Jelajahi Sumber

物料添加功能完善

lucw 7 bulan lalu
induk
melakukan
400bb7841d

+ 27 - 11
src/views/produce/components/prenatalExamination/materialModal.vue

@@ -105,7 +105,7 @@
             prop: 'pickQuantity',
             prop: 'pickQuantity',
             minWidth: 120,
             minWidth: 120,
             formatter: (row) => {
             formatter: (row) => {
-              return (row.pickQuantity || '') + (row.pickUnit || '');
+              return (row.pickQuantity || 0) + (row.pickUnit || '');
             }
             }
           },
           },
           {
           {
@@ -113,9 +113,7 @@
             prop: 'outStorageQuantity',
             prop: 'outStorageQuantity',
             minWidth: 120,
             minWidth: 120,
             formatter: (row) => {
             formatter: (row) => {
-              return (
-                (row.outStorageQuantity || '') + (row.outStorageUnit || '')
-              );
+              return (row.outStorageQuantity || 0) + (row.outStorageUnit || '');
             }
             }
           },
           },
           {
           {
@@ -123,28 +121,43 @@
             prop: 'feedQuantity',
             prop: 'feedQuantity',
             minWidth: 120,
             minWidth: 120,
             formatter: (row) => {
             formatter: (row) => {
-              return (row.feedQuantity || '') + (row.feedUnit || '');
+              return (row.feedQuantity || 0) + (row.feedUnit || '');
             }
             }
           },
           },
           {
           {
             label: '已报工数量',
             label: '已报工数量',
             prop: 'reportQuantity',
             prop: 'reportQuantity',
-            minWidth: 120
+            minWidth: 120,
+            formatter(row) {
+              return (row.reportQuantity || 0) + row.feedUnit;
+            }
           },
           },
           {
           {
             label: '未报工数量',
             label: '未报工数量',
             prop: 'noReportQuantity',
             prop: 'noReportQuantity',
-            minWidth: 120
+            minWidth: 120,
+            formatter(row) {
+              if (row.reportQuantity != null) {
+                return row.feedQuantity - row.reportQuantity + row.feedUnit;
+              }
+              return `${row.feedQuantity}${row.feedUnit || ''}`;
+            }
           },
           },
           {
           {
             label: '合格总数',
             label: '合格总数',
             prop: 'qualifiedQuantity',
             prop: 'qualifiedQuantity',
-            minWidth: 120
+            minWidth: 120,
+            formatter(row) {
+              return (row.qualifiedQuantity || 0) + (row.feedUnit || '');
+            }
           },
           },
           {
           {
             label: '不合格总数',
             label: '不合格总数',
             prop: 'noQualifiedQuantity',
             prop: 'noQualifiedQuantity',
-            minWidth: 120
+            minWidth: 120,
+            formatter(row) {
+              return (row.noQualifiedQuantity || 0) + (row.feedUnit || '');
+            }
           }
           }
         ],
         ],
 
 
@@ -152,6 +165,7 @@
         selection: [],
         selection: [],
         taskPlanList: [],
         taskPlanList: [],
         workOrderId: '',
         workOrderId: '',
+        ruleId: '',
         // 已选物料
         // 已选物料
         pickDetails: []
         pickDetails: []
       };
       };
@@ -181,7 +195,8 @@
       async datasource({ page, limit, where }) {
       async datasource({ page, limit, where }) {
         const res = await queryPickAndFeedByWorkOrderId({
         const res = await queryPickAndFeedByWorkOrderId({
           ...where,
           ...where,
-          workOrderId: this.workOrderId
+          workOrderId: this.workOrderId,
+          ruleId: this.ruleId
           // pageNum: page,
           // pageNum: page,
           // size: limit
           // size: limit
         });
         });
@@ -196,9 +211,10 @@
         this.selection = [];
         this.selection = [];
         this.visible = false;
         this.visible = false;
       },
       },
