Просмотр исходного кода

当次最大报工数量限制

lucw 7 месяцев назад
Родитель
Сommit
29a63d7a6b
1 измененных файлов с 29 добавлено и 9 удалено
  1. 29 9
      src/views/produce/components/prenatalExamination/material.vue

+ 29 - 9
src/views/produce/components/prenatalExamination/material.vue

@@ -725,14 +725,34 @@
           // 物料本身 不能超过已报工数量减领料数量
           // 物料本身 不能超过已报工数量减领料数量
           return row.quantity - row.sumReportQuantity;
           return row.quantity - row.sumReportQuantity;
         }
         }
-        if (row.outputType == 2) {
-          // 在物料中查询对应的物料
-          const pickitem = this.preOutputDetails.find(
-            (pick) => pick.categoryId == row.categoryId
-          );
-          if (pickitem) {
-            return pickitem.qualifiedQuantity;
-          }
+        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 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;
+          });
+          return max <= 0 ? 0 : max;
         }
         }
         return Infinity;
         return Infinity;
       },
       },
@@ -789,7 +809,7 @@
           }
           }
         }
         }
 
 
-        if (this.outputType == 2) {
+        if (this.outputType == 3 || this.outputType == 2) {
           let val = true;
           let val = true;
 
 
           if (!this.materialQuotaInfo) {
           if (!this.materialQuotaInfo) {