From 049ecf224380ec0a714a00c6567f8c70bee61662 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期三, 27 三月 2024 19:26:00 +0800
Subject: [PATCH] 销售明细单发货操作的时候一次发货和多发货 2个部分的列表表头不显示的问题修改+切换表头变化的逻辑处理

---
 src/views/sales/salesDetails/shipmentsDialog.vue |  131 +++++++++++++++++++++++++++++++------------
 1 files changed, 94 insertions(+), 37 deletions(-)

diff --git a/src/views/sales/salesDetails/shipmentsDialog.vue b/src/views/sales/salesDetails/shipmentsDialog.vue
index 79dcc11..c6dc1d6 100644
--- a/src/views/sales/salesDetails/shipmentsDialog.vue
+++ b/src/views/sales/salesDetails/shipmentsDialog.vue
@@ -13,7 +13,7 @@
         :model="editConfig.infomation"
         :rules="rules"
         label-position="left"
-        label-width="10%"
+        label-width="90px"
         size="mini"
         style="height: 60vh; overflow-x: hidden"
       >
@@ -23,15 +23,15 @@
           <div class="basic-info-view">
             <el-row>
               <el-col :span="24">
-                <el-form-item width="50%" label="浜や粯绫诲瀷" prop="addressee">
-                  <el-radio-group v-model="shipmentsType" @change="handleRadioChange">
+                <el-form-item width="50%" label="浜や粯绫诲瀷锛�" prop="deliverType">
+                  <el-radio-group v-model="editConfig.infomation.deliverType" @change="handleRadioChange">
                     <el-radio :label="1">涓�娆″彂璐�</el-radio>
                     <el-radio :label="2">澶氭鍙戣揣</el-radio>
                   </el-radio-group>
                 </el-form-item>
               </el-col>
               <el-col :span="24">
-                <el-form-item label="鍏宠仈椤圭洰" prop="projectId">
+                <el-form-item label="鍏宠仈椤圭洰锛�" prop="projectId">
                   <el-select
                     v-model="editConfig.infomation.projectId"
                     placeholder="璇烽�夋嫨"
@@ -78,6 +78,7 @@
               @getSelectArray="getSelectArray"
               @emptyProductClick="emptyProductClick"
               @clearupProduct="clearupProduct"
+              @selTableCol="selTableCol"
             ></CommonFormTableView>
           </div>
           <p class="tips tips_success" v-if="completely"><i class="el-icon-warning-outline"></i>{{ shipmentsMsg }}</p>
