From 03cfba0f636b42417070fc8caef44bcdd792a085 Mon Sep 17 00:00:00 2001
From: haoxuan <haoxuan>
Date: 星期二, 07 五月 2024 17:34:37 +0800
Subject: [PATCH] 概述 出库模块 编辑的时候循环处理对应产品调用接口获取在库数量的逻辑处理

---
 src/views/overview/AddOverviewDialog.vue |  141 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 116 insertions(+), 25 deletions(-)

diff --git a/src/views/overview/AddOverviewDialog.vue b/src/views/overview/AddOverviewDialog.vue
index 462936e..156dbe6 100644
--- a/src/views/overview/AddOverviewDialog.vue
+++ b/src/views/overview/AddOverviewDialog.vue
@@ -473,17 +473,19 @@
                 :addTypeIdMultiple="true"
                 :product-table-list="productTableList"
                 :detail-enter="!showFooter"
+                @selProductClick="selProductClick"
                 @inputContent="inputContent"
                 @addProductClick="addProductClick('鎿嶄綔')"
                 @getSelectArray="getSelectArray"
+                @selSonLocationClick="selSonLocationClick"
                 @emptyProductClick="emptyProductClick"
                 @clearupProduct="clearupProduct"
               >
                 <template v-if="showFooter" slot="tableButton">
+                  <!--  fixed="right" -->
                   <el-table-column
                     label="鎿嶄綔"
                     width="60"
-                    fixed="right"
                     align="center"
                   >
                     <template slot-scope="scope">
@@ -642,6 +644,9 @@
   getLogisticCompanyList,
   printReceipts,
 } from "@/api/overview/overview";
+import {
+  getLocationProductAmount
+} from "@/api/operate/inventoryAdjustment"
 import {
   getSupplierList,
   getCompanyList,
@@ -1044,6 +1049,8 @@
                     productId: item.productId,
                     auxiliaryUnit:item.auxiliaryUnit,
                     auxiliaryAmount:item.auxiliaryAmount,
+                    totalNetWeight:item.totalNetWeight,
+                    totalGrossWeight:item.totalGrossWeight,
                   });
                 });
                 params.details = arr;
@@ -1057,6 +1064,8 @@
                       productId: item.productId,
                       auxiliaryUnit:item.auxiliaryUnit,
                       auxiliaryAmount:item.auxiliaryAmount,
+                      totalNetWeight:item.totalNetWeight,
+                     totalGrossWeight:item.totalGrossWeight,
                     });
                   } else {
                     arr.push({
@@ -1066,6 +1075,8 @@
                       productId: item.productId,
                       auxiliaryUnit:item.auxiliaryUnit,
                       auxiliaryAmount:item.auxiliaryAmount,
+                      totalNetWeight:item.totalNetWeight,
+                     totalGrossWeight:item.totalGrossWeight,
                     });
                   }
                 });
@@ -1085,6 +1096,8 @@
                     productId: item.productId,
                     auxiliaryUnit:item.auxiliaryUnit,
                     auxiliaryAmount:item.auxiliaryAmount,
+                    totalNetWeight:item.totalNetWeight,
+                    totalGrossWeight:item.totalGrossWeight,
                   });
                   // if(item.fromLocationId.value){
                   //   arr.push({
