Ver Fonte

fix(库存管理): 移除单重精度限制并优化重量计算逻辑

yusheng há 6 meses atrás
pai
commit
5e3cb0faaf
1 ficheiros alterados com 43 adições e 58 exclusões
  1. 43 58
      src/views/bpm/stockManagement/storage.vue

+ 43 - 58
src/views/bpm/stockManagement/storage.vue

@@ -410,7 +410,6 @@
                     v-else
                     v-model="row.singleWeight"
                     placeholder="请输入"
-                    :precision="2"
                     :min="0"
                     controls-position="right"
                     @change="inputsingleWeight(row, $index)"
@@ -1402,7 +1401,7 @@
     methods: {
       ...mapActions('dict', ['requestDict']),
       // 通过挂起状态设置行样式
-      tableRowClassName({row}) {
+      tableRowClassName({ row }) {
         // console.log('tableRowClassName', row)
         if (row.isReversal == 1) {
           return 'warning-row';
@@ -1411,7 +1410,7 @@
       },
       handleRowClick(row) {
         // this.current = row;
-        console.log('handleRowClick', row)
+        console.log('handleRowClick', row);
         if (row.isReversal == 1) {
           this.$alert(`替代批次号:${row.suspendOrReverseDetail[0].batchNo}`, {
             confirmButtonText: '知道了',
@@ -1445,7 +1444,8 @@
         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
@@ -1463,8 +1463,6 @@
         if (isClear) {
           if (row.packingQuantity < 0) {
             this.$set(this.productList[index], 'packingQuantity', 1);
-          } else if (row.packingQuantity > 9999) {
-            this.$set(this.productList[index], 'packingQuantity', 9999);
           }
         }
         //如果有包装数量和包装单位
@@ -1552,8 +1550,9 @@
               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);
@@ -1711,7 +1710,7 @@
                 filtersItem.purchaseCount ||
                 filtersItem.totalCount ||
                 0;
-                console.log(packingQuantity,'packingQudasdasdantity')
+              console.log(packingQuantity, 'packingQudasdasdantity');
               let packingUnit =
                 filtersItem.purchaseUnit || filtersItem.measuringUnit || '';
 
@@ -3749,57 +3748,38 @@
 
           // 处理单位为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 =
-                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);
-              console.log(measureQuantity, 'measureQuantit1111y');
-            }
+            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);
+            console.log(measureQuantity, 'measureQuantit1111y');
           } else {
-            if (row.isUnpack == 1) {
-              console.log('1 拆--------', measureBoolen);
-              if (measureBoolen) {
-                //计量单位等于重量单位并且有总重 计量数量=总重/包装数
-                if (row.weightUnit == row.measureUnit && row.weight) {
-                  measureQuantity =
-                    Math.trunc((row.weight / packingCodeList.length) * 100) /
-                    100;
-                } else {
-                  // 处理单位不为KG类,计量单位为KG类的情况
-                  let splitIndex = row.packingSpecificationOption.findIndex(
-                    (item) =>
-                      item.conversionUnit == row.packingUnit &&
-                      item.packageUnit != item.conversionUnit
-                  );
-                  for (; splitIndex > 0; splitIndex--) {
-                    measureQuantity = this.$math.format(
-                      measureQuantity *
-                        row.packingSpecificationOption[splitIndex].packageCell,
-                      14
-                    );
-                  }
-                }
-              } else {
-                measureQuantity = row.packingSpecificationOption[1].packageCell;
+            console.log('1 拆--------', measureBoolen);
+            //计量单位等于重量单位并且有总重 计量数量=总重/包装数
+
+            if (row.weightUnit == row.measureUnit && row.weight) {
+              measureQuantity =
+                Math.trunc((row.weight / packingCodeList.length) * 10000) /
+                10000;
+            } else if (measureBoolen) {
+              let splitIndex = row.packingSpecificationOption.findIndex(
+                (item) =>
+                  item.conversionUnit == row.packingUnit &&
+                  item.packageUnit != item.conversionUnit
+              );
+              for (; splitIndex > 0; splitIndex--) {
+                measureQuantity = this.$math.format(
+                  measureQuantity *
+                    row.packingSpecificationOption[splitIndex].packageCell,
+                  14
+                );
               }
             } else {
-              console.log('4 拆--------');
-              if (row.packingQuantity) {
-                measureQuantity = row.measureQuantity / row.packingQuantity;
-              }
+              measureQuantity = row.packingSpecificationOption[1].packageCell;
             }
+
             console.log(measureQuantity, 'measureQuantity');
           }
           let clientCode = '';
@@ -3908,7 +3888,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
@@ -4104,7 +4089,7 @@
 </script>
 
 <style lang="scss" scoped>
-::v-deep .el-table .warning-row {
+  ::v-deep .el-table .warning-row {
     background: #d9ecff;
   }
   .inbound_details {