@@ -125,6 +126,17 @@
     },
   },
   data() {
+    // 浜у搧淇℃伅
+    const productColumn = [
+          { label: "浜у搧缂栧彿", prop: "number", isShowColumn:true, },
+          { label: "浜у搧鍚嶇О", prop: "name",isShowColumn:true, min: 110 },
+          { label: "璁㈠崟鏁伴噺", prop: "orderAmount", isShowColumn:true,},
+          { label: "璁㈠崟瀹屾垚鏁伴噺", prop: "finishAmount",isShowColumn:true, },
+          { label: "鍙敤搴撳瓨", prop: "availableAmount",isShowColumn:true, },
+          { label: "鏈彂璐ф暟閲�", prop: "leftAmount", isShowColumn:true, },
+          { label: "鏈鍙戣揣鏁伴噺", prop: "outputAmount", inputFloat: true,isRequird:true,isShowColumn:true,},
+          { label: "鍓╀綑鍙戣揣鏁伴噺", prop: "availableAmount",isShowColumn:true,},
+        ]
     return {
       dialogWidth: "60%",
       editConfig: this.editCommonConfig,
@@ -136,7 +148,15 @@
       wechatOrderStatusOptions: [], // 寰俊璁㈠崟鐘舵��
       currencyOptions: [{ id: 1, name: "浜烘皯甯�" }], // 甯佺
       approvalWorkflowOptions: [], // 瀹℃壒娴佺▼
-      productTableList: {},
+      productTableList: {
+        allcol: [],
+        showcol: ['浜у搧缂栧彿','浜у搧鍚嶇О', "璁㈠崟鏁伴噺", "璁㈠崟瀹屾垚鏁伴噺",],
+        tableData: [],
+        tableColumn: []
+      },
+      tableColumn: productColumn,
+      searchOptions: [],
+      
       showSummary: {
         show: true,
         total: true,
@@ -190,7 +210,6 @@
           return time.getTime() > Date.now()
         }
       },
-      shipmentsType:1,
       options: [{
         value: '1',
         label: '浠撳簱1--搴撳瓨涓嶈冻鐨勬儏鍐�'
@@ -212,19 +231,22 @@
   created() {
     this.$store.dispatch("geClient")
     this.setTableForm()
+    this.handleRadioChange()
     this.getCommonData()
     this.formInfo()
     this.getUseSystemSet({ modeType: "xsmx" })
     this.getProjectList()
     this.getDeliveryPrepareInfo({
-      saleDetailID: this.editCommonConfig.infomation.saleDetailID,
-      saleDetailNumber: this.editCommonConfig.infomation.saleDetailNumber
+          saleDetailID: this.editCommonConfig.infomation.saleDetailID,
+          saleDetailNumber: this.editCommonConfig.infomation.saleDetailNumber
     })
   },
   watch: {
     "editClientManageConfig.visible"(val) {
       if (val) {
+        this.handleRadioChange()
         this.formInfo()
+        
       }
     }
   },
@@ -271,7 +293,7 @@
           let isShipments=false
           let shipmentsNum=false
           this.shipmentsList.map((item)=>{
-            if(this.shipmentsType===1){
+            if(this.editConfig.infomation.deliverType===1){
               if(item.leftAmount<item.availableAmount&&item.leftAmount>0){
                 isShipments=false
               }else if(item.leftAmount<=0){
@@ -317,7 +339,7 @@
       this.shipmentsList.map((item)=>{
         let obj={
           number:item.number,
-          outputAmount:this.shipmentsType===1?item.leftAmount:item.outputAmount // 鏈鍙戣揣鏁伴噺
+          outputAmount:this.editConfig.infomation.deliverType===1?item.leftAmount:item.outputAmount // 鏈鍙戣揣鏁伴噺
         }
         params.products.push(obj)
       })
@@ -439,23 +461,51 @@
           }
         ]
       } else {
-        this.tableData = this.editConfig.infomation.products
+        this.tableData = this.editConfig.infomation.products?this.editConfig.infomation.products:[]
         this.tableData.map((item, index) => {
           item.productId = index + 1
         })
         this.getQuotation(this.editConfig.infomation.saleChanceId, "鍏ㄩ儴浜у搧")
       }
+      this.tableColumn=[
+          { label: "浜у搧缂栧彿", prop: "number", isShowColumn:true, },
+          { label: "浜у搧鍚嶇О", prop: "name",isShowColumn:true, min: 110 },
+          { label: "璁㈠崟鏁伴噺", prop: "orderAmount", isShowColumn:true,},
+          { label: "璁㈠崟瀹屾垚鏁伴噺", prop: "finishAmount",isShowColumn:true, }
+        ]
       this.productTableList = {
         tableData: this.tableData,
         isReturn: true,
-        tableColumn: [
-          { label: "浜у搧缂栧彿", prop: "number" },
-          { label: "浜у搧鍚嶇О", prop: "name",   min: 110 },
-          { label: "璁㈠崟鏁伴噺", prop: "orderAmount" },
-          { label: "璁㈠崟瀹屾垚鏁伴噺", prop: "finishAmount" },
-          // { label: "鍙敤搴撳瓨", prop: "unit" },
-        ]
+        // tableColumn: [
+        //   { label: "浜у搧缂栧彿", prop: "number", isShowColumn:true, },
+        //   { label: "浜у搧鍚嶇О", prop: "name",isShowColumn:true, min: 110 },
+        //   { label: "璁㈠崟鏁伴噺", prop: "orderAmount", isShowColumn:true,},
+        //   { label: "璁㈠崟瀹屾垚鏁伴噺", prop: "finishAmount",isShowColumn:true, }
+        // ],
+        tableColumn: this.setColumnVisible(this.productTableList.showcol, this.tableColumn)
       }
+      this.setTableList(this.productTableList)
+    },
+    setTableList(tableList) {
+      tableList.allcol = tableList.tableColumn.filter((ele) => !ele.default).map((ele) => ele.label)
+      this.searchOptions = []
+      for (let i = 0; i < tableList.tableColumn.length; i++) {
+        const label = tableList.tableColumn[i].label
+        const value = tableList.tableColumn[i].prop
+        this.searchOptions.push({ value: value, label: label })
+      }
+    },
+    setColumnVisible(showcol, tableColumn) {
+      return tableColumn.map((ele) => {
+        return {
+          ...ele,
+          isShowColumn: showcol.includes(ele.label)
+        }
+      })
+    },
+    selTableCol(val) {
+      this.productTableList.showcol = val
+      this.productTableList.tableColumn = this.setColumnVisible(val, this.tableColumn)
     },
     // 浜у搧鍒楄〃杈撳叆
     inputContent(val, prop, row) {
@@ -529,18 +579,22 @@
       }
     },
     // 閫夋嫨鍙戣揣鏂瑰紡
-    handleRadioChange(value) {  
+    handleRadioChange() {
+      let value=this.editConfig.infomation.deliverType
       this.shipmentsList=[]
       this.dissatisfy=false
       this.completely=false
-      if(value===1){
-        this.productTableList.tableColumn=[
-          { label: "浜у搧缂栧彿", prop: "number" },
-          { label: "浜у搧鍚嶇О", prop: "name",   min: 110 },
-          { label: "璁㈠崟鏁伴噺", prop: "orderAmount" },
-          { label: "璁㈠崟瀹屾垚鏁伴噺", prop: "finishAmount" },
-          { label: "鍙敤搴撳瓨", prop: "availableAmount" },
+      if(value==1){
+        this.productTableList.showcol= ['浜у搧缂栧彿','浜у搧鍚嶇О', "璁㈠崟鏁伴噺", "璁㈠崟瀹屾垚鏁伴噺","鍙敤搴撳瓨"]
+        this.productTableList.allcol= ["璁㈠崟鏁伴噺", "璁㈠崟瀹屾垚鏁伴噺","鍙敤搴撳瓨"]
+        this.tableColumn=[
+          { label: "浜у搧缂栧彿", prop: "number",isShowColumn:true,  },
+          { label: "浜у搧鍚嶇О", prop: "name",isShowColumn:true,  min: 110 },
+          { label: "璁㈠崟鏁伴噺", prop: "orderAmount",isShowColumn:true, },
+          { label: "璁㈠崟瀹屾垚鏁伴噺", prop: "finishAmount",isShowColumn:true, },
+          { label: "鍙敤搴撳瓨", prop: "availableAmount",isShowColumn:true, },
         ]
+        this.productTableList.tableColumn=this.setColumnVisible(this.productTableList.showcol, this.tableColumn)
         this.dissatisfy=false
         let portion=0
         // let noUsable=false
@@ -584,17 +638,20 @@
           this.completely=false
           this.completely=true
         }
-      }else if(value===2){
-        this.productTableList.tableColumn= [
-          { label: "浜у搧缂栧彿", prop: "number" },
-          { label: "浜у搧鍚嶇О", prop: "name",  min: 110 },
-          { label: "璁㈠崟鏁伴噺", prop: "orderAmount" },
-          { label: "璁㈠崟瀹屾垚鏁伴噺", prop: "finishAmount" },
-          { label: "鍙敤搴撳瓨", prop: "availableAmount" },
-          { label: "鏈彂璐ф暟閲�", prop: "leftAmount",  },
-          { label: "鏈鍙戣揣鏁伴噺", prop: "outputAmount", inputFloat: true,isRequird:true },
-          { label: "鍓╀綑鍙戣揣鏁伴噺", prop: "availableAmount",},
+      }else if(value==2){
+        this.productTableList.showcol= ['浜у搧缂栧彿','浜у搧鍚嶇О', "璁㈠崟鏁伴噺", "璁㈠崟瀹屾垚鏁伴噺","鍙敤搴撳瓨","鏈彂璐ф暟閲�", "鏈鍙戣揣鏁伴噺","鍓╀綑鍙戣揣鏁伴噺",]
+        this.productTableList.allcol= [ "璁㈠崟鏁伴噺", "璁㈠崟瀹屾垚鏁伴噺","鍙敤搴撳瓨","鏈彂璐ф暟閲�", "鍓╀綑鍙戣揣鏁伴噺",]
+        this.tableColumn= [
+          { label: "浜у搧缂栧彿", prop: "number",isShowColumn:true, },
+          { label: "浜у搧鍚嶇О", prop: "name",  min: 110 ,isShowColumn:true,},
+          { label: "璁㈠崟鏁伴噺", prop: "orderAmount",isShowColumn:true, },
+          { label: "璁㈠崟瀹屾垚鏁伴噺", prop: "finishAmount" ,isShowColumn:true,},
+          { label: "鍙敤搴撳瓨", prop: "availableAmount",isShowColumn:true, },
+          { label: "鏈彂璐ф暟閲�", prop: "leftAmount", isShowColumn:true, },
+          { label: "鏈鍙戣揣鏁伴噺", prop: "outputAmount", inputFloat: true,isRequird:true,isShowColumn:true,},
+          { label: "鍓╀綑鍙戣揣鏁伴噺", prop: "availableAmount",isShowColumn:true,},
         ]
+        this.productTableList.tableColumn=this.setColumnVisible(this.productTableList.showcol, this.tableColumn)
         let portion=0
         this.productTableList.tableData.map((item)=>{
           item.availableAmount=Number(item.availableAmount)
@@ -627,7 +684,7 @@
         this.shipmentsList=[]
         if(res&&res.code===200){
           this.productTableList.tableData=res.data||[]
-          if(this.shipmentsType===1){
+          if(this.editConfig.infomation.deliverType===1){
             let portion=0
             this.productTableList.tableData.map((item)=>{
               item.availableAmount=Number(item.availableAmount)

--
Gitblit v1.8.0