@@ -1196,7 +1209,7 @@
         params = {
           baseOperationType: data.baseOperationType,
           comment: data.comment || "",
-          companyID: companyID,
+          companyID: companyID+'',
           companyName: companyName,
           contacterID: contacterID,
           contacterName: contacterName,
@@ -1230,7 +1243,7 @@
         params = {
           baseOperationType: data.baseOperationType,
           comment: data.comment || "",
-          companyID: companyID,
+          companyID: companyID+'',
           companyName: companyName,
           contacterID: contacterID,
           contacterName: contacterName,
@@ -1293,13 +1306,14 @@
           {
             label: "浜у搧鍚嶇О",
             prop: "productName",
+            min:150,
             productName: true,
             isRequird: true,
           },
           { label: "浜у搧缂栫爜", prop: "productId" },
-          { label: "鏁伴噺", prop: "amount", inputFloat: true },
           { label: "浜у搧瑙勬牸", prop: "specs" },
           { label: "浜у搧鍨嬪彿", prop: "model" },
+          { label: "鏁伴噺", prop: "amount", inputFloat: true },
           { label: "璁¢噺鍗曚綅", prop: "unit" },
           { label: "杈呭姪鏁伴噺", prop: "auxiliaryAmount",inputFloatValue:true,isInputFloat:'inputFloatAuxiliaryAmount' },
           { label: "杈呭姪鍗曚綅", prop: "auxiliaryUnit" },
@@ -1313,19 +1327,22 @@
           {
             label: "浜у搧鍚嶇О",
             prop: "productName",
+            min:150,
             productName: true,
             isRequird: true,
           },
           { label: "浜у搧缂栫爜", prop: "productId" },
-          { label: "鏁伴噺", prop: "amount", inputFloat: true },
           { label: "浜у搧瑙勬牸", prop: "specs" },
           { label: "浜у搧鍨嬪彿", prop: "model" },
           {
             label: "浠�",
             prop: "fromLocationId",
+            min:120,
             sonLocation: true,
             isRequird: true,
           },
+          { label: "鍦ㄥ簱鏁伴噺", prop: "inLibraryAmount" },
+          { label: "鏁伴噺", prop: "amount", inputFloat: true },
           { label: "璁¢噺鍗曚綅", prop: "unit" },
           { label: "杈呭姪鏁伴噺", prop: "auxiliaryAmount",inputFloatValue:true,isInputFloat:'inputFloatAuxiliaryAmount' },
           { label: "杈呭姪鍗曚綅", prop: "auxiliaryUnit" },
@@ -1339,17 +1356,18 @@
           {
             label: "浜у搧鍚嶇О",
             prop: "productName",
+            min:150,
             productName: true,
             isRequird: true,
           },
           { label: "浜у搧缂栫爜", prop: "productId" },
-          { label: "鏁伴噺", prop: "amount", inputFloat: true },
           { label: "浜у搧瑙勬牸", prop: "specs" },
           { label: "浜у搧鍨嬪彿", prop: "model" },
           {
             label: "浠�",
             prop: "fromLocationId",
             sonLocation: true,
+            min:120,
             isRequird: true,
           },
           {
@@ -1358,6 +1376,7 @@
             toLocation: true,
             isRequird: true,
           },
+          { label: "鏁伴噺", prop: "amount", inputFloat: true },
           { label: "璁¢噺鍗曚綅", prop: "unit" },
           { label: "杈呭姪鏁伴噺", prop: "auxiliaryAmount",inputFloatValue:true,isInputFloat:'inputFloatAuxiliaryAmount' },
           { label: "杈呭姪鍗曚綅", prop: "auxiliaryUnit" },
@@ -1371,16 +1390,17 @@
           {
             label: "浜у搧鍚嶇О",
             prop: "productName",
+            min:150,
             productName: true,
             isRequird: true,
           },
           { label: "浜у搧缂栫爜", prop: "productId" },
-          { label: "鏁伴噺", prop: "amount", inputFloat: true },
           { label: "浜у搧瑙勬牸", prop: "specs" },
           { label: "浜у搧鍨嬪彿", prop: "model" },
           {
             label: "浠�",
             prop: "fromLocationId",
+            min:120,
             sonLocation: true,
             isRequird: true,
           },
@@ -1390,6 +1410,7 @@
             toLocation: true,
             isRequird: true,
           },
+          { label: "鏁伴噺", prop: "amount", inputFloat: true },
           { label: "璁¢噺鍗曚綅", prop: "unit" },
         ];
       } else if (this.workType == 5) {
@@ -1397,16 +1418,17 @@
           {
             label: "浜у搧鍚嶇О",
             prop: "productName",
+            min:150,
             productName: true,
             isRequird: true,
           },
           { label: "浜у搧缂栫爜", prop: "productId" },
-          { label: "鏁伴噺", prop: "amount", inputFloat: true },
           { label: "浜у搧瑙勬牸", prop: "specs" },
           { label: "浜у搧鍨嬪彿", prop: "model" },
           {
             label: "浠�",
             prop: "fromLocationId",
+            min:120,
             sonLocation: true,
             isRequird: true,
           },
@@ -1416,13 +1438,21 @@
             toLocation: true,
             isRequird: true,
           },