-      open(workOrderId, pickDetails) {
+      open(workOrderId, ruleId, pickDetails = []) {
         this.workOrderId = workOrderId;
         this.workOrderId = workOrderId;
         this.pickDetails = pickDetails;
         this.pickDetails = pickDetails;
+        this.ruleId = ruleId;
         this.$nextTick(() => {
         this.$nextTick(() => {
           // this.reload({ workOrderId });
           // this.reload({ workOrderId });
           this.queryAllProduceTaskList(workOrderId);
           this.queryAllProduceTaskList(workOrderId);

+ 114 - 34
src/views/produce/components/prenatalExamination/releaseRulesDialog.vue

@@ -208,25 +208,31 @@
       </template>
       </template>
 
 
       <template v-slot:reportQuantity="{ row }">
       <template v-slot:reportQuantity="{ row }">
-        <el-input
+        <el-input-number
+          size="small"
           v-model.number="row.reportQuantity"
           v-model.number="row.reportQuantity"
-          type="text"
-          min="0"
-        ></el-input>
+          controls-position="right"
+          :min="0"
+          :max="row.feedQuantity"
+        ></el-input-number>
       </template>
       </template>
       <template v-slot:qualifiedQuantity="{ row }">
       <template v-slot:qualifiedQuantity="{ row }">
-        <el-input
+        <el-input-number
+          size="small"
           v-model.number="row.qualifiedQuantity"
           v-model.number="row.qualifiedQuantity"
-          type="text"
-          min="0"
-        ></el-input>
+          controls-position="right"
+          :min="0"
+          :max="qualifiedQuantityMax(row)"
+        ></el-input-number>
       </template>
       </template>
       <template v-slot:noQualifiedQuantity="{ row }">
       <template v-slot:noQualifiedQuantity="{ row }">
-        <el-input
+        <el-input-number
+          size="small"
           v-model.number="row.noQualifiedQuantity"
           v-model.number="row.noQualifiedQuantity"
-          type="text"
-          min="0"
-        ></el-input>
+          controls-position="right"
+          :min="0"
+          :max="noQualifiedQuantityMax(row)"
+        ></el-input-number>
       </template>
       </template>
       <template v-slot:msg="{ row }">
       <template v-slot:msg="{ row }">
         <el-input
         <el-input
@@ -491,11 +497,10 @@
                 if (!value) return callback();
                 if (!value) return callback();
                 const now = new Date();
                 const now = new Date();
                 const start = new Date(value);
                 const start = new Date(value);
-                if (start < now) {
-                  callback(new Error('开始时间不能小于当前时间'));
-                } else {
-                  callback();
-                }
+                // if (start < now) {
+                //   return callback(new Error('开始时间不能小于当前时间'));
+                // }
+                callback();
               },
               },
               trigger: 'blur'
               trigger: 'blur'
             }
             }
@@ -618,6 +623,24 @@
               return (row.pickQuantity || '') + (row.pickUnit || '');
               return (row.pickQuantity || '') + (row.pickUnit || '');
             }
             }
           },
           },
+          {
+            label: '出库数量',
+            prop: 'outStorageQuantity',
+            minWidth: 120,
+            formatter: (row) => {
+              return (
+                (row.outStorageQuantity || '') + (row.outStorageUnit || '')
+              );
+            }
+          },
+          {
+            label: '投料数量',
+            prop: 'feedQuantity',
+            minWidth: 120,
+            formatter: (row) => {
+              return (row.feedQuantity || '') + (row.feedUnit || '');
+            }
+          },
           {
           {
             label: '当次报工数量',
             label: '当次报工数量',
             prop: 'reportQuantity',
             prop: 'reportQuantity',
@@ -645,22 +668,37 @@
           {
           {
             label: '已报工数量',
             label: '已报工数量',
             prop: 'sumReportQuantity',
             prop: 'sumReportQuantity',
-            minWidth: 120
+            minWidth: 120,
+            formatter(row) {
+              return (row.sumReportQuantity || 0) + row.feedUnit;
+            }
           },
           },
           {
           {
             label: '未报工数量',
             label: '未报工数量',
             prop: 'noReportQuantity',
             prop: 'noReportQuantity',
-            minWidth: 120
+            minWidth: 120,
+            formatter(row) {
+              if (row.sumReportQuantity != null) {
+                return row.feedQuantity - row.sumReportQuantity + row.feedUnit;
+              }
+              return `${row.feedQuantity}${row.feedUnit || ''}`;
+            }
           },
           },
           {
           {
             label: '合格总数',
             label: '合格总数',
             prop: 'sumQualifiedQuantity',
             prop: 'sumQualifiedQuantity',
-            minWidth: 120
+            minWidth: 120,
+            formatter(row) {
+              return (row.sumQualifiedQuantity || 0) + (row.feedUnit || '');
+            }
           },
           },
           {
           {
             label: '不合格总数',
             label: '不合格总数',
             prop: 'sumNoQualifiedQuantity',
             prop: 'sumNoQualifiedQuantity',
-            minWidth: 120
+            minWidth: 120,
+            formatter(row) {
+              return (row.sumNoQualifiedQuantity || 0) + (row.feedUnit || '');
+            }
           }
           }
         ]
         ]
       };
       };
