lucw пре 7 месеци
родитељ
комит
e8fd627ca5

+ 55 - 4
src/views/batchRecord/components/editModal.vue

@@ -1504,6 +1504,12 @@
           }
         }
 
+        //
+        if (this.reportWorkType == 4) {
+          // 延迟 500ms 等待公式计算
+          await new Promise((resolve) => setTimeout(resolve, 700));
+        }
+
         if (
           this.$refs.statisticsRef &&
           type != 'cache' &&
@@ -1647,13 +1653,17 @@
           i.reportQuantityCopy = i.reportQuantity;
 
           const sumItem = materialObject.sumOutputDetails.find(
-            (i) => i.categoryId === i.categoryId
+            (i) => i.categoryCode === i.categoryCode
           );
 
           if (sumItem) {
-            i.reportQuantity = sumItem.reportQuantity;
+            i.sumQualifiedQuantity = sumItem.sumQualifiedQuantity;
+            i.sumNoQualifiedQuantity = sumItem.sumNoQualifiedQuantity;
+            i.sumReportQuantity = sumItem.sumReportQuantity;
           } else {
-            i.reportQuantity = i.reportQuantity || 0;
+            i.sumQualifiedQuantity = 0;
+            i.sumNoQualifiedQuantity = 0;
+            i.sumReportQuantity = 0;
           }
 
           return i;
@@ -1661,20 +1671,61 @@
         const pickDetails = materialObject.pickDetails.map((i) => {
           // 物料清单中如果存在则 selected 设置为 true
           const any = this.form.outputDetails.find(
-            (j) => j.categoryId === i.categoryId
+            (j) => j.categoryCode === i.categoryCode
           );
           if (any) {
             i.selected = true;
           } else {
             i.selected = false;
           }
+
+          const sumItem = materialObject.sumOutputDetails.find(
+            (item) => i.categoryCode === item.categoryCode
+          );
+
+          if (sumItem) {
+            i.sumQualifiedQuantity = sumItem.sumQualifiedQuantity;
+            i.sumNoQualifiedQuantity = sumItem.sumNoQualifiedQuantity;
+            i.sumReportQuantity = sumItem.sumReportQuantity;
+          } else {
+            i.sumQualifiedQuantity = 0;
+            i.sumNoQualifiedQuantity = 0;
+            i.sumReportQuantity = 0;
+          }
+
           return i;
         });
 
         const preOutputDetails = materialObject.preOutputDetails.map((i) => {
           i.quantity = i.qualifiedQuantity;
+
+          // 物料清单中如果存在则 selected 设置为 true
+          const any = this.addForm.outputDetails.find(
+            (j) => j.categoryCode === i.categoryCode
+          );
+          if (any) {
+            i.selected = true;
+          } else {
+            i.selected = false;
+          }
+
+          const sumItem = materialObject.sumOutputDetails.find(
+            (item) => i.categoryCode === item.categoryCode
+          );
+
+          if (sumItem) {
+            i.sumQualifiedQuantity = sumItem.sumQualifiedQuantity;
+            i.sumNoQualifiedQuantity = sumItem.sumNoQualifiedQuantity;
+            i.sumReportQuantity = sumItem.sumReportQuantity;
+          } else {
+            i.sumQualifiedQuantity = 0;
+            i.sumNoQualifiedQuantity = 0;
+            i.sumReportQuantity = 0;
+          }
+
           return i;
         });
+
         this.preOutputDetails = preOutputDetails.filter(
           (i) => i.outputType != 1
         );

+ 4 - 3
src/views/batchRecord/components/statistics.vue

@@ -45,7 +45,7 @@
                 "
                 :disabled="Boolean(row[index].formula)"
                 :controls="false"
-                @input="handleDataChange(row)"
+                @change="handleDataChange(row)"
               ></el-input-number>
               <div style="width: 80px; height: 100%; flex-shrink: 0">
                 <DictSelection
@@ -155,7 +155,7 @@
                 "
                 :disabled="Boolean(row[index].formula)"
                 :controls="false"
-                @input="handleDataChange(row)"
+                @change="handleDataChange(row)"
               ></el-input-number>
               <div style="width: 80px; height: 100%; flex-shrink: 0">
                 <DictSelection
@@ -258,7 +258,7 @@
                 "
                 :disabled="Boolean(row[index].formula)"
                 :controls="false"
-                @input="handleDataChange(row)"
+                @change="handleDataChange(row)"
               ></el-input>
               <div style="width: 80px; height: 100%; flex-shrink: 0">
                 <DictSelection
@@ -780,6 +780,7 @@
       },
       // 当数据变化时计算公式
       handleDataChange(row) {
+        console.log('row 触发',row)
         // todo 计算公式
         // 寻找当前行的所有可计算项,进行计算更新
         const formulaItmes = row.filter((i) => i.formula);

+ 2 - 2
src/views/produce/components/footBtn.vue

@@ -274,11 +274,11 @@
             buts: ['过程监测', '产后检查', '报工'],
             msg: '请先完成投料'
           },
