Jelajahi Sumber

物料信息bug修复

lucw 7 bulan lalu
induk
melakukan
7920997347

+ 37 - 31
src/views/batchRecord/components/editModal.vue

@@ -1619,37 +1619,41 @@
         });
 
         console.log('materialObject 物料信息', materialObject);
-        if (type == '') {
-          this.form.outputDetails = materialObject.outputDetails;
-          this.form.pickDetails = materialObject.pickDetails.map((i) => {
-            // 物料清单中如果存在则 selected 设置为 true
-            const any = this.form.outputDetails.find(
-              (j) => j.categoryId === i.categoryId
-            );
-            if (any) {
-              i.selected = true;
-            } else {
-              i.selected = false;
-            }
-            return i;
-          });
-          this.preOutputDetails = materialObject.preOutputDetails;
-        }
+        this.form.outputDetails = materialObject.outputDetails;
+        const pickDetails = materialObject.pickDetails.map((i) => {
+          // 物料清单中如果存在则 selected 设置为 true
+          const any = this.form.outputDetails.find(
+            (j) => j.categoryId === i.categoryId
+          );
+          if (any) {
+            i.selected = true;
+          } else {
+            i.selected = false;
+          }
+          return i;
+        });
 
-        if (type == 'output') {
-          this.form.outputDetails = materialObject.outputDetails;
-          this.form.pickDetails = this.form.pickDetails.map((i) => {
-            // 物料清单中如果存在则 selected 设置为 true
-            const any = this.form.outputDetails.find(
-              (j) => j.categoryId === i.categoryId
-            );
-            if (any) {
-              i.selected = true;
-            } else {
-              i.selected = false;
-            }
-            return i;
-          });
+        const preOutputDetails = materialObject.preOutputDetails.map((i) => {
+          i.quantity = i.qualifiedQuantity;
+          return i;
+        });
+        this.preOutputDetails = preOutputDetails.filter(
+          (i) => i.outputType != 1
+        );
+
+        this.form.pickDetails = [
+          ...preOutputDetails.filter((i) => i.outputType == 1),
+          ...pickDetails
+        ];
+
+        //  this.preOutputDetails 是否存在outputType=2的数据
+        const hasInProcess = this.preOutputDetails.some(
+          (i) => i.outputType == 2
+        );
+        if (hasInProcess) {
+          // 产出物为在制品
+          this.form.outputType = 2;
+          // 不可选择
         }
       },
       // qualifiedQuantityMax 最大合格数量
@@ -1820,7 +1824,9 @@
 
         this.$nextTick(() => {
           // 工单变化构建物料和工序数据
-          this.$refs.statisticsRef.rebuildMaterialAndProcessData();
+          if (this.$refs.statisticsRef) {
+            this.$refs.statisticsRef.rebuildMaterialAndProcessData();
+          }
         });
       }
     }

+ 2 - 2
src/views/produce/components/prenatalExamination/material.vue

@@ -611,7 +611,7 @@
             (pick) => pick.categoryId == row.categoryId
           );
           if (pickitem) {
-            return  pickitem.qualifiedQuantity;
+            return pickitem.qualifiedQuantity;
           }
         }
         return Infinity;
@@ -776,7 +776,7 @@
       },
       localOutputDetailsRefresh() {
         if (this.outputType == 1) {
-          $emit('refresh', 'output');
+          this.$emit('refresh', 'output');
         } else if (this.outputType == 2) {
           this.getCategoryAndLevelByCategoryId();
         } else {

+ 32 - 41
src/views/produce/components/prenatalExamination/releaseRulesDialog.vue

@@ -866,50 +866,41 @@
 
         console.log('materialList 物料信息', materialObject);
 
-        if (type == '') {
-          this.addForm.outputDetails = materialObject.outputDetails;
-          this.addForm.pickDetails = materialObject.pickDetails.map((i) => {
-            // 物料清单中如果存在则 selected 设置为 true
-            const any = this.addForm.outputDetails.find(
-              (j) => j.categoryId === i.categoryId
-            );
-            if (any) {
-              i.selected = true;
-            } else {
-              i.selected = false;
-            }
-            return i;
-          });
-          this.preOutputDetails = materialObject.preOutputDetails.map((i) => {
-            i.quantity = i.qualifiedQuantity;
-            return i;
-          });
-
-          //  this.preOutputDetails 是否存在outputType=2的数据
-          const hasInProcess = this.preOutputDetails.some(
-            (i) => i.outputType == 2
+        this.addForm.outputDetails = materialObject.outputDetails;
+        const pickDetails = materialObject.pickDetails.map((i) => {
+          // 物料清单中如果存在则 selected 设置为 true
+          const any = this.addForm.outputDetails.find(
+            (j) => j.categoryId === i.categoryId
           );
-          if (hasInProcess) {
-            // 产出物为在制品
-            this.addForm.outputType = 2;
-            // 不可选择
+          if (any) {
+            i.selected = true;
+          } else {
+            i.selected = false;
           }
-        }
+          return i;
+        });
 
-        if (type == 'output') {
-          this.addForm.outputDetails = materialObject.outputDetails;
-          this.addForm.pickDetails = this.addForm.pickDetails.map((i) => {
-            // 物料清单中如果存在则 selected 设置为 true
-            const any = this.addForm.outputDetails.find(
-              (j) => j.categoryId === i.categoryId
-            );
-            if (any) {
-              i.selected = true;
-            } else {
-              i.selected = false;
-            }
-            return i;
-          });
+        const preOutputDetails = materialObject.preOutputDetails.map((i) => {
+          i.quantity = i.qualifiedQuantity;
+          return i;
+        });
+        this.preOutputDetails = preOutputDetails.filter(
+          (i) => i.outputType != 1
+        );
+
+        this.addForm.pickDetails = [
+          ...preOutputDetails.filter((i) => i.outputType == 1),
+          ...pickDetails
+        ];
+
+        //  this.preOutputDetails 是否存在outputType=2的数据
+        const hasInProcess = this.preOutputDetails.some(
+          (i) => i.outputType == 2
+        );
+        if (hasInProcess) {
+          // 产出物为在制品
+          this.addForm.outputType = 2;
+          // 不可选择
         }
       },
       // 规则信息