@@ -799,7 +837,8 @@
         const materialList = await queryListByWorkOrderId({
         const materialList = await queryListByWorkOrderId({
           workOrderId: this.addForm.workOrderId,
           workOrderId: this.addForm.workOrderId,
           recordId: this.productionInfo.recordId,
           recordId: this.productionInfo.recordId,
-          produceTaskInstanceId: this.workOrderInfo.taskId
+          produceTaskInstanceId: this.workOrderInfo.taskId,
+          ruleId: this.addForm.ruleId
         });
         });
 
 
         console.log('materialList 物料信息', materialList);
         console.log('materialList 物料信息', materialList);
@@ -848,8 +887,8 @@
       handleBeforeClose() {
       handleBeforeClose() {
         this.addForm = JSON.parse(JSON.stringify(this.formDate));
         this.addForm = JSON.parse(JSON.stringify(this.formDate));
         console.log('this.$refs.ruleFormRef', this.addForm);
         console.log('this.$refs.ruleFormRef', this.addForm);
-        this.$refs.ruleFormRef?.clearValidate();
         this.$nextTick(() => {
         this.$nextTick(() => {
+          this.$refs.ruleFormRef.clearValidate();
           this.visible = false;
           this.visible = false;
         });
         });
       },
       },
@@ -932,12 +971,20 @@
           this.addForm.checkValidityUnit = null;
           this.addForm.checkValidityUnit = null;
           this.addForm.conclution = null;
           this.addForm.conclution = null;
           this.addForm.id = null;
           this.addForm.id = null;
+          this.addForm.pickDetails = [];
+          this.addForm.duration = 0;
+          this.addForm.executeUsers = [];
+          thia.addForm.executeUsersIds = [];
 
 
           this.getRuleList();
           this.getRuleList();
           this.$message.success('缓存清空成功!');
           this.$message.success('缓存清空成功!');
           this.productionInfo.executeStatus = 0;
           this.productionInfo.executeStatus = 0;
           if (this.addForm.isTempRecord) {
           if (this.addForm.isTempRecord) {
             this.handleBeforeClose();
             this.handleBeforeClose();
+          } else {
+            this.$nextTick(() => {
+              this.$refs.ruleFormRef.clearValidate();
+            });
           }
           }
           this.$emit('reload');
           this.$emit('reload');
         } catch (error) {
         } catch (error) {
@@ -1080,24 +1127,57 @@
       openMaterialModal() {
       openMaterialModal() {
         this.$refs.materialModalRef.open(
         this.$refs.materialModalRef.open(
           this.addForm.workOrderId,
           this.addForm.workOrderId,
-          this.addForm.pickDetails
+          this.addForm.ruleId,
+          []
         );
         );
       },
       },
       materialConfirm(data) {
       materialConfirm(data) {
         // 选择物料后添加
         // 选择物料后添加
+        console.log('data', data);
 
 
-        this.addForm.pickDetails = [
-          ...this.addForm.pickDetails,
-          ...data.map((i) => {
+        // 去重
+        const list = data
+          .filter((i) => {
+            const any = this.addForm.pickDetails.find(
+              (item) =>
+                item.categoryCode === i.categoryCode &&
+                item.produceTaskInstanceId === i.produceTaskInstanceId
+            );
+            return !any;
+          })
+          .map((i) => {
+            i.ruleId = this.addForm.ruleId;
+            return i;
+          });
+
+        // 覆盖部分数据
+        this.addForm.pickDetails = this.addForm.pickDetails.map((i) => {
+          const item = data.find(
+            (item) =>
+              item.categoryCode === i.categoryCode &&
+              item.produceTaskInstanceId === i.produceTaskInstanceId
+          );
+          if (item) {
             return {
             return {
-              ...i,
-              sumReportQuantity: i.reportQuantity,
-              sumNoReportQuantity: i.noReportQuantity,
-              sumQualifiedQuantity: i.qualifiedQuantity,
-              sumNoQualifiedQuantity: i.noQualifiedQuantity
+              ...item,
+              reportQuantity: i.reportQuantity,
+              qualifiedQuantity: i.qualifiedQuantity,
+              noQualifiedQuantity: i.noQualifiedQuantity,
+              msg: i.msg
             };
             };
-          })
-        ];
+          }
+          return i;
+        });
+        this.addForm.pickDetails = [...this.addForm.pickDetails, ...list];
+        console.log('list', list);
+        console.log('this.addForm.pickDetails', this.addForm.pickDetails);
+      },
+      // qualifiedQuantityMax 最大合格数量
+      qualifiedQuantityMax(row) {
+        return row.reportQuantity - row.noQualifiedQuantity;
+      },
+      noQualifiedQuantityMax(row) {
+        return row.reportQuantity - row.qualifiedQuantity;
       }
       }
     }
     }
   };
   };