Kaynağa Gözat

提交相关商机代码

Lijy 1 yıl önce
ebeveyn
işleme
a5cc4aafae

+ 32 - 14
fhKeeper/formulahousekeeper/customerBuler-crm/src/pages/business/index.vue

@@ -60,16 +60,17 @@
           <el-table ref="businessTableRef" :data="businessTable" border v-loading="allLoading.businessTableLading"
             @selection-change="changeBatch" style="width: 100%;height: 100%;">
             <el-table-column type="selection" width="55" />
-            <el-table-column v-for="(item, index) in tableColumn" :prop="item.prop" :label="item.label" :key="index" :width="item.width">
+            <el-table-column v-for="(item, index) in tableColumn" :prop="item.prop" :label="item.label" :key="index"
+              :width="item.width">
               <template #default="scope">
-                <el-button link type="primary" size="large" @click="dealWithTableColumn(scope.row, item.eventName)" v-if="item.eventName">{{scope.row[item.prop]}}</el-button>
-                <template v-else>{{scope.row[item.prop]}}</template>
+                <el-button link type="primary" size="large" @click="dealWithTableColumn(scope.row, item.eventName)"
+                  v-if="item.eventName">{{ scope.row[item.prop] }}</el-button>
+                <template v-else>{{ scope.row[item.prop] }}</template>
               </template>
             </el-table-column>
             <el-table-column label="操作" fixed="right" width="200">
               <template #default="scope">
-                <el-button link type="primary" size="large"
-                  @click="editNewBusiness(scope.row)">编辑</el-button>
+                <el-button link type="primary" size="large" @click="editNewBusiness(scope.row)">编辑</el-button>
                 <el-button link type="primary" size="large" @click="newTask(scope.row)">新建任务</el-button>
                 <el-button link type="danger" size="large"
                   @click="businessDeteleItem(scope.row.id, scope.row.name)">删除</el-button>
@@ -99,9 +100,11 @@
         </div>
       </template>
       <div class="h-[60vh] overflow-y-auto scroll-bar pt-3" v-loading="allLoading.generateFormLading">
-        <GenerateForm ref="businessTemplateRef" :data="businessTemplate" :value="businessTemplateValue" :key="businessTemplateKey" />
+        <GenerateForm ref="businessTemplateRef" :data="businessTemplate" :value="businessTemplateValue"
+          :key="businessTemplateKey" />
         <div>相关产品</div>
-        <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList" />
+        <RelatedProducts ref="relatedProductsRef" :productTableList="productTableList"
+          :productTableListValue="productTableListValue" />
       </div>
     </el-dialog>
 
@@ -133,7 +136,8 @@
         <div class="flex justify-between items-center border-b pb-3 dialog-header">
           <h4 :id="titleId">导入产品</h4>
           <div class="flex">
-            <el-upload class="upload-demo mr-3" :limit="1" :show-file-list="false" accept=".xlsx" :http-request="importBusiness">
+            <el-upload class="upload-demo mr-3" :limit="1" :show-file-list="false" accept=".xlsx"
+              :http-request="importBusiness">
               <el-button type="primary" :loading="allLoading.importLoading">导入</el-button>
             </el-upload>
             <el-button @click="allVisible.importVisible = false">取消</el-button>
@@ -142,7 +146,8 @@
       </template>
       <div class="p-8">
         <div class="ml-4 mr-4">
-          <div class="flex items-center">1、点击下载 <el-link type="primary" @click="downloadTemplate(MODURL, '商机导入模板.xlsx')">商机导入模板.xlsx</el-link></div>
+          <div class="flex items-center">1、点击下载 <el-link type="primary"
+              @click="downloadTemplate(MODURL, '商机导入模板.xlsx')">商机导入模板.xlsx</el-link></div>
           <div class="mt-4">2、填写excel文件、商机名称、商机金额、商机阶段必填</div>
         </div>
       </div>
@@ -236,6 +241,7 @@ const fixedData = reactive({
   Personnel: [] as personnelInterface[]
 })
 const productTableList = ref([])
+const productTableListValue = ref([])
 
 
 function editBusiness(visibles: boolean) {
@@ -265,11 +271,13 @@ function editNewBusiness(item: any) {
   showVisible('newBusinessisible')
   allLoading.generateFormLading = true
   if (item) {
+    editProduct(item)
     businessTemplateValue.value = item
     allText.newBusinessisibleText = '编辑商机'
   }
   if (!item) {
     businessTemplateValue.value = {}
+    productTableListValue.value = []
     allText.newBusinessisibleText = '新建商机'
   }
   setTimeout(() => {
@@ -353,7 +361,7 @@ async function importBusiness(param: UploadRequestOptions) {
 function exportBusinessTableList() {
   allLoading.exoprtLoading = true
   let valueForm = getFromValue(businessOpportunityForm)
-  post('接口名称', {...valueForm}).then((res) => {
+  post('接口名称', { ...valueForm }).then((res) => {
     downloadFile(res.data, '商机表导出.xlsx')
   }).finally(() => {
     allLoading.exoprtLoading = false
@@ -369,6 +377,17 @@ function changeBatch(flag: boolean = true) {
   }
 }
 
+function editProduct(row: any) {
+  const list = row.businessItemProductList.map((item: any) => {
+    const { id, productName, productCode, unit, unitName, typeName, type, price, inventory, orderProductDetail, num, discount, sealPrice, totalPrice } = item
+    return {
+      id, productId: id, productName, productCode, unit, unitName, typeName, type, price, inventory,
+      num, discount, sealPrice, totalPrice 
+    }
+  })
+  productTableListValue.value = list
+}
+
 function showVisible(type: keyof typeof allVisible) { // 显示弹窗
   allVisible[type] = true
 }
@@ -425,7 +444,7 @@ async function getSystemField() {
   fixedData.BusinessStage = (row.data || []).map((item: any) => {
     const { name, id, seq } = item
     return { name, id, seq }
-  }).sort(function (a: any, b: any) {return a.seq - b.seq;});
+  }).sort(function (a: any, b: any) { return a.seq - b.seq; });
 
   const { data } = await post(GETPERSONNEL, {})
   fixedData.Personnel = data.map((item: any) => {
@@ -447,7 +466,7 @@ function toBusinessTableDetail(row: any) {
 }
 
 function dealWithTableColumn(row: any, eventName: string) {
-  if(eventName == 'toClueTableDetail') {
+  if (eventName == 'toClueTableDetail') {
     toBusinessTableDetail(row)
   }
 }
@@ -491,5 +510,4 @@ onMounted(() => {
     font-size: 18px;
     line-height: 24px;
   }
-}
-</style>
+}</style>