Browse Source

fix: 物品清单选择问题

liujt 1 tuần trước cách đây
mục cha
commit
625e4bee4b
1 tập tin đã thay đổi với 29 bổ sung4 xóa
  1. 29 4
      src/views/warehouseManagement/components/AssetsDialog.vue

+ 29 - 4
src/views/warehouseManagement/components/AssetsDialog.vue

@@ -673,12 +673,24 @@
             ...this.searchForm,
             isEnabled: 1
           });
-          this.tableData = data.list;
+          this.tableData = data.list.map(item => {
+            const measure = Number(item.measureQuantity) || 0;
+            const lock = Number(item.lockQuantity) || 0;
+            const result = (measure * 100 - lock * 100) / 100;
+            return {
+              ...item,
+              availableQuantity: Math.round(result * 100) / 100
+            }
+          });
           this.total = data.count;
         } else if (this.dimension == 2) {
           // 批次维度
           const data = await storageApi.getBatchList(this.searchForm);
           for (let i = 0; i < data.list.length; i++) {
+            const measure = Number(item.measureQuantity) || 0;
+            const lock = Number(item.lockQuantity) || 0;
+            const result = (measure * 100 - lock * 100) / 100;
+            data.list[i].availableQuantity = Math.round(result * 100) / 100;
             data.list[i].outboundNum = data.list[i].availableQuantity;
           }
           this.tableData = data.list;
@@ -688,12 +700,24 @@
           const data = await storageApi.getMaterialList({
             ...this.searchForm
           });
-          this.tableData = data.list;
+          this.tableData = data.list.map(item => {
+            const measure = Number(item.measureQuantity) || 0;
+            const lock = Number(item.lockQuantity) || 0;
+            const result = (measure * 100 - lock * 100) / 100;
+            return {
+              ...item,
+              availableQuantity: Math.round(result * 100) / 100
+            }
+          });
           this.total = data.count;
         } else {
           // 包装维度
           const data = await storageApi.getPackingList(this.searchForm);
           for (let i = 0; i < data.list.length; i++) {
+            const measure = Number(item.measureQuantity) || 0;
+            const lock = Number(item.lockQuantity) || 0;
+            const result = (measure * 100 - lock * 100) / 100;
+            data.list[i].availableQuantity = Math.round(result * 100) / 100;
             data.list[i].outboundNum = data.list[i].packingQuantity;
           }
           this.tableData = data.list;
@@ -715,7 +739,7 @@
               (product) => product.categoryId === item.categoryId
             );
             let num = matchedProduct.reduce(
-              (pre, cur) => pre + cur.availableQuantity,
+              (pre, cur) => pre + cur.measureQuantity,
               0
             );
             // console.log(matchedProduct);
@@ -738,7 +762,7 @@
             );
 
             if (matchedProduct) {
-              this.$set(item, 'outboundNum', matchedProduct.availableQuantity);
+              this.$set(item, 'outboundNum', matchedProduct.measureQuantity);
             }
             const isSelection = this.selectionList.find(
               (product) => product.id === item.id
@@ -906,6 +930,7 @@
               
               item.availableQuantity = Math.round(result * 100) / 100;
           });
+          console.log('dimension == 1~~~', data.list);
           this.updateProductOutboundNums(data.list);
           return data;
         }