+          { label: "鏁伴噺", prop: "amount", inputFloat: true },
           { label: "璁¢噺鍗曚綅", prop: "unit" },
         ];
+      }
+      console.log(this.tableData,'===tableData')
+      if(this.workType == 2){
+        for(let i in this.tableData){
+          this.selSonLocationClick(this.tableData[i].fromLocation.id,'fromLocationId',this.tableData[i],i,3)
+        }
       }
       this.productTableList = {
         tableData: this.tableData,
         tableColumn: tableColumnArr,
       };
+      
     },
     getTwoTable(data,value){
         let list = data.map((res) => {
@@ -1468,31 +1498,68 @@
             unit: res.product.unit,
             model:res.product.model,
             specs:res.product.specs,
+            moreUnit:res.product.moreUnit,
+            moreUnitList:res.product.moreUnitList,
             auxiliaryUnit:res.auxiliaryUnit,
+            // auxiliaryAmount:res.amount&&adjunctAmount?Number(adjunctAmount)*Number(res.amount):0,
             auxiliaryAmount:res.auxiliaryAmount,
+            auxiliaryAmountInfo:adjunctAmount?Number(adjunctAmount):0,
             inputFloatAuxiliaryAmount:isValue,
-            grossWeight:res.product.grossWeight,
-            totalGrossWeight:res.totalGrossWeight,
-            netWeight:res.product.netWeight, 
-            totalNetWeight:res.totalNetWeight,  
+            grossWeight:res.product.grossWeight==0?null:res.product.grossWeight,
+            totalGrossWeight:res.totalGrossWeight==0?null:Number(res.totalGrossWeight),
+            netWeight:res.product.netWeight==0?null:res.product.netWeight, 
+            totalNetWeight:res.totalNetWeight==0?null:Number(res.totalNetWeight),  
           };
         }else{
           return {
             ...res,
             amount: 1,
-            productName: res.name,
-            productId: res.id,
+            productName: res.productId?res.productName:res.name,
+            productId:  res.productId?res.productId:res.id,
             auxiliaryUnit:adjunctUnit,
-            auxiliaryAmount:Number(adjunctAmount),
+            auxiliaryAmount:adjunctAmount?(1/Number(adjunctAmount)).toFixed(2):0,
+            auxiliaryAmountInfo:adjunctAmount?Number(adjunctAmount):0,
             inputFloatAuxiliaryAmount:isValue,
-            grossWeight:res.grossWeight,
-            totalGrossWeight:res.grossWeight?Number(res.grossWeight)*1:'',
-            netWeight:res.netWeight, 
-            totalNetWeight:res.netWeight?Number(res.netWeight)*1:'', 
+            grossWeight:res.grossWeight==0?null:res.grossWeight,
+            totalGrossWeight:res.grossWeight==0?null:Number(res.grossWeight)*1,
+            netWeight:res.netWeight==0?null:res.netWeight, 
+            totalNetWeight:res.netWeight==0?null:Number(res.netWeight)*1, 
           };
         }
       });
         return list||[];
