Răsfoiți Sursa

fix(仓库管理): 优化重量计算精度并移除不必要的包装数量限制

yusheng 6 luni în urmă
părinte
comite
f1d87507e5
1 a modificat fișierele cu 12 adăugiri și 22 ștergeri
  1. 12 22
      src/views/warehouseManagement/stockManagement/add.vue

+ 12 - 22
src/views/warehouseManagement/stockManagement/add.vue

@@ -1530,8 +1530,6 @@
         console.log(row, 'row1');
         if (row.singleWeight < 0) {
           this.$set(this.productList[index], 'singleWeight', 1);
-        } else if (row.packingQuantity > 9999) {
-          this.$set(this.productList[index], 'singleWeight', 9999);
         }
         if (row.measureUnit == row.weightUnit) {
           row.weight = row.singleWeight * row.packingQuantity;
@@ -1560,7 +1558,7 @@
         if (row.measureUnit == row.weightUnit) {
           row.measureQuantity = row.weight;
           row.singleWeight =
-            Math.trunc((row.measureQuantity / row.packingQuantity) * 100) / 100;
+            Math.trunc((row.measureQuantity / row.packingQuantity) * 10000) / 10000;
         } else {
           row.singleWeight = row.measureQuantity
             ? row.weight / row.measureQuantity
@@ -1604,9 +1602,7 @@
         if (isClear) {
           if (row.packingQuantity < 0) {
             this.$set(this.productList[index], 'packingQuantity', 1);
-          } else if (row.packingQuantity > 999999) {
-            this.$set(this.productList[index], 'packingQuantity', 999999);
-          }
+          } 
         }
         //如果有包装数量和包装单位
         if (row.packingQuantity && row.packingUnit) {
@@ -1669,8 +1665,8 @@
               row.singleWeight = 0;
             } else {
               row.singleWeight =
-                Math.trunc((row.measureQuantity / row.packingQuantity) * 100) /
-                100;
+                Math.trunc((row.measureQuantity / row.packingQuantity) * 10000) /
+                10000;
             }
           } else if (row.singleWeight) {
             weight = row.measureQuantity * Number(row.singleWeight);
@@ -3275,28 +3271,17 @@
 
             // 处理单位为KG类,计算每桶KG值
             if (packingBoolen) {
-              if (!row.isUnpack && row.packingUnit == '立方') {
-                let result =
-                  row.packingQuantity /
-                  row.packingSpecificationOption[1].packageCell;
-                packingQuantity = Math.ceil(result * 100) / 100;
-                console.log(packingQuantity, '包装数oppppp量');
-                measureQuantity = row.measureQuantity;
-                console.log(measureQuantity, '计量数oppppp量');
-                packingUnit = row.packingUnit;
-              } else {
-                measureQuantity =
+               measureQuantity =
                   Number(row.packingQuantity) >
                   this.$math.format(filterArr[0].packageCell * (index + 1), 14)
                     ? filterArr[0].packageCell
                     : Number(row.packingQuantity) -
                       this.$math.format(filterArr[0].packageCell * index, 14);
-              }
             } else {
               //计量单位等于重量单位并且有总重 计量数量=总重/包装数
               if (row.weightUnit == row.measureUnit && row.weight) {
                 measureQuantity =
-                  Math.trunc((row.weight / packingCodeList.length) * 100) / 100;
+                  Math.trunc((row.weight / packingCodeList.length) * 10000) / 10000;
               } else {
                 measureQuantity = row.packingSpecificationOption[1].packageCell;
               }
@@ -3377,7 +3362,12 @@
 
             let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
               .dictValue;
-            if (outBoolen) {
+               //计量单位等于重量单位
+          if (row.weightUnit == row.measureUnit) {
+            item.weight = item.measureQuantity
+              ? Number(item.measureQuantity)
+              : 0;
+          } else if (outBoolen) {
               // 计量单位为KG类,直接替换
               item.weight = item.measureQuantity
                 ? Number(item.measureQuantity)