-          processResult: {
+          postResult: {
             buts: ['产后检查', '报工'],
             msg: '请先完成过程监测'
           },
-          postResult: {
+          finalResult: {
             buts: ['报工'],
             msg: '请先完成产后检查'
           }

+ 170 - 198
src/views/produce/components/prenatalExamination/material.vue

@@ -39,14 +39,16 @@
       @refresh="localOutputDetailsRefresh"
     >
       <template v-slot:reportQuantity="{ row }">
-        <el-input-number
-          size="small"
-          v-model.number="row.reportQuantity"
-          controls-position="right"
-          :min="0"
-          :max="reportQuantitymax(row)"
-          @change="reportQuantityChange(row)"
-        ></el-input-number>
+        <div>
+          <el-input-number
+            size="small"
+            v-model.number="row.reportQuantity"
+            controls-position="right"
+            :min="0"
+            :max="reportQuantitymax(row)"
+            @change="reportQuantityChange(row)"
+          ></el-input-number>
+        </div>
       </template>
       <template v-slot:qualifiedQuantity="{ row }">
         <el-input-number
@@ -154,10 +156,10 @@
         type: [String, Number],
         required: false
       },
-      // recordId 是否保存过数据
-      recordId: {
-        type: [String, Number],
-        default: ''
+      // 执行状态
+      executeStatus: {
+        type: [Number],
+        required: false
       }
     },
     watch: {
@@ -305,7 +307,7 @@
               if (this.outputType == 1) {
                 // 取值产出清单
                 const outputItem = this.localOutputDetails.find(
-                  (item) => item.categoryId === row.categoryId
+                  (item) => item.categoryCode === row.categoryCode
                 );
                 return (
                   (outputItem ? outputItem.reportQuantity : 0) +
@@ -318,7 +320,7 @@
                   return '0' + (row.unit || '');
                 }
                 const materialItem = this.materialQuotaInfo.materialQuota.find(
-                  (item) => item.id === row.categoryId
+                  (item) => item.categoryCode === row.categoryCode
                 );
                 if (!materialItem) {
                   return '0' + (row.unit || '');
@@ -344,58 +346,59 @@
             formatter: (row) => {
               if (this.outputType == 1) {
                 const outputItem = this.localOutputDetails.find(
-                  (item) => item.categoryId === row.categoryId
+                  (item) => item.categoryCode == row.categoryCode
                 );
                 if (!outputItem) {
-                  return '0' + (row.unit || '');
+                  return row.sumReportQuantity + (row.unit || '');
                 }
-                if (this.recordId) {
-                  let count =
-                    outputItem.sumReportQuantity +
-                    outputItem.reportQuantity -
-                    outputItem.reportQuantityCopy;
-                  return count + (row.unit || '');
+                let count = 0;
+                if (this.executeStatus === 2) {
+                  // 已执行,处理重新一键报工时,sumReportQuantity包含了当前报工数量
+                  count =
+                    row.sumReportQuantity -
+                    (outputItem.reportQuantityCopy - outputItem.reportQuantity);
                 } else {
-                  let count =
-                    outputItem.sumReportQuantity + outputItem.reportQuantity;
-                  return count + (row.unit || '');
+                  count = row.sumReportQuantity + outputItem.reportQuantity;
                 }
+
+                return count + (row.unit || '');
               } else {
-                // 产出为在制品 或 BOM标准产出
-                // 查询基数
+                // 产出为在制品 或 BOM标准产出 累计消耗数量
                 if (!this.materialQuotaInfo) {
-                  return '0' + (row.unit || '');
+                  return row.sumReportQuantity + (row.unit || '');
                 }
                 const materialItem = this.materialQuotaInfo.materialQuota.find(
-                  (item) => item.id === row.categoryId
+                  (item) => item.categoryCode === row.categoryCode
                 );
                 if (!materialItem) {
-                  return '0' + (row.unit || '');
+                  return row.sumReportQuantity + (row.unit || '');
                 }
-                // 需要的物料数量比例
-                let count =
-                  materialItem.count / this.materialQuotaInfo.baseCount;
-                // 产出清单的报工数量 当次报工+累计报工
                 const outputItem = this.localOutputDetails[0];
                 if (!outputItem) {
-                  return '0' + (row.unit || '');
+                  return row.sumReportQuantity + (row.unit || '');
                 }
-                if (this.recordId) {
-                  // 累计消耗
-                  let needQuantity =
-                    (outputItem.sumReportQuantity +
-                      outputItem.reportQuantity -
-                      outputItem.reportQuantityCopy) *
-                    count;
-                  return needQuantity + (row.unit || '');
+                // 单位产出所需物料比例
+                const proportion =
+                  materialItem.count / this.materialQuotaInfo.baseCount;
+
+                let cumulativeOutputQuantity = 0;
+
+                if (this.executeStatus === 2) {
+                  // 已执行,处理重新一键报工时,sumReportQuantity包含了当前报工数量
+                  cumulativeOutputQuantity =
+                    outputItem.sumReportQuantity -
+                    (outputItem.reportQuantityCopy - outputItem.reportQuantity);
                 } else {
-                  // 累计消耗
-                  let needQuantity =
-                    (outputItem.sumReportQuantity + outputItem.reportQuantity) *
-                    count;
-                  if (needQuantity < 0) needQuantity = 0;
-                  return needQuantity + (row.unit || '');
+                  cumulativeOutputQuantity =
+                    outputItem.sumReportQuantity + outputItem.reportQuantity;
                 }
+                const needQuantity = cumulativeOutputQuantity * proportion;
+
+                // 已消耗数量转换
+                // const sumReportQuantity = row.sumReportQuantity * proportion;
+                const sumReportQuantity = row.sumReportQuantity;
+
+                return needQuantity + sumReportQuantity + (row.unit || '');
               }
             }
           }
@@ -539,34 +542,39 @@
 
         data.forEach((newItem) => {
           const index = this.localPickDetails.findIndex(
-            (item) =>
-              item.categoryCode === newItem.categoryCode &&
-              item.produceTaskInstanceId === newItem.produceTaskInstanceId
+            (item) => item.categoryCode === newItem.categoryCode
           );
           if (index !== -1) {
             // 存在则替换数量
             this.localPickDetails[index].quantity = newItem.quantity;
           } else {
             const sumItem = this.sumOutputDetails.find(
-              (i) => i.categoryId === i.categoryId
+              (item) => item.categoryCode === newItem.categoryCode
             );
 
-            let reportQuantity = newItem.reportQuantity || 0;
+            let sumQualifiedQuantity = 0;
+            let sumNoQualifiedQuantity = 0;
+            let sumReportQuantity = 0;
 
             if (sumItem) {
-              reportQuantity = sumItem.reportQuantity;
+              sumQualifiedQuantity = sumItem.sumQualifiedQuantity;
+              sumNoQualifiedQuantity = sumItem.sumNoQualifiedQuantity;
+              sumReportQuantity = sumItem.sumReportQuantity;
             }
 
             // 不存在则添加
             this.localPickDetails.push({
               ...newItem,
-              reportQuantity,
+              reportQuantity: 0,
               ruleId: this.ruleId,
               bomCategoryId: this.bomCategoryId,
               produceTaskId: this.produceTaskId,
               produceTaskInstanceId: this.produceTaskInstanceId,
               produceTaskName: this.produceTaskName,
-              workOrderId: this.workOrderId
+              workOrderId: this.workOrderId,
+              sumQualifiedQuantity,
+              sumNoQualifiedQuantity,
+              sumReportQuantity
             });
           }
         });
@@ -579,13 +587,18 @@
         if (this.materialQuotaInfo && this.materialQuotaInfo.standardOutput) {
           const sumItem = this.sumOutputDetails.find(
             (i) =>
-              i.categoryId === this.materialQuotaInfo.standardOutput.categoryId
+              i.categoryCode ===
+              this.materialQuotaInfo.standardOutput.categoryCode
           );
 
-          let reportQuantity = 0;
+          let sumQualifiedQuantity = 0;
+          let sumNoQualifiedQuantity = 0;
+          let sumReportQuantity = 0;
 
           if (sumItem) {
-            reportQuantity = sumItem.reportQuantity;
+            sumQualifiedQuantity = sumItem.sumQualifiedQuantity;
+            sumNoQualifiedQuantity = sumItem.sumNoQualifiedQuantity;
+            sumReportQuantity = sumItem.sumReportQuantity;
           }
 
           // 赋值产出
@@ -593,13 +606,14 @@
             {
               ...this.materialQuotaInfo.standardOutput,
               id: null,
-              reportQuantity,
+              reportQuantity: 0,
+              reportQuantityCopy: 0,
               qualifiedQuantity: 0,
               noQualifiedQuantity: 0,
               msg: '',
-              sumReportQuantity: 0,
-              sumQualifiedQuantity: 0,
-              sumNoQualifiedQuantity: 0,
+              sumReportQuantity,
+              sumQualifiedQuantity,
+              sumNoQualifiedQuantity,
               ruleId: this.ruleId,
               outputType: this.outputType,
               produceTaskId: this.produceTaskId,
@@ -642,23 +656,36 @@
         if (row.selected) {
           // 判断是否存在
           const index = this.localOutputDetails.findIndex(
-            (item) =>
-              item.categoryId === row.categoryId &&
-              item.produceTaskInstanceId === row.produceTaskInstanceId
+            (item) => item.categoryId === row.categoryId
           );
 
           if (index === -1) {
+            const sumItem = this.sumOutputDetails.find(
+              (i) => i.categoryCode === row.categoryCode
+            );
+
+            let sumQualifiedQuantity = 0;
+            let sumNoQualifiedQuantity = 0;
+            let sumReportQuantity = 0;
+
+            if (sumItem) {
+              sumQualifiedQuantity = sumItem.sumQualifiedQuantity;
+              sumNoQualifiedQuantity = sumItem.sumNoQualifiedQuantity;
+              sumReportQuantity = sumItem.sumReportQuantity;
+            }
+
             // 不存在则添加
             this.localOutputDetails.push({
               ...row,
               id: null,
               reportQuantity: 0,
+              reportQuantityCopy: 0,
               qualifiedQuantity: 0,
               noQualifiedQuantity: 0,
               msg: '',
-              sumReportQuantity: 0,
-              sumQualifiedQuantity: 0,
-              sumNoQualifiedQuantity: 0,
+              sumReportQuantity,
+              sumQualifiedQuantity,
+              sumNoQualifiedQuantity,
               ruleId: this.ruleId,
               outputType: this.outputType,
               bomCategoryId: this.bomCategoryId,
@@ -684,26 +711,31 @@
         const data = await getCategoryAndLevelByCategoryId(this.categoryId);
         if (data) {
           const sumItem = this.sumOutputDetails.find(
-            (i) => i.categoryId == data.categoryId
+            (i) => i.categoryCode == data.categoryCode
           );
 
-          let reportQuantity = 0;
+          let sumQualifiedQuantity = 0;
+          let sumNoQualifiedQuantity = 0;
+          let sumReportQuantity = 0;
 
           if (sumItem) {
-            reportQuantity = sumItem.reportQuantity;
+            sumQualifiedQuantity = sumItem.sumQualifiedQuantity;
+            sumNoQualifiedQuantity = sumItem.sumNoQualifiedQuantity;
+            sumReportQuantity = sumItem.sumReportQuantity;
           }
 
           this.localOutputDetails = [
             {
               ...data,
               id: null,
-              reportQuantity,
+              reportQuantity: 0,
+              reportQuantityCopy: 0,
               qualifiedQuantity: 0,
               noQualifiedQuantity: 0,
               msg: '',
-              sumReportQuantity: 0,
-              sumQualifiedQuantity: 0,
-              sumNoQualifiedQuantity: 0,
+              sumReportQuantity,
+              sumQualifiedQuantity,
+              sumNoQualifiedQuantity,
               ruleId: this.ruleId,
               outputType: this.outputType,
               produceTaskId: this.produceTaskId,
@@ -722,37 +754,63 @@
       // 计算报工数量最大值
       reportQuantitymax(row) {
         if (this.outputType == 1) {
+          // 查询物料本身
+          const pickItem = this.localPickDetails.find(
+            (item) => item.categoryCode === row.categoryCode
+          );
           // 物料本身 不能超过已报工数量减领料数量
-          return row.quantity - row.sumReportQuantity;
+
+          // 已执行,处理重新一键报工时,sumReportQuantity包含了当前报工数量
+          if (this.executeStatus === 2) {
+            return (
+              pickItem.quantity -
+              (pickItem.sumReportQuantity - row.reportQuantityCopy)
+            );
+          } else {
+            return pickItem.quantity - pickItem.sumReportQuantity;
+          }
         }
         if (row.outputType == 2 || row.outputType == 3) {
-          // 基于物料配额限制最大可报工数量
+          // 基于物料配额限制最大可报工数量(兼容已缓存/已保存一次的编辑场景,并区分已执行状态)
           if (!this.materialQuotaInfo) return Infinity;
-          const quota = this.materialQuotaInfo;
-          const alreadyOutput = this.recordId
-            ? row.sumReportQuantity - (row.reportQuantityCopy || 0)
-            : row.sumReportQuantity;
-          let max = Infinity;
-          quota.materialQuota.forEach((m) => {
-            const proportion = m.count / quota.baseCount; // 单位产出所需物料数量
-            if (!proportion) return;
-            const pick = this.localPickDetails.find(
-              (p) => p.categoryId == m.id
+          const quota = this.materialQuotaInfo.materialQuota || [];
+          if (!quota.length) return Infinity;
+
+          const isExecuted = this.executeStatus === 2;
+
+          const { baseCount } = this.materialQuotaInfo;
+          if (!baseCount) return Infinity;
+
+          // 计算每个物料的最大可报工数量
+          const maxQuantities = quota.map((item) => {
+            const pickItem = this.localPickDetails.find(
+              (p) => p.categoryCode === item.categoryCode
             );
-            const pre = this.preOutputDetails.find((p) => p.categoryId == m.id);
-            const source = pick || pre;
-            if (!source) return;
-            // 可用物料数量:优先使用累计已报工+当次报工,没有则回退领料数量
-            const available =
-              (source.sumReportQuantity || 0) + (source.reportQuantity || 0) ||
-              source.quantity ||
-              0;
-            if (!available) return;
-            const materialMaxTotalOutput = available / proportion;
-            const remain = materialMaxTotalOutput - alreadyOutput;
-            if (remain < max) max = remain;
+            if (!pickItem) {
+              return Infinity;
+            }
+
+            // 单位产出所需物料比例
+            const proportion = item.count / baseCount;
+
+            // 已执行,处理重新一键报工时,sumReportQuantity包含了当前报工数量
+            let consumedQuantity = isExecuted
+              ? row.sumReportQuantity - row.reportQuantityCopy
+              : row.sumReportQuantity;
+
+            // 已执行的比例换算,换算为需要多少物料数量
+            const consumedProportion = consumedQuantity * proportion;
+
+            // 最大可报工数量
+            const maxQuantity =
+              (pickItem.quantity - consumedProportion) / proportion;
+
+            // 向下取整
+            return Math.floor(maxQuantity);
           });
-          return max <= 0 ? 0 : max;
+
+          // 返回最小的那个物料的最大可报工数量
+          return Math.min(...maxQuantities);
         }
         return Infinity;
       },
@@ -781,19 +839,24 @@
         }
 
         if (this.outputType == 1) {
-          if (this.localPickDetails.length == 0) {
+          if (
+            this.localPickDetails.length == 0 &&
+            this.preOutputDetails.length == 0
+          ) {
             this.$message.warning(`物料清单不能为空`);
             return false;
           }
 
           for (const item of this.localOutputDetails) {
             const pickitem = this.localPickDetails.find(
-              (pick) =>
-                pick.categoryId == item.categoryId &&
-                pick.produceTaskInstanceId == item.produceTaskInstanceId
+              (pick) => pick.categoryCode == item.categoryCode
+            );
+
+            const prePickitem = this.preOutputDetails.find(
+              (pick) => pick.categoryCode == item.categoryCode
             );
 
-            if (pickitem == null) {
+            if (pickitem == null && prePickitem == null) {
               this.$message.warning(
                 `所需物料【${item.categoryName}】未在物料清单中找到`
               );
@@ -809,97 +872,6 @@
           }
         }
 
-        if (this.outputType == 3 || this.outputType == 2) {
-          let val = true;
-
-          if (!this.materialQuotaInfo) {
-            await this.getMaterialQuotaInfo();
-          }
-
-          // 没有配置产出清单 、没有原材料 不检查
-          if (!this.materialQuotaInfo || this.localPickDetails.length == 0) {
-            return true;
-          }
-
-          this.materialQuotaInfo.materialQuota.forEach((i) => {
-            // 避免重复提示
-            if (!val) {
-              return;
-            }
-            // 需要的物料数量比例
-            let count = i.count / this.materialQuotaInfo.baseCount;
-
-            // 产出清单的报工数量 当次报工+累计报工
-            const outputItem = this.localOutputDetails[0];
-
-            // 产出物料数量
-            const outputQuantity =
-              outputItem.reportQuantity + outputItem.sumReportQuantity;
-            const needQuantity = outputQuantity * count;
-
-            // 查询物料清单 是否满足数量
-            const pickitem = this.localPickDetails.find(
-              (pick) => pick.categoryId == i.id
-            );
-            // 查询preOutputDetails 上一道工序产出物
-            const preOutputItem = this.preOutputDetails.find(
-              (pre) => pre.categoryId == i.id
-            );
-
-            // 所需物料是 物料或者是上一道工序产出物
-            if (pickitem == null && preOutputItem == null) {
-              this.$message.warning(
-                `所需物料【${i.categoryName}】未在物料清单中找到`
-              );
-              val = false;
-              return false;
-            }
-
-            // 物料对象存在
-            if (pickitem) {
-              if (needQuantity > pickitem.quantity) {
-                this.$message.warning(
-                  `物料【${pickitem.categoryName}】领料数量不足,需${needQuantity}${pickitem.unit},当前仅有${pickitem.quantity}${pickitem.unit}`
-                );
-                val = false;
-                return false;
-              }
-              // 判断累计报工数量是否足够
-              let pickitemSumReportQuantity =
-                pickitem.sumReportQuantity + pickitem.reportQuantity;
-              if (needQuantity > pickitemSumReportQuantity) {
-                this.$message.warning(
-                  `物料【${pickitem.categoryName}】累计报工数量不足,需${needQuantity}${pickitem.unit},当前仅有${pickitemSumReportQuantity}${pickitem.unit}`
-                );
-                val = false;
-                return false;
-              }
-            }
-            // 上一道工序产出物存在
-            // if (preOutputItem) {
-            //   if (needQuantity > preOutputItem.quantity) {
-            //     this.$message.warning(
-            //       `物料【${preOutputItem.categoryName}】领料数量不足,需${needQuantity}${preOutputItem.unit},当前仅有${preOutputItem.quantity}${preOutputItem.unit}`
-            //     );
-            //     val = false;
-            //     return false;
-            //   }
-            //   // 判断累计报工数量是否足够
-            //   let preOutputItemSumReportQuantity =
-            //     preOutputItem.sumReportQuantity + preOutputItem.reportQuantity;
-            //   if (needQuantity > preOutputItemSumReportQuantity) {
-            //     this.$message.warning(
-            //       `物料【${preOutputItem.categoryName}】累计报工数量不足,需${needQuantity}${preOutputItem.unit},当前仅有${preOutputItemSumReportQuantity}${preOutputItem.unit}`
-            //     );
-            //     val = false;
-            //     return false;
-            //   }
-            // }
-          });
-
-          return val;
-        }
-
         return true;
       },
       // 当次报工修改

+ 51 - 14
src/views/produce/components/prenatalExamination/releaseRulesDialog.vue

@@ -251,7 +251,7 @@
       :bomCategoryId="workOrderInfo.bomCategoryId"
       :outputType="addForm.outputType"
       :categoryId="workOrderInfo.categoryId"
-      :record-id="productionInfo.recordId"
+      :executeStatus="productionInfo.executeStatus"
       @refresh="getListByWorkOrderId"
     ></material>
 
@@ -887,34 +887,80 @@
           i.reportQuantityCopy = i.reportQuantity;
 
           const sumItem = materialObject.sumOutputDetails.find(
-            (i) => i.categoryId === i.categoryId
+            (item) => i.categoryCode === item.categoryCode
           );
 
           if (sumItem) {
-            i.reportQuantity = sumItem.reportQuantity;
+            i.sumQualifiedQuantity = sumItem.sumQualifiedQuantity;
+            i.sumNoQualifiedQuantity = sumItem.sumNoQualifiedQuantity;
+            i.sumReportQuantity = sumItem.sumReportQuantity;
           } else {
-            i.reportQuantity = i.reportQuantity || 0;
+            i.sumQualifiedQuantity = 0;
+            i.sumNoQualifiedQuantity = 0;
+            i.sumReportQuantity = 0;
           }
 
           return i;
         });
+
         const pickDetails = materialObject.pickDetails.map((i) => {
           // 物料清单中如果存在则 selected 设置为 true
           const any = this.addForm.outputDetails.find(
-            (j) => j.categoryId === i.categoryId
+            (j) => j.categoryCode === i.categoryCode
           );
           if (any) {
             i.selected = true;
           } else {
             i.selected = false;
           }
+
+          const sumItem = materialObject.sumOutputDetails.find(
+            (item) => i.categoryCode === item.categoryCode
+          );
+
+          if (sumItem) {
+            i.sumQualifiedQuantity = sumItem.sumQualifiedQuantity;
+            i.sumNoQualifiedQuantity = sumItem.sumNoQualifiedQuantity;
+            i.sumReportQuantity = sumItem.sumReportQuantity;
+          } else {
+            i.sumQualifiedQuantity = 0;
+            i.sumNoQualifiedQuantity = 0;
+            i.sumReportQuantity = 0;
+          }
+
           return i;
         });
 
         const preOutputDetails = materialObject.preOutputDetails.map((i) => {
           i.quantity = i.qualifiedQuantity;
+
+          // 物料清单中如果存在则 selected 设置为 true
+          const any = this.addForm.outputDetails.find(
+            (j) => j.categoryCode === i.categoryCode
+          );
+          if (any) {
+            i.selected = true;
+          } else {
+            i.selected = false;
+          }
+
+          const sumItem = materialObject.sumOutputDetails.find(
+            (item) => i.categoryCode === item.categoryCode
+          );
+
+          if (sumItem) {
+            i.sumQualifiedQuantity = sumItem.sumQualifiedQuantity;
+            i.sumNoQualifiedQuantity = sumItem.sumNoQualifiedQuantity;
+            i.sumReportQuantity = sumItem.sumReportQuantity;
+          } else {
+            i.sumQualifiedQuantity = 0;
+            i.sumNoQualifiedQuantity = 0;
+            i.sumReportQuantity = 0;
+          }
+
           return i;
         });
+
         this.preOutputDetails = preOutputDetails.filter(
           (i) => i.outputType != 1
         );
@@ -987,15 +1033,6 @@
       // 提交
       submit(type) {
         console.log('this.addForm', this.addForm);
-        if (type == 'submit') {
-          if (this.$refs.materialRef) {
-            // 验证产出物数量
-            const valid = this.$refs.materialRef.validateOutputQuantities();
-            if (!valid) {
-              return;
-            }
-          }
-        }
         // 验证表单
         this.$refs.ruleFormRef.validate(async (valid) => {
           if (!valid) {

+ 2 - 2
vue.config.js

@@ -37,14 +37,14 @@ module.exports = {
         // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.125:18086',
-        // target: 'http://192.168.1.116:18086', // 赵沙金
+        target: 'http://192.168.1.116:18086', // 赵沙金
         // target: 'http://192.168.1.251:18086', // 开发环境
         // target: 'http://192.168.1.103:18086',192.168.1.116
         // target: 'http://192.168.1.144:18086',
         // target: 'http://192.168.1.30:18086',
         // target: 'http://192.168.1.211:18086',
         // target: 'http://192.168.1.33:18086',
-        target: 'http://192.168.1.251:18186', // 测试环境
+        // target: 'http://192.168.1.251:18186', // 测试环境
         // target: 'http://192.168.1.251:18087',
         // target: 'http://116.163.22.90:86/api', // 嘉实生产
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域