695593266@qq.com преди 6 месеца
родител
ревизия
023f065f9e

+ 1 - 1
manifest.json

@@ -2,7 +2,7 @@
     "name" : "智慧工厂",
     "appid" : "__UNI__45B3907",
     "description" : "",
-    "versionName" : "V1.0.3.25",
+    "versionName" : "V1.0.3.26",
     "versionCode" : "100",
     "transformPx" : false,
     "h5" : {

+ 1 - 1
pages/pda/feeding/components/workInProgressList.vue

@@ -110,7 +110,7 @@
                   class="u-reset-button"
                   type="primary"
                   @click="batchClick(it, idx)"
-                  v-if="it.extInfo.sourceQuantity > 1"
+                  v-if="it.feedQuantity > 1 && it.isAllPackageData != 1"
                   >拆批</u-button
                 >
                 <u-button

+ 119 - 38
pages/pda/jobBooking/components/batchJobBom.vue

@@ -335,50 +335,99 @@ export default {
       deep: true,
       handler(newVal) {
         console.log(newVal, "newVal");
-        if (newVal.product && newVal.product.length != 0) {
-          let formedNum = 0;
-          let notFormedNum = 0;
-          let lossNum = 0;
-
-          newVal.product.forEach((item) => {
-            if (
-              (!item.extInfo.isQualified ||
-                item.extInfo.isQualified == 1 ||
-                item.extInfo.isQualified == 3) &&
-              !item.extInfo.isLoss
-            ) {
-              formedNum = formedNum + Number(item.feedQuantity);
-              // formedNum = this.add(formedNum, Number(item.feedQuantity));
-            } else if (!item.extInfo.isLoss) {
-              if (item.extInfo.notType == 5 || item.extInfo.notType == 8) {
-                formedNum = formedNum + Number(item.feedQuantity);
-
-                // formedNum = this.add(formedNum, Number(item.feedQuantity));
+
+        if (newVal.product && newVal.product.length !== 0) {
+          const product = newVal.product;
+
+          const finalList = product.some((it) => it.confirm == 1)
+            ? product.filter((it) => it.confirm == 1)
+            : product;
+
+          const isLoss = (item) => item.extInfo.isLoss == 1;
+
+          const isFormed = (item) => {
+            const { isQualified, notType } = item.extInfo;
+            return (
+              !isQualified ||
+              isQualified == 1 ||
+              isQualified == 3 ||
+              notType == 5 ||
+              notType == 8
+            );
+          };
+
+          const getQty = (item) => Number(item.feedQuantity);
+
+          const result = finalList.reduce(
+            (acc, item) => {
+              const qty = getQty(item);
+
+              if (isLoss(item)) {
+                acc.lossNum = this.add(acc.lossNum, qty);
+              } else if (isFormed(item)) {
+                acc.formedNum = this.add(acc.formedNum, qty);
               } else {
-                notFormedNum = notFormedNum + Number(item.feedQuantity);
-                // if (!item.extInfo.isLoss) {
-                // notFormedNum = this.add(
-                //   notFormedNum,
-                //   Number(item.feedQuantity)
-                // );
-                // }
+                acc.notFormedNum = this.add(acc.notFormedNum, qty);
               }
-            } else if (item.extInfo.isLoss == 1) {
-              // lossNum = this.add(lossNum, Number(item.feedQuantity));
-              lossNum = lossNum + Number(item.feedQuantity);
-            }
-          });
 
-          console.log(formedNum, "formedNumformedNumformedNum");
-
-          this.$set(this.item.workReportInfo, "formedNum", formedNum);
-          this.$set(this.item.workReportInfo, "notFormedNum", notFormedNum);
-          this.$set(this.item.workReportInfo, "lossQuantity", lossNum);
+              return acc;
+            },
+            { formedNum: 0, notFormedNum: 0, lossNum: 0 }
+          );
 
-          // console.log(this.item.workReportInfo);
-          this.item.workReportInfo = this.deepCopy(this.item.workReportInfo);
+          this.$set(this.item.workReportInfo, "formedNum", result.formedNum);
+          this.$set(
+            this.item.workReportInfo,
+            "notFormedNum",
+            result.notFormedNum
+          );
+          this.$set(this.item.workReportInfo, "lossQuantity", result.lossNum);
           this.$forceUpdate();
         }
+        // if (newVal.product && newVal.product.length != 0) {
+        //   let formedNum = 0;
+        //   let notFormedNum = 0;
+        //   let lossNum = 0;
+
+        //   newVal.product.forEach((item) => {
+        //     if (
+        //       (!item.extInfo.isQualified ||
+        //         item.extInfo.isQualified == 1 ||
+        //         item.extInfo.isQualified == 3) &&
+        //       !item.extInfo.isLoss
+        //     ) {
+        //       formedNum = formedNum + Number(item.feedQuantity);
+        //       // formedNum = this.add(formedNum, Number(item.feedQuantity));
+        //     } else if (!item.extInfo.isLoss) {
+        //       if (item.extInfo.notType == 5 || item.extInfo.notType == 8) {
+        //         formedNum = formedNum + Number(item.feedQuantity);
+
+        //         // formedNum = this.add(formedNum, Number(item.feedQuantity));
+        //       } else {
+        //         notFormedNum = notFormedNum + Number(item.feedQuantity);
+        //         // if (!item.extInfo.isLoss) {
+        //         // notFormedNum = this.add(
+        //         //   notFormedNum,
+        //         //   Number(item.feedQuantity)
+        //         // );
+        //         // }
+        //       }
+        //     } else if (item.extInfo.isLoss == 1) {
+        //       // lossNum = this.add(lossNum, Number(item.feedQuantity));
+        //       lossNum = lossNum + Number(item.feedQuantity);
+        //     }
+        //   });
+
+        //   console.log(formedNum, "formedNumformedNumformedNum");
+
+        //   this.$set(this.item.workReportInfo, "formedNum", formedNum);
+        //   this.$set(this.item.workReportInfo, "notFormedNum", notFormedNum);
+        //   this.$set(this.item.workReportInfo, "lossQuantity", lossNum);
+
+        //   // console.log(this.item.workReportInfo);
+        //   this.item.workReportInfo = this.deepCopy(this.item.workReportInfo);
+        //   this.$forceUpdate();
+        // }
 
         // if (
         //   this.clientEnvironmentId == 3 &&
@@ -630,6 +679,38 @@ export default {
       return (num.toString().split(".")[1] || "").length;
     },
 
+    toInteger(num) {
+      const len = this.getDecimalLength(num);
+      return {
+        int: Math.round(num * Math.pow(10, len)),
+        factor: Math.pow(10, len),
+      };
+    },
+
+    add(a, b) {
+      const { int: aInt, factor: aFactor } = this.toInteger(a);
+      const { int: bInt, factor: bFactor } = this.toInteger(b);
+      const maxFactor = Math.max(aFactor, bFactor);
+      return (
+        (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
+        maxFactor
+      );
+    },
+
+    sub(a, b) {
+      const { int: aInt, factor: aFactor } = this.toInteger(a);
+      const { int: bInt, factor: bFactor } = this.toInteger(b);
+      const maxFactor = Math.max(aFactor, bFactor);
+      return (
+        (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
+        maxFactor
+      );
+    },
+
+    getDecimalLength(num) {
+      return (num.toString().split(".")[1] || "").length;
+    },
+
     singleBatchTg() {
       if (!this.item.workReportInfo.formedNum)
         return uni.showToast({

+ 44 - 4
pages/pda/jobBooking/components/batchProductJobBom.vue

@@ -345,7 +345,12 @@
                   class="u-reset-button"
                   type="primary"
                   @click="batchClick(it, idx)"
-                  v-if="it.extInfo.sourceQuantity > 1"
+                  v-if="
+                    it.feedQuantity > 1 &&
+                    item.currentTaskDiagram.isFirstTask != 1 &&
+                    it.isAllPackageData != 1 &&
+                    !it.extInfo.isLoss
+                  "
                   >拆批</u-button
                 >
                 <u-button
@@ -1188,9 +1193,13 @@ export default {
     },
 
     refreshData(list, feedQuantity) {
-      const number =
-        Number(this.list[this.bacthIndex].extInfo.sourceQuantity) -
-        Number(feedQuantity);
+      const number = this.sub(
+        Number(this.list[this.bacthIndex].feedQuantity),
+        Number(feedQuantity)
+      );
+      // const number =
+      //   Number(this.list[this.bacthIndex].extInfo.sourceQuantity) -
+      //   Number(feedQuantity);
       this.list[this.bacthIndex].extInfo.sourceQuantity = number;
       this.list[this.bacthIndex].feedQuantity = number;
       this.list[this.bacthIndex].extInfo.newWeight =
@@ -1207,6 +1216,37 @@ export default {
       this.$forceUpdate();
       this.$refs.inputDialog.close();
     },
+    toInteger(num) {
+      const len = this.getDecimalLength(num);
+      return {
+        int: Math.round(num * Math.pow(10, len)),
+        factor: Math.pow(10, len),
+      };
+    },
+
+    add(a, b) {
+      const { int: aInt, factor: aFactor } = this.toInteger(a);
+      const { int: bInt, factor: bFactor } = this.toInteger(b);
+      const maxFactor = Math.max(aFactor, bFactor);
+      return (
+        (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
+        maxFactor
+      );
+    },
+
+    sub(a, b) {
+      const { int: aInt, factor: aFactor } = this.toInteger(a);
+      const { int: bInt, factor: bFactor } = this.toInteger(b);
+      const maxFactor = Math.max(aFactor, bFactor);
+      return (
+        (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
+        maxFactor
+      );
+    },
+
+    getDecimalLength(num) {
+      return (num.toString().split(".")[1] || "").length;
+    },
 
     openLoss(item, index) {
       this.lossForm.quantity = "";

+ 98 - 18
pages/pda/jobBooking/components/singleJobBom.vue

@@ -245,26 +245,74 @@ export default {
       immediate: true,
       deep: true,
       handler(newVal) {
-        console.log(newVal, "newVal--------------");
-        if (newVal.semiProductList && newVal.semiProductList.length != 0) {
-          let formedNum = 0;
-          let notFormedNum = 0;
-
-          newVal.semiProductList.forEach((item) => {
-            if (!item.extInfo.isQualified || item.extInfo.isQualified == 1) {
-              formedNum = formedNum + Number(item.feedQuantity);
-            } else {
-              notFormedNum = notFormedNum + Number(item.feedQuantity);
-            }
-          });
+        if (newVal.semiProductList && newVal.semiProductList.length !== 0) {
+          const list = newVal.semiProductList;
+
+          const finalList = list.some((it) => it.confirm == 1)
+            ? list.filter((it) => it.confirm == 1)
+            : list;
+
+          const isFormed = (item) => {
+            const { isQualified, notType } = item.extInfo;
+            return (
+              !isQualified ||
+              isQualified == 1 ||
+              isQualified == 3 ||
+              notType == 5 ||
+              notType == 8
+            );
+          };
 
-          this.$set(this.item.workReportInfo, "formedNum", formedNum);
-          this.$set(this.item.workReportInfo, "notFormedNum", notFormedNum);
-        }
-        this.$forceUpdate();
-        if (!newVal.currentTaskDiagram.isFirstTask) {
-          this.getSemiProductList(newVal);
+          const getQty = (item) => Number(item.feedQuantity);
+
+          const result = finalList.reduce(
+            (acc, item) => {
+              const qty = getQty(item);
+
+              if (isFormed(item)) {
+                acc.formedNum = this.add(acc.formedNum, qty);
+              } else {
+                acc.notFormedNum = this.add(acc.notFormedNum, qty);
+              }
+
+              return acc;
+            },
+            { formedNum: 0, notFormedNum: 0 }
+          );
+
+          this.$set(this.item.workReportInfo, "formedNum", result.formedNum);
+          this.$set(
+            this.item.workReportInfo,
+            "notFormedNum",
+            result.notFormedNum
+          );
+
+          this.$forceUpdate();
         }
+
+        // this.$forceUpdate();
+        // if (!newVal.currentTaskDiagram.isFirstTask) {
+        //   this.getSemiProductList(newVal);
+        // }
+        // if (newVal.semiProductList && newVal.semiProductList.length != 0) {
+        //   let formedNum = 0;
+        //   let notFormedNum = 0;
+
+        //   newVal.semiProductList.forEach((item) => {
+        //     if (!item.extInfo.isQualified || item.extInfo.isQualified == 1) {
+        //       formedNum = formedNum + Number(item.feedQuantity);
+        //     } else {
+        //       notFormedNum = notFormedNum + Number(item.feedQuantity);
+        //     }
+        //   });
+
+        //   this.$set(this.item.workReportInfo, "formedNum", formedNum);
+        //   this.$set(this.item.workReportInfo, "notFormedNum", notFormedNum);
+        // }
+        // this.$forceUpdate();
+        // if (!newVal.currentTaskDiagram.isFirstTask) {
+        //   this.getSemiProductList(newVal);
+        // }
       },
     },
   },
@@ -417,6 +465,38 @@ export default {
       });
     },
 
+    toInteger(num) {
+      const len = this.getDecimalLength(num);
+      return {
+        int: Math.round(num * Math.pow(10, len)),
+        factor: Math.pow(10, len),
+      };
+    },
+
+    add(a, b) {
+      const { int: aInt, factor: aFactor } = this.toInteger(a);
+      const { int: bInt, factor: bFactor } = this.toInteger(b);
+      const maxFactor = Math.max(aFactor, bFactor);
+      return (
+        (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
+        maxFactor
+      );
+    },
+
+    sub(a, b) {
+      const { int: aInt, factor: aFactor } = this.toInteger(a);
+      const { int: bInt, factor: bFactor } = this.toInteger(b);
+      const maxFactor = Math.max(aFactor, bFactor);
+      return (
+        (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
+        maxFactor
+      );
+    },
+
+    getDecimalLength(num) {
+      return (num.toString().split(".")[1] || "").length;
+    },
+
     singleQueryTg() {
       console.log(this.item.workReportInfo);