index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. <template>
  2. <div class="h-full flex">
  3. <div class="p-5 w-80 pr-0">
  4. <div class="bg-white w-full h-full shadow-md rounded-md flex flex-col">
  5. <div class="flex-1 p-3 overflow-y-auto">
  6. <el-form :model="businessOpportunityForm" label-width="70px" style="max-width: 600px">
  7. <el-form-item label="商机名称">
  8. <el-input v-model="businessOpportunityForm.name" clearable placeholder="请输入"></el-input>
  9. </el-form-item>
  10. <el-form-item label="商机阶段">
  11. <el-select v-model="businessOpportunityForm.stageId" placeholder="请选择" clearable>
  12. <el-option v-for="item in fixedData.BusinessStage" :key="item.id" :label="item.name" :value="item.id" />
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="客户名称">
  16. <el-input v-model="businessOpportunityForm.customerName" clearable placeholder="请输入"></el-input>
  17. </el-form-item>
  18. <el-form-item label="联系人">
  19. <el-input v-model="businessOpportunityForm.contactsName" clearable placeholder="请输入"></el-input>
  20. </el-form-item>
  21. <el-form-item label="产品">
  22. <el-select v-model="businessOpportunityForm.product" placeholder="请选择" clearable>
  23. <el-option v-for="item in fixedData.ProductArr" :key="item.value" :label="item.label"
  24. :value="item.value" />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="负责人">
  28. <!-- <el-select v-model="businessOpportunityForm.inchargerId" placeholder="请选择" clearable>
  29. <el-option v-for="item in fixedData.Personnel" :key="item.id" :label="item.name" :value="item.id" />
  30. </el-select> -->
  31. <personnel-search v-model="businessOpportunityForm.inchargerId" :size="''" placeholder="请选择"></personnel-search>
  32. </el-form-item>
  33. <el-form-item label="创建时间">
  34. <el-date-picker v-model="businessOpportunityForm.startTime" type="date" placeholder="请选择"
  35. :clearable="false" format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
  36. </el-form-item>
  37. <el-form-item label="">
  38. <el-date-picker v-model="businessOpportunityForm.endTime" type="date" placeholder="请选择" :clearable="false"
  39. format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
  40. </el-form-item>
  41. </el-form>
  42. </div>
  43. <div class="w-full flex p-3 shadow-[0_-3px_5px_0px_rgba(0,0,0,0.2)]">
  44. <El-button class="w-full" @click="resetForm()">重置</El-Button>
  45. <El-button type="primary" class="w-full" @click="getBusinessTableList()">搜索</El-Button>
  46. </div>
  47. </div>
  48. </div>
  49. <div class="flex-1 p-5 overflow-auto">
  50. <div class="bg-white w-full h-full p-3 shadow-md rounded-md flex flex-col">
  51. <div class="flex justify-end pb-3">
  52. <el-button v-permission="['businessAddAnEdit']" type="primary"
  53. @click="editNewBusiness(false)">新建商机</el-button>
  54. <el-button type="primary" @click="showVisible('batchTransferVisible')"
  55. :disabled="batchTableData.length <= 0">批量转移</el-button>
  56. <el-button type="primary" v-permission="['businessDelete']" @click="batchDeteleItem()"
  57. :disabled="batchTableData.length <= 0">批量删除</el-button>
  58. <el-button type="primary" @click="showVisible('stageSetVisible')">阶段设置</el-button>
  59. <el-button type="primary" v-permission="['businessRecycle']"
  60. @click="showVisible('deteleBusinessVisible')">回收站</el-button>
  61. <el-button v-permission="['businessImport']" type="primary"
  62. @click="showVisible('importVisible')">导入</el-button>
  63. <el-button v-permission="['businessExport']" type="primary" @click="exportBusinessTableList()"
  64. :loading="allLoading.exoprtLoading">导出</el-button>
  65. </div>
  66. <div class="flex-1 w-full overflow-hidden">
  67. <el-table ref="businessTableRef" :data="businessTable" border v-loading="allLoading.businessTableLading"
  68. :show-overflow-tooltip="tableShowOverflowTooltip" @selection-change="changeBatch"
  69. style="width: 100%;height: 100%;">
  70. <el-table-column type="selection" width="55" />
  71. <el-table-column v-for="(item, index) in tableColumn" :prop="item.prop" :label="item.label" :key="index"
  72. :width="item.width">
  73. <template #default="scope">
  74. <div class="table-text-textnowrap" v-if="item.eventName"
  75. @click="dealWithTableColumn(scope.row, item.eventName)">{{ scope.row[item.prop] }}</div>
  76. <template v-else-if="['inchargerName', 'creatorName'].includes(item.prop)">
  77. <TextTranslation translationTypes="userName" :translationValue="scope.row[item.prop]"></TextTranslation>
  78. </template>
  79. <template v-else>{{ scope.row[item.prop] }}</template>
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="操作" fixed="right" width="200"
  83. v-permission="['businessAddAnEdit', 'tasksAdd', 'businessDelete']">
  84. <template #default="scope">
  85. <el-button link type="primary" size="large" @click="editNewBusiness(scope.row)"
  86. v-permission="['businessAddAnEdit']">编辑</el-button>
  87. <el-button link type="primary" size="large" @click="newTask(scope.row)"
  88. v-permission="['tasksAdd']">新建任务</el-button>
  89. <el-button link type="danger" size="large" @click="businessDeteleItem(scope.row.id, scope.row.name)"
  90. v-permission="['businessDelete']">删除</el-button>
  91. </template>
  92. </el-table-column>
  93. </el-table>
  94. </div>
  95. <div class="flex justify-end pt-3">
  96. <el-pagination layout="total, prev, pager, next, sizes" :page-size="businessOpportunityForm.pageFrom"
  97. @size-change="handleSizeChange" @current-change="handleCurrentChange" :total="businessTotalTable"
  98. :hide-on-single-page="true" />
  99. </div>
  100. </div>
  101. </div>
  102. <!-- 弹窗 -->
  103. <el-dialog v-model="allVisible.newBusinessisible" width="1000" :show-close="false" top="10vh"
  104. :before-close="handleClose">
  105. <template #header="{ close, titleId, titleClass }">
  106. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  107. <h4 :id="titleId">{{ allText.newBusinessisibleText }}</h4>
  108. <div>
  109. <el-button type="primary" :loading="allLoading.newBusinessSaveLading"
  110. :disabled="allLoading.businessSaveLading" @click="editBusiness(true)"
  111. v-if="!businessTemplateValue.id">保存并新建</el-button>
  112. <el-button type="primary" @click="editBusiness(false)" :loading="allLoading.businessSaveLading"
  113. :disabled="allLoading.newBusinessSaveLading">保存</el-button>
  114. <el-button @click="closeVisible('newBusinessisible')">取消</el-button>
  115. </div>
  116. </div>
  117. </template>
  118. <div class="h-[60vh] overflow-y-auto scroll-bar pt-3" v-loading="allLoading.generateFormLading">
  119. <GenerateForm ref="businessTemplateRef" :data="businessTemplate" :value="businessTemplateValue"
  120. :key="businessTemplateKey" />
  121. <div>相关产品</div>
  122. <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList"
  123. :productTableListValue="productTableListValue" />
  124. </div>
  125. </el-dialog>
  126. <!-- 批量转移 -->
  127. <el-dialog v-model="allVisible.batchTransferVisible" width="600" :show-close="false" top="10vh">
  128. <template #header="{ close, titleId, titleClass }">
  129. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  130. <h4 :id="titleId">{{ allText.transferText }}</h4>
  131. <div>
  132. <el-button type="primary" v-loading="allLoading.transferLoading" @click="transferBusiness()">转移</el-button>
  133. <el-button @click="allVisible.batchTransferVisible = false">取消</el-button>
  134. </div>
  135. </div>
  136. </template>
  137. <div class="scroll-bar m-6">
  138. <div class="flex mb-4">
  139. <div class="w-20 flex items-center justify-end pr-4">转移至:</div>
  140. <!-- <el-select v-model="transferPersonnel" placeholder="请选择" class="flex1">
  141. <el-option v-for="item in fixedData.Personnel" :key="item.id" :label="item.name" :value="item.id" />
  142. </el-select> -->
  143. <personnel-search v-model="transferPersonnel" :size="''" placeholder="请选择"></personnel-search>
  144. </div>
  145. <div class="pl-3 text-[#e94a4a]">转移后,将看不到此商机</div>
  146. </div>
  147. </el-dialog>
  148. <!-- 导入 -->
  149. <el-dialog v-model="allVisible.importVisible" width="680" :show-close="false" top="10vh">
  150. <template #header="{ close, titleId, titleClass }">
  151. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  152. <h4 :id="titleId">导入产品</h4>
  153. <div class="flex">
  154. <el-upload class="upload-demo mr-3" :limit="1" :show-file-list="false" accept=".xlsx"
  155. :http-request="importBusiness">
  156. <el-button type="primary" :loading="allLoading.importLoading">导入</el-button>
  157. </el-upload>
  158. <el-button @click="allVisible.importVisible = false">取消</el-button>
  159. </div>
  160. </div>
  161. </template>
  162. <div class="p-8">
  163. <div class="ml-4 mr-4">
  164. <div class="flex items-center">1、点击下载 <el-link type="primary"
  165. @click="downloadTemplate(MODURL, '商机导入模板.xlsx')">商机导入模板.xlsx</el-link></div>
  166. <div class="mt-4">2、填写excel文件、商机名称、商机金额、商机阶段必填</div>
  167. </div>
  168. </div>
  169. </el-dialog>
  170. <!-- 新建任务 -->
  171. <TaskModal :visible="allVisible.taskModalVisible" :edit-form="taskModalForm" :save-loading="taskLoading"
  172. @close="closeVisible('taskModalVisible')" @submit="submitForm" :title="'新建任务'"
  173. :disabled-list="['taskType', 'businessOpportunityId']" />
  174. <!-- 回收站 -->
  175. <DeteleBusiness :visibles="allVisible.deteleBusinessVisible" @closeVisible="closeVisible" />
  176. <!-- 阶段设置 -->
  177. <StageSetting :visibles="allVisible.stageSetVisible" @closeVisible="closeVisible" />
  178. </div>
  179. </template>
  180. <script lang="ts" setup>
  181. import { ref, reactive, onMounted, inject } from "vue";
  182. import type { ElTable, FormInstance, FormRules, UploadRequestOptions } from 'element-plus'
  183. import { useRouter, useRoute } from "vue-router";
  184. import { GETSYSFILED, MOD, GETPERSONNEL, GETGENERATEFOEM, GETBUSINESSLIST, UPDATEINSET, BUSINESSDETELE, BATCHTRANSFER, MODURL, tableColumn, BUSIESS_GETSATE, URL_IMPOERBUSINESS, BUSIESS_INFO, URL_EXPORTBUSINESS } from './api'
  185. import { GETTABLELIST } from '@/pages/product/api'
  186. import { post, get, uploadFile } from "@/utils/request";
  187. import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, createTaskFromType, formatDate, confirmAction, downloadTemplate, downloadFile, judgmentaAmounteEqual } from '@/utils/tools'
  188. import { createTask } from '@/components/TaskModal/taskFunction'
  189. import { formatDateTime } from '@/utils/times'
  190. import { GenerateForm } from '@zmjs/form-design';
  191. import { tableShowOverflowTooltip } from '@/utils/globalVariables'
  192. import RelatedProducts from '@/components/relatedProducts/relatedProducts.vue'
  193. import TaskModal from '@/components/TaskModal/index.vue'
  194. import DeteleBusiness from './component/deteleTables.vue'
  195. import StageSetting from './component/stageSetting.vue'
  196. import { GETTABLELISTPRODUCT } from "../order/api";
  197. import personnelSearch from '@/components/translationComponent/personnelSearch/personnelSearch.vue';
  198. const route = useRoute()
  199. const router = useRouter()
  200. const globalPopup = inject<GlobalPopup>('globalPopup')
  201. const businessTableRef = ref<InstanceType<typeof ElTable>>() // 商机table dom
  202. const businessTotalTable = ref(0)
  203. const businessTemplateRef = ref<typeof GenerateForm>() // 自定义表单dom
  204. const relatedProductsRef = ref<typeof RelatedProducts>()
  205. const businessTemplateValue = ref<any>({})
  206. const businessTemplateKey = ref(1)
  207. const businessTemplate = ref({
  208. config: {},
  209. list: []
  210. }) // 自定义表单数据
  211. const businessTable = ref([])
  212. const allLoading = reactive({
  213. businessTableLading: false,
  214. businessSaveLading: false,
  215. newBusinessSaveLading: false,
  216. transferLoading: false,
  217. importLoading: false,
  218. exoprtLoading: false,
  219. generateFormLading: false
  220. })
  221. const allVisible = reactive({
  222. newBusinessisible: false,
  223. recycleVisible: false,
  224. taskModalVisible: false,
  225. batchTransferVisible: false,
  226. deteleBusinessVisible: false,
  227. stageSetVisible: false,
  228. importVisible: false
  229. })
  230. const allText = reactive({
  231. newBusinessisibleText: '新建商机',
  232. transferText: '转移商机'
  233. }) // 所有文本
  234. const taskModalForm = ref({}) // 任务弹窗表单
  235. const taskLoading = ref<saveLoadingType>("1");
  236. const batchTableData = ref([]) // 批量数据
  237. const transferPersonnel = ref('') // 转移人
  238. const businessOpportunityForm = reactive<businessOpportunityFormType>({
  239. name: '',
  240. stageId: '',
  241. customerName: '',
  242. contactsName: '',
  243. product: '',
  244. inchargerId: '',
  245. startTime: getFirstDayOfMonth(new Date()),
  246. endTime: formatDate(new Date()),
  247. pageIndex: 1,
  248. pageFrom: 10
  249. })
  250. const fixedData = reactive({
  251. BusinessStage: [] as fixedDataInterface[],
  252. Personnel: [] as personnelInterface[],
  253. ProductArr: [] as productInterface[]
  254. })
  255. const productTableList = ref([])
  256. const productTableListValue = ref([])
  257. function editBusiness(visibles: boolean) {
  258. businessTemplateRef.value?.getData().then((res: any) => {
  259. let productTableListData = relatedProductsRef?.value?.returnData()
  260. console.log(!productTableListData, judgmentaAmounteEqual({ ...businessTemplateValue.value, ...res }, productTableListData))
  261. if (!productTableListData || judgmentaAmounteEqual({ ...businessTemplateValue.value, ...res }, productTableListData)) {
  262. return
  263. }
  264. productTableListData.forEach((item: any) => {
  265. delete item.id
  266. })
  267. let newForm = {
  268. ...res,
  269. expectedTransactionDate: res.expectedTransactionDate ? formatDateTime(new Date(res.expectedTransactionDate)) : '',
  270. businessItemProductList: productTableListData ? JSON.stringify(productTableListData) : []
  271. }
  272. allLoading.businessSaveLading = true
  273. setTimeout(() => {
  274. post(UPDATEINSET, { ...businessTemplateValue.value, ...newForm }).then((_res) => {
  275. allVisible.newBusinessisible = visibles
  276. globalPopup?.showSuccess('保存成功')
  277. getBusinessTableList()
  278. }).finally(() => {
  279. allLoading.businessSaveLading = false
  280. })
  281. }, 1500)
  282. }).catch((_err: any) => {
  283. console.log(_err)
  284. globalPopup?.showError('请填写完整')
  285. })
  286. }
  287. function editNewBusiness(item: any) {
  288. console.log(item, '选择数据')
  289. showVisible('newBusinessisible')
  290. allLoading.generateFormLading = true
  291. if (item) {
  292. editProduct(item)
  293. businessTemplateValue.value = editBusinessData(item)
  294. allText.newBusinessisibleText = '编辑商机'
  295. }
  296. if (!item) {
  297. businessTemplateValue.value = {}
  298. productTableListValue.value = []
  299. allText.newBusinessisibleText = '新建商机'
  300. }
  301. setTimeout(() => {
  302. businessTemplateRef.value && businessTemplateRef.value.reset()
  303. businessTemplateKey.value++
  304. allLoading.generateFormLading = false
  305. }, 500)
  306. }
  307. function newTask(item: any) {
  308. const { id } = item
  309. taskModalForm.value = { ...createTaskFromType(1), businessOpportunityId: id, }
  310. showVisible('taskModalVisible')
  311. }
  312. function submitForm(submitData: any, isClose: boolean) { // 任务提交
  313. taskLoading.value = '2'
  314. createTask(submitData, isClose).then((res) => {
  315. const { saveLoading, isClose } = res
  316. taskLoading.value = saveLoading
  317. allVisible.taskModalVisible = isClose
  318. globalPopup?.showSuccess('新增成功')
  319. }).catch((err) => {
  320. const { saveLoading, isClose, message } = err
  321. taskLoading.value = saveLoading
  322. allVisible.taskModalVisible = isClose
  323. globalPopup?.showError(message)
  324. })
  325. }
  326. function transferBusiness() {
  327. const ids = batchTableData.value.map((item: any) => item.id).join(',')
  328. allLoading.transferLoading = true
  329. post(BATCHTRANSFER, { ids, inchargerId: transferPersonnel.value }).then(() => {
  330. transferPersonnel.value = ''
  331. globalPopup?.showSuccess('转移成功')
  332. closeVisible('batchTransferVisible')
  333. getBusinessTableList()
  334. }).finally(() => {
  335. allLoading.transferLoading = false
  336. })
  337. }
  338. function batchDeteleItem() {
  339. const value = batchTableData.value.map((item: any) => item.id).join(',')
  340. const label = batchTableData.value.map((item: any) => item.name).join(',')
  341. businessDeteleItem(value, label, true)
  342. }
  343. function businessDeteleItem(value: string | number, label: string, batch: boolean = false) {
  344. confirmAction(`确定${batch ? '批量' : ''}删除【${label}】商机吗?`).then(() => {
  345. post(BUSINESSDETELE, { ids: value }).then(res => {
  346. if (res.code != 'ok') {
  347. globalPopup?.showError(res.msg)
  348. return
  349. }
  350. globalPopup?.showSuccess('删除成功')
  351. changeBatch(false)
  352. getBusinessTableList()
  353. }).catch((err) => {
  354. globalPopup?.showError(err.msg)
  355. })
  356. })
  357. }
  358. async function importBusiness(param: UploadRequestOptions) {
  359. allLoading.importLoading = true
  360. const formData = new FormData();
  361. formData.append('multipartFile', param.file)
  362. const res = await uploadFile(URL_IMPOERBUSINESS, formData).finally(() => {
  363. allLoading.importLoading = false
  364. })
  365. if (res.code == 'ok') {
  366. globalPopup?.showSuccess('导入成功' || '')
  367. getBusinessTableList()
  368. return
  369. }
  370. globalPopup?.showError(res.msg || '')
  371. }
  372. function exportBusinessTableList() {
  373. allLoading.exoprtLoading = true
  374. let valueForm = getFromValue(businessOpportunityForm)
  375. post(URL_EXPORTBUSINESS, { ...valueForm }).then((res) => {
  376. downloadFile(res.data, '商机表导出.xlsx')
  377. }).finally(() => {
  378. allLoading.exoprtLoading = false
  379. })
  380. }
  381. function changeBatch(flag: boolean = true) {
  382. if (flag) {
  383. batchTableData.value = businessTableRef.value && businessTableRef.value.getSelectionRows()
  384. } else {
  385. batchTableData.value = []
  386. businessTableRef.value && businessTableRef.value.clearSelection()
  387. }
  388. }
  389. function editProduct(row: any) {
  390. post(BUSIESS_INFO, { id: row.id }).then(({ data }) => {
  391. const list = (data.businessItemProducts || []).map((item: any) => {
  392. const { id, productName, productId, productCode, unit, unitName, typeName, productType, type, price, inventory, orderProductDetail, num, discount, sellingPrice, sealPrice, totalPrice, quantity } = item
  393. return {
  394. id, productId: productId, productName, productCode, unitName: unit, typeName: productType, type, price, inventory,
  395. num, discount, sealPrice, totalPrice, quantity, sellingPrice
  396. }
  397. })
  398. productTableListValue.value = list
  399. })
  400. }
  401. function editBusinessData(item: any) {
  402. const { name, expectedTransactionDate, amountOfMoney = 0, customerId, contactsId, creatorId, stageId, id, inchargerId, remark } = item
  403. return { name, expectedTransactionDate, amountOfMoney, customerId, contactsId, creatorId, stageId, id, inchargerId, remark }
  404. }
  405. function handleSizeChange(val: number) {
  406. businessOpportunityForm.pageIndex = 1
  407. businessOpportunityForm.pageFrom = val
  408. getBusinessTableList()
  409. }
  410. function handleCurrentChange(val: number) {
  411. businessOpportunityForm.pageIndex = val
  412. getBusinessTableList()
  413. }
  414. function showVisible(type: keyof typeof allVisible) { // 显示弹窗
  415. allVisible[type] = true
  416. }
  417. function closeVisible(type: keyof typeof allVisible) {
  418. allVisible[type] = false
  419. }
  420. function handleClose(done: () => void) {
  421. done()
  422. }
  423. function getBusinessTableList() {
  424. const formValue = getFromValue(businessOpportunityForm)
  425. allLoading.businessTableLading = true
  426. post(GETBUSINESSLIST, { ...formValue }).then((res) => {
  427. const { data, total } = res.data
  428. businessTable.value = data.map((item: any) => {
  429. return {
  430. ...item,
  431. expectedTransactionDate: formatDate(new Date(item.expectedTransactionDate))
  432. }
  433. })
  434. businessTotalTable.value = total
  435. }).finally(() => {
  436. allLoading.businessTableLading = false
  437. })
  438. }
  439. function resetForm() {
  440. let reset = {
  441. startTime: getFirstDayOfMonth(new Date()),
  442. endTime: formatDate(new Date()),
  443. pageIndex: 1,
  444. pageFrom: 10
  445. }
  446. let newBusinessOpportunityForm = resetFromValue(businessOpportunityForm, { ...reset })
  447. Object.assign(businessOpportunityForm, newBusinessOpportunityForm)
  448. getBusinessTableList()
  449. }
  450. async function getSystemField() {
  451. // const systemField = getAllListByCode(['商机阶段'])
  452. // for (let i in systemField) {
  453. // const { data } = await get(`${GETSYSFILED}?code=${systemField[i]}`)
  454. // for (let key of Object.keys(fixedData)) {
  455. // if (systemField[i] == key) {
  456. // Object.assign(fixedData, { [key]: data })
  457. // }
  458. // }
  459. // }
  460. const row = await post(BUSIESS_GETSATE, {})
  461. fixedData.BusinessStage = (row.data || []).map((item: any) => {
  462. const { name, id, seq } = item
  463. return { name, id, seq }
  464. }).sort(function (a: any, b: any) { return a.seq - b.seq; });
  465. const { data } = await post(GETPERSONNEL, {})
  466. fixedData.Personnel = data.map((item: any) => {
  467. const { id, name, phone, jobNumber } = item
  468. return {
  469. id, name, phone, jobNumber
  470. }
  471. })
  472. post(GETTABLELISTPRODUCT, { pageIndex: -1, pageSize: -1 }).then(({ data }) => {
  473. fixedData.ProductArr = (data.record || []).map((item: any) => {
  474. const { id, productName } = item
  475. return {
  476. value: id, label: productName
  477. }
  478. })
  479. })
  480. const res = await get(GETGENERATEFOEM)
  481. businessTemplate.value = JSON.parse(res.data[0].config)
  482. }
  483. function toBusinessTableDetail(row: any) {
  484. router.push({
  485. path: `${MOD}/detail`,
  486. query: { id: row.id }
  487. })
  488. }
  489. function dealWithTableColumn(row: any, eventName: string) {
  490. if (eventName == 'toClueTableDetail') {
  491. toBusinessTableDetail(row)
  492. }
  493. }
  494. function getProductTableList() {
  495. post(GETTABLELIST, { pageIndex: -1, pageSize: -1 }).then((res) => {
  496. if (res.code == 'ok') {
  497. const { record, total } = res.data
  498. productTableList.value = record.map((item: any) => {
  499. const { id, productName, productCode, unit, unitName, typeName, type, price, inventory } = item
  500. return {
  501. id,
  502. productId: id,
  503. productName,
  504. productCode,
  505. unit,
  506. unitName,
  507. price,
  508. type,
  509. typeName,
  510. inventory,
  511. quantity: '',
  512. discount: '',
  513. totalPrice: ''
  514. }
  515. })
  516. }
  517. })
  518. }
  519. onMounted(() => {
  520. getSystemField()
  521. getProductTableList()
  522. getBusinessTableList()
  523. })
  524. </script>
  525. <style lang="scss" scoped>
  526. .dialog-header {
  527. h4 {
  528. font-size: 18px;
  529. line-height: 24px;
  530. }
  531. }
  532. </style>