Explorar el Código

fix: 出库选择物品使用可用数量限制最大值

liujt hace 1 semana
padre
commit
41c6125b67
Se han modificado 1 ficheros con 35 adiciones y 16 borrados
  1. 35 16
      src/views/warehouseManagement/components/AssetsDialog.vue

+ 35 - 16
src/views/warehouseManagement/components/AssetsDialog.vue

@@ -310,7 +310,7 @@
           // console.log(row);
           return (
             _this.productLists.some((it) => it.categoryId == row.categoryId) ||
-            _this.dimension == '3' || row.measureQuantity == 0
+            _this.dimension == '3' || row.availableQuantity == 0
           );
         };
       },
@@ -413,7 +413,7 @@
                   return (
                     !_this.productLists.some((item) =>
                       _this.isSameStockRecord(item, row)
-                    ) && row.measureQuantity != 0
+                    ) && row.availableQuantity != 0
                   );
                 }
               }
@@ -428,7 +428,7 @@
                   return (
                     !_this.productLists.some((item) =>
                       _this.isSameStockRecord(item, row)
-                    ) && row.measureQuantity != 0
+                    ) && row.availableQuantity != 0
                   );
                 }
               },
@@ -474,13 +474,13 @@
             label: '可用数量',
             align: 'center',
             showOverflowTooltip: true,
-            formatter: (row) => {
-              // 使用整数运算避免浮点数精度丢失
-              const measure = Number(row.measureQuantity) || 0;
-              const lock = Number(row.lockQuantity) || 0;
-              const result = (measure * 100 - lock * 100) / 100;
-              return Math.round(result * 100) / 100;
-            }
+            // formatter: (row) => {
+            //   // 使用整数运算避免浮点数精度丢失
+            //   const measure = Number(row.measureQuantity) || 0;
+            //   const lock = Number(row.lockQuantity) || 0;
+            //   const result = (measure * 100 - lock * 100) / 100;
+            //   return Math.round(result * 100) / 100;
+            // }
           },
           {
             prop: 'inventoryCycle',
@@ -622,7 +622,7 @@
 
       // 出库数量限制
       handleInput(row, value) {
-        if (row.outboundNum <= row.measureQuantity) {
+        if (row.outboundNum <= row.availableQuantity) {
           // return (row.outboundNum = value.replace(/^(0+)|[^\d]+/g, ''));
 
           // 过滤掉非数字和小数点的字符
@@ -645,7 +645,7 @@
           }
           return
         } else {
-          row.outboundNum = row.measureQuantity;
+          row.outboundNum = row.availableQuantity;
           const currentIndex = this.selectionList.findIndex(item => item.id === row.id)
           if(currentIndex > -1) {
             this.$set(this.selectionList, currentIndex, row);
@@ -679,7 +679,7 @@
           // 批次维度
           const data = await storageApi.getBatchList(this.searchForm);
           for (let i = 0; i < data.list.length; i++) {
-            data.list[i].outboundNum = data.list[i].measureQuantity;
+            data.list[i].outboundNum = data.list[i].availableQuantity;
           }
           this.tableData = data.list;
           this.total = data.count;
@@ -715,7 +715,7 @@
               (product) => product.categoryId === item.categoryId
             );
             let num = matchedProduct.reduce(
-              (pre, cur) => pre + cur.measureQuantity,
+              (pre, cur) => pre + cur.availableQuantity,
               0
             );
             // console.log(matchedProduct);
@@ -738,7 +738,7 @@
             );
 
             if (matchedProduct) {
-              this.$set(item, 'outboundNum', matchedProduct.measureQuantity);
+              this.$set(item, 'outboundNum', matchedProduct.availableQuantity);
             }
             const isSelection = this.selectionList.find(
               (product) => product.id === item.id
@@ -897,6 +897,15 @@
           // console.log(data);
           // let result = this.updateSelect(data);
           // return result;
+
+          data.list.forEach(item => {
+            // 使用整数运算避免浮点数精度丢失
+              const measure = Number(item.measureQuantity) || 0;
+              const lock = Number(item.lockQuantity) || 0;
+              const result = (measure * 100 - lock * 100) / 100;
+              
+              item.availableQuantity = Math.round(result * 100) / 100;
+          });
           this.updateProductOutboundNums(data.list);
           return data;
         }
@@ -910,7 +919,12 @@
             size: limit
           });
           data.list.forEach((item) => {
-            item.outboundNum = item.measureQuantity;
+            const measure = Number(item.measureQuantity) || 0;
+            const lock = Number(item.lockQuantity) || 0;
+            const result = (measure * 100 - lock * 100) / 100;
+            
+            item.availableQuantity = Math.round(result * 100) / 100;
+            item.outboundNum = item.availableQuantity;
           });
           return data;
         }
@@ -924,6 +938,11 @@
             size: limit
           });
           data.list.forEach((item) => {
+            const measure = Number(item.measureQuantity) || 0;
+            const lock = Number(item.lockQuantity) || 0;
+            const result = (measure * 100 - lock * 100) / 100;
+            
+            item.availableQuantity = Math.round(result * 100) / 100;
             item.outboundNum = item.packingQuantity;
           });
           this.updateProductOutboundNums(data.list);