+    },
+    getAuxiligyAmount(unit,unitList){
+      let adjunctUnit=''
+        let adjunctAmount=''
+        let isValue=false
+        let moreUnit=unit?unit:''
+        let moreUnitList=unitList?unitList:[]
+        if(moreUnit&&moreUnitList){
+          if(moreUnitList.length>0){
+            for(let j in moreUnitList){
+              if(moreUnitList[j].floating){
+                isValue=true;
+                adjunctUnit=moreUnitList[j].unit
+                adjunctAmount=moreUnitList[j].amount
+                break;
+              }
+            }
+            if(!isValue){
+              for(let j in moreUnitList){
+                 if(moreUnitList[j].unit){
+                  adjunctUnit=moreUnitList[j].unit
+                  adjunctAmount=moreUnitList[j].amount
+                  break;
+                }
+              }
+            }
+          }
+        }
+        return {
+          auxiliaryAmount:adjunctAmount,
+          auxiliaryUnit:adjunctUnit,
+        }
     },
     // 鎿嶄綔杈撳叆
     inputContent(val, prop, row) {
@@ -1500,12 +1567,33 @@
       this.tableData.map((item) => {
         if (item.id == row.id) {
           item[prop] = val;
+          let auxiliaryAmountObject=this.getAuxiligyAmount(item.moreUnit,item.moreUnitList)
           if(prop=='amount'){
-            item.totalGrossWeight=item[prop]&&item.grossWeight?Number(item.grossWeight)*Number(item[prop]):''
-            item.totalNetWeight=item[prop]&&item.netWeight?Number(item.netWeight)*Number(item[prop]):''
+            item.totalGrossWeight=item[prop]&&item.grossWeight?Number(item.grossWeight)*Number(item[prop]):null
+            item.totalNetWeight=item[prop]&&item.netWeight?Number(item.netWeight)*Number(item[prop]):null
+            item.auxiliaryAmount=item[prop]&&auxiliaryAmountObject.auxiliaryAmount?(Number(item[prop])/Number(auxiliaryAmountObject.auxiliaryAmount)).toFixed(2):null
           }
         }
       });
+    },
+    selSonLocationClick(val, prop, row,scope,type){
+      if(this.workType == 2){
+        if(prop=='fromLocationId'){
+         getLocationProductAmount({
+            locationId:type==3?val:val.value,
+            productId:row.productId
+          }).then((res)=>{
+            if(res.code==200){
+              if(type==3){
+                this.$set(this.tableData[scope],'inLibraryAmount',res.data?res.data.amount:0)
+              }else{
+                this.$set(this.tableData[scope.$index],'inLibraryAmount',res.data?res.data.amount:0)
+              }
+              this.$forceUpdate()
+            }
+          })
+        }
+      }
     },
     // 鏂板
     addProductClick(value) {
@@ -1555,9 +1643,12 @@
       //   }
       // }
     },
+    selProductClick(value, prop,row,scope){
+      this.getSelectArray([value],scope.$index)
+    },
     // 鏂板鏂瑰紡淇敼
     getSelectArray(val, index) {
-      if (this.tableData.length == 1 && this.tableData[0].number.length == 0) {
+      if (this.tableData.length == 1 && this.tableData[0].number&&this.tableData[0].number.length == 0) {
         this.tableData = [];
       }
       if (index < this.tableData.length) {
@@ -1605,7 +1696,7 @@
       if (this.workType == "鍐呴儴璋冩嫧"||this.workType==3) {
         this.tableColumn = [
           { label: "浜у搧", prop: "name", productName: true, isRequird: true },
-          { label: "浠�", prop: "number", select: true },
+          { label: "浠�", prop: "number", select: true,min:120,},
           { label: "鑷�", prop: "amount", select: true },
           { label: "瀹屾垚", prop: "total", inputFloat: true },
           { label: "璁¢噺鍗曚綅", prop: "total", select: true },
@@ -1613,7 +1704,7 @@
       } else {
         this.tableColumn = [
           { label: "浜у搧", prop: "name", productName: true, isRequird: true },
-          { label: "浠�", prop: "number", select: true },
+          { label: "浠�", prop: "number", select: true , min:120,},
           { label: "瀹屾垚", prop: "total", inputFloat: true },
           { label: "璁¢噺鍗曚綅", prop: "total", select: true },
         ];
@@ -1693,7 +1784,7 @@
               baseOperationType:
                 this.editConfig.infomation.baseOperationType || undefined,
               // 1鏄槈鑱�
-              cutAfterWidth:name=='jialian'?52.6:
+              cutAfterWidth:name=='jialian'?53.9:
                (this.editConfig.infomation.baseOperationType == 2
                   ? 50.8
                   : 53.3),

--
Gitblit v1.8.0