Преглед на файлове

修改任务报工的bug

695593266@qq.com преди 5 месеца
родител
ревизия
050e21c598

+ 1 - 1
src/views/produce/components/qualityInspection/index.vue

@@ -119,7 +119,7 @@
             minWidth: 150
           },
           {
-            prop: 'workstationName',
+            prop: 'assignObjectName',
             label: '工位名称',
             align: 'center',
             showOverflowTooltip: true,

+ 43 - 34
src/views/produce/components/taskDialog/index.vue

@@ -50,12 +50,12 @@
         >
         </el-date-picker>
       </template>
-      <template v-slot:qualifiedQuantity="{ row }">
+      <template v-slot:reportQuantity="{ row }">
         <el-input
-          v-model="row.qualifiedQuantity"
+          v-model="row.reportQuantity"
           placeholder="请输入"
           type="number"
-          @input="(e) => handleQuantityInput(e, 'qualifiedQuantity', row)"
+          @input="(e) => handleQuantityInput(e, 'reportQuantity', row)"
         ></el-input>
       </template>
       <template v-slot:qualifiedWeight="{ row }">
@@ -63,15 +63,14 @@
           v-model="row.qualifiedWeight"
           placeholder="请输入"
           type="number"
-          @input="(e) => handleWeightInput(e, 'qualifiedWeight', row)"
         ></el-input>
       </template>
-      <template v-slot:unqualifiedQuantity="{ row }">
+      <template v-slot:lossQuantity="{ row }">
         <el-input
-          v-model="row.unqualifiedQuantity"
+          v-model="row.lossQuantity"
           placeholder="请输入"
           type="number"
-          @input="(e) => handleQuantityInput(e, 'unqualifiedQuantity', row)"
+          @input="(e) => handleQuantityInput(e, 'lossQuantity', row)"
         ></el-input>
       </template>
       <template v-slot:unqualifiedWeight="{ row }">
@@ -79,7 +78,6 @@
           v-model="row.unqualifiedWeight"
           placeholder="请输入"
           type="number"
-          @input="(e) => handleWeightInput(e, 'unqualifiedWeight', row)"
         ></el-input>
       </template>
       <template v-slot:assigneeRemark="{ row }">
@@ -209,9 +207,9 @@
             showOverflowTooltip: true
           },
           {
-            slot: 'qualifiedQuantity',
-            label: '合格数量',
-            prop: 'qualifiedQuantity',
+            slot: 'reportQuantity',
+            label: '报工数',
+            prop: 'reportQuantity',
             width: 160,
             align: 'center',
             showOverflowTooltip: true
@@ -225,9 +223,9 @@
           //   showOverflowTooltip: true
           // },
           {
-            slot: 'unqualifiedQuantity',
-            label: '不合格数量',
-            prop: 'unqualifiedQuantity',
+            slot: 'lossQuantity',
+            label: '损耗数',
+            prop: 'lossQuantity',
             width: 160,
             align: 'center',
             showOverflowTooltip: true
@@ -286,7 +284,11 @@
           unqualifiedQuantity: row.unqualifiedQuantity,
           unqualifiedWeight: row.unqualifiedWeight,
           remark: row.assigneeRemark,
-          apsAssigneeId: row.id
+          apsAssigneeId: row.id,
+          reportQuantity: row.reportQuantity
+            ? row.reportQuantity
+            : row.formingNum,
+          lossQuantity: row.lossQuantity ? row.lossQuantity : 0
         };
         batchUpdateRealTimeConfirm(params).then((res) => {
           console.log(res, 'res 1111');
@@ -319,26 +321,26 @@
         if (!row.realEndTime) {
           return this.$message.warning('请选择结束时间');
         }
-        if (!row.qualifiedQuantity && row.qualifiedQuantity != 0) {
-          return this.$message.warning('请输入合格数量');
-        }
+        // if (!row.qualifiedQuantity && row.qualifiedQuantity != 0) {
+        //   return this.$message.warning('请输入合格数量');
+        // }
         // if (!row.qualifiedWeight && row.qualifiedWeight != 0) {
         //   return this.$message.warning('请输入合格重量');
         // }
-        if (!row.unqualifiedQuantity && row.unqualifiedQuantity != 0) {
-          return this.$message.warning('请输入不合格数量');
-        }
+        // if (!row.unqualifiedQuantity && row.unqualifiedQuantity != 0) {
+        //   return this.$message.warning('请输入不合格数量');
+        // }
         // if (!row.unqualifiedWeight && row.unqualifiedWeight != 0) {
         //   return this.$message.warning('请输入不合格重量');
         // }
-        if (
-          row.qualifiedQuantity - 0 + (row.unqualifiedQuantity - 0) !=
-          row.quantity - 0
-        ) {
-          return this.$message.warning(
-            `合格数量加不合格数量需要等于任务数量${row.quantity}`
-          );
-        }
+        // if (
+        //   row.qualifiedQuantity - 0 + (row.unqualifiedQuantity - 0) !=
+        //   row.quantity - 0
+        // ) {
+        //   return this.$message.warning(
+        //     `合格数量加不合格数量需要等于任务数量${row.quantity}`
+        //   );
+        // }
         // if (
         //   row.qualifiedWeight - 0 + (row.unqualifiedWeight - 0) !=
         //   row.weight - 0
@@ -356,7 +358,9 @@
           unqualifiedQuantity: row.unqualifiedQuantity,
           unqualifiedWeight: row.unqualifiedWeight,
           remark: row.assigneeRemark,
-          apsAssigneeId: row.id
+          apsAssigneeId: row.id,
+          reportQuantity: row.reportQuantity,
+          lossQuantity: row.lossQuantity
         };
         // getData
         batchUpdateRealTime([params])
@@ -409,10 +413,15 @@
       },
       // 计算数量
       calculateQuantity(row, type) {
-        let total = row.qualifiedQuantity - 0 + (row.unqualifiedQuantity - 0);
-        if (total > row.quantity) {
-          row[type] = 0;
-          this.$message.warning('合格数量加不合格数量不能大于任务数量');
+        // let total = row.qualifiedQuantity - 0 + (row.unqualifiedQuantity - 0);
+        // if (total > row.quantity) {
+        //   row[type] = 0;
+        //   this.$message.warning('合格数量加不合格数量不能大于任务数量');
+        // }
+        let total = row.reportQuantity - 0 + (row.lossQuantity - 0);
+        if (total > row.formingNum) {
+          this.form[type] = 0;
+          this.$message.warning('报工数量加损耗数量不能大于要求完成数量');
         }
       },
       // 查看修改记录

+ 69 - 30
src/views/produce/components/taskReport.vue

@@ -101,7 +101,6 @@
               v-model.number="form.reportQuantity"
               :disabled="inputDis"
               placeholder="请输入"
-              type="number"
               @input="(e) => handleQuantityInput(e, 'reportQuantity')"
             ></el-input>
           </el-form-item>
@@ -113,7 +112,6 @@
               v-model.number="form.lossQuantity"
               :disabled="inputDis"
               placeholder="请输入"
-              type="number"
               @input="(e) => handleQuantityInput(e, 'lossQuantity')"
             ></el-input>
           </el-form-item>
@@ -303,7 +301,9 @@
         },
         loadingBtn: false,
         list: [],
-        inputDis: false
+        inputDis: false,
+        reportNum: '',
+        lossNum: ''
       };
     },
     computed: {
@@ -319,6 +319,8 @@
         if (form.realEndTime) {
           this.$nextTick(() => {
             this.form = { ...form };
+            this.reportNum = form.reportQuantity ? form.reportQuantity : 0;
+            this.lossNum = form.lossQuantity ? form.lossQuantity : 0;
           });
           if (type !== 'report') {
             listUpdateRealTimeRecord(row.apsAssigneeId)
@@ -405,49 +407,86 @@
           this.$message.warning('合格重量加不合格重量不能大于任务重量');
         }
       },
+
+      getDecimalLength(num) {
+        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
+        );
+      },
+
       // 计算数量
       calculateQuantity(type) {
+        const actualQuantity = this.add(this.reportNum, this.lossNum);
+        const remainingQuantity = this.sub(
+          this.current.formingNum,
+          actualQuantity
+        );
         let total = this.form.reportQuantity - 0 + (this.form.lossQuantity - 0);
-        if (total > this.current.formingNum) {
+        if (total > remainingQuantity) {
           this.form[type] = 0;
           this.$message.warning('报工数量加损耗数量不能大于要求完成数量');
         }
       },
       // 数量正则 quantity
       handleQuantityInput(e, type) {
-        // 过滤非数字字符(包括负号)
-        let value = e.replace(/[^\d]/g, '');
-        // 限制不能以 0 开头(除非是 0 本身)
-        if (value.startsWith('0') && value.length > 1) {
-          value = value.slice(1);
+        // // 过滤非数字字符(包括负号)
+        // let value = e.replace(/[^\d]/g, '');
+        // // 限制不能以 0 开头(除非是 0 本身)
+        // if (value.startsWith('0') && value.length > 1) {
+        //   value = value.slice(1);
+        // }
+        // // 更新绑定值
+        // this.form[type] = value;
+        let newVal = e.replace(/[^\d.]/g, '');
+
+        if (newVal.startsWith('.')) {
+          newVal = '';
+        }
+
+        const firstDotIndex = newVal.indexOf('.');
+        if (firstDotIndex !== -1) {
+          newVal =
+            newVal.slice(0, firstDotIndex + 1) +
+            newVal.slice(firstDotIndex + 1).replace(/\./g, '');
         }
+
+        const match = newVal.match(/^(\d+)(\.\d{0,4})?/);
+        // this.batchForm.quantity = match ? match[0] : '';
         // 更新绑定值
-        this.form[type] = value;
+        this.form[type] = match ? match[0] : '';
+        this.calculateQuantity(type);
         this.calculateQuantity(type);
       },
       submitAdd() {
         this.$refs.form.validate((valid) => {
           if (!valid) return;
-          // if (
-          //   this.form.qualifiedQuantity -
-          //     0 +
-          //     (this.form.unqualifiedQuantity - 0) !==
-          //   this.current.quantity
-          // ) {
-          //   return this.$message.warning(
-          //     `合格数量加不合格数量要等于任务数量${this.current.quantity}`
-          //   );
-          // }
-          // if (
-          //   this.form.qualifiedWeight -
-          //     0 +
-          //     (this.form.unqualifiedWeight - 0) !==
-          //   this.current.weight
-          // ) {
-          //   return this.$message.warning(
-          //     `合格重量加不合格重量要等于任务重量${this.current.weight}`
-          //   );
-          // }
+
           let data = {
             ...this.form,
             apsAssigneeId: this.current.apsAssigneeId

+ 31 - 9
src/views/produceOrder/workReport.vue

@@ -791,6 +791,24 @@
           return true;
         }
         if (['pick', 'feed', 'job', 'work', 'workStep', 'task'].includes(t)) {
+          this.isFinalCheckProduction = false;
+          if (t == 'feed') {
+            if (!this.$store.state.user.info.workCenterIds) {
+              return this.$message.warning('该用户没有权限投料');
+            }
+
+            const isWorkCenter =
+              this.$store.state.user.info.workCenterIds.includes(
+                this.taskObj.workCenterId
+              );
+
+            if (!isWorkCenter) {
+              return this.$message.warning('该用户没有权限投料');
+            }
+          }
+
+          this.isFinalCheckProduction = true;
+
           if (this.workListIds.length == 0) {
             this.$message.warning('请选择工单列表');
             return false;
@@ -805,6 +823,19 @@
             data: [this.workOrderInfo]
           };
 
+          if (!this.$store.state.user.info.workCenterIds) {
+            return this.$message.warning('该用户没有权限报工');
+          }
+
+          const isWorkCenter =
+            this.$store.state.user.info.workCenterIds.includes(
+              this.taskObj.workCenterId
+            );
+
+          if (!isWorkCenter) {
+            return this.$message.warning('该用户没有权限报工');
+          }
+
           // let resultValue = '0';
           // await parameterGetByCode({
           //   code: 'first_article_dual_inspection_for_report'
@@ -847,15 +878,6 @@
           this.isFinalCheckProduction = true;
           // }
 
-          // const isWorkCenter =
-          //   this.$store.state.user.info.workCenterIds.includes(
-          //     this.taskObj.workCenterId
-          //   );
-
-          // if (!isWorkCenter) {
-          //   this.isFinalCheckProduction = false;
-          //   return this.$message.warning('该用户没有权限报工');
-          // }
           if (
             this.taskObj.type == 2 ||
             this.taskObj.type == 3 ||

+ 65 - 9
src/views/taskList/components/Ddtails.vue

@@ -110,7 +110,6 @@
               v-model.number="form.reportQuantity"
               :disabled="inputDis"
               placeholder="请输入"
-              type="number"
               @input="(e) => handleQuantityInput(e, 'reportQuantity')"
             ></el-input>
           </el-form-item>
@@ -122,7 +121,6 @@
               v-model.number="form.lossQuantity"
               :disabled="inputDis"
               placeholder="请输入"
-              type="number"
               @input="(e) => handleQuantityInput(e, 'lossQuantity')"
             ></el-input>
           </el-form-item>
@@ -315,7 +313,9 @@
           ]
         },
         loadingBtn: false,
-        list: []
+        list: [],
+        reportNum: '',
+        lossNum: ''
       };
     },
     computed: {
@@ -331,6 +331,8 @@
         if (form.realEndTime) {
           this.$nextTick(() => {
             this.form = { ...form };
+            this.reportNum = form.reportQuantity ? form.reportQuantity : 0;
+            this.lossNum = form.lossQuantity ? form.lossQuantity : 0;
           });
           if (type !== 'report') {
             listUpdateRealTimeRecord(row.apsAssigneeId)
@@ -419,22 +421,76 @@
       },
       // 计算数量
       calculateQuantity(type) {
+        const actualQuantity = this.add(this.reportNum, this.lossNum);
+        const remainingQuantity = this.sub(
+          this.current.formingNum,
+          actualQuantity
+        );
+
         let total = this.form.reportQuantity - 0 + (this.form.lossQuantity - 0);
-        if (total > this.current.formingNum) {
+        if (total > remainingQuantity) {
           this.form[type] = 0;
           this.$message.warning('报工数量加损耗数量不能大于要求完成数量');
         }
       },
+
+      getDecimalLength(num) {
+        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
+        );
+      },
+
       // 数量正则 quantity
       handleQuantityInput(e, type) {
         // 过滤非数字字符(包括负号)
-        let value = e.replace(/[^\d]/g, '');
-        // 限制不能以 0 开头(除非是 0 本身)
-        if (value.startsWith('0') && value.length > 1) {
-          value = value.slice(1);
+        // let value = e.replace(/[^\d]/g, '');
+        // // 限制不能以 0 开头(除非是 0 本身)
+        // if (value.startsWith('0') && value.length > 1) {
+        //   value = value.slice(1);
+        // }
+        let newVal = e.replace(/[^\d.]/g, '');
+
+        if (newVal.startsWith('.')) {
+          newVal = '';
         }
+
+        const firstDotIndex = newVal.indexOf('.');
+        if (firstDotIndex !== -1) {
+          newVal =
+            newVal.slice(0, firstDotIndex + 1) +
+            newVal.slice(firstDotIndex + 1).replace(/\./g, '');
+        }
+
+        const match = newVal.match(/^(\d+)(\.\d{0,4})?/);
+        // this.batchForm.quantity = match ? match[0] : '';
         // 更新绑定值
-        this.form[type] = value;
+        this.form[type] = match ? match[0] : '';
         this.calculateQuantity(type);
       },
       submitAdd() {

+ 18 - 18
src/views/taskList/components/ModifyRecord.vue

@@ -51,33 +51,33 @@
             showOverflowTooltip: true
           },
           {
-            label: '合格数量',
-            prop: 'qualifiedQuantity',
+            label: '报工数',
+            prop: 'reportQuantity',
             minWidth: 100,
             align: 'center',
             showOverflowTooltip: true
           },
           {
-            label: '不合格数量',
-            prop: 'unqualifiedQuantity',
-            minWidth: 100,
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            label: '合格重量(kg)',
-            prop: 'qualifiedWeight',
-            minWidth: 100,
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            label: '不合格重量(kg)',
-            prop: 'unqualifiedWeight',
+            label: '损耗数',
+            prop: 'lossQuantity',
             minWidth: 100,
             align: 'center',
             showOverflowTooltip: true
           },
+          // {
+          //   label: '合格重量(kg)',
+          //   prop: 'qualifiedWeight',
+          //   minWidth: 100,
+          //   align: 'center',
+          //   showOverflowTooltip: true
+          // },
+          // {
+          //   label: '不合格重量(kg)',
+          //   prop: 'unqualifiedWeight',
+          //   minWidth: 100,
+          //   align: 'center',
+          //   showOverflowTooltip: true
+          // },
           {
             label: '备注信息',
             prop: 'remark',

+ 18 - 7
src/views/taskList/index.vue

@@ -80,10 +80,11 @@
             @click="details('report', row)"
             v-if="
               (row.disposalStatus == '1' &&
-                row.hasFirstArtieleDualInspection == '0' &&
+                row.hasFirstArticleDualInspection == '0' &&
                 tabValue != '4') ||
-              (row.totalFirstArticleDualInspectionStatus == 2 &&
-                row.hasFirstArtieleDualInspection == '1' &&
+              (row.disposalStatus == '1' &&
+                row.totalFirstArticleDualInspectionStatus == 2 &&
+                row.hasFirstArticleDualInspection == '1' &&
                 tabValue != '4')
             "
             >报工
@@ -130,7 +131,8 @@
             v-if="
               row.disposalStatus == '1' &&
               tabValue != '4' &&
-              row.hasFirstArticleDualInspection == '1'
+              row.hasFirstArticleDualInspection == '1' &&
+              row.totalFirstArticleDualInspectionStatus != 2
             "
             >首件两检
           </el-link>
@@ -216,7 +218,10 @@
       </div>
     </el-dialog>
 
-    <qualityInspection ref="qualityInspectionRefs"></qualityInspection>
+    <qualityInspection
+      ref="qualityInspectionRefs"
+      @close="close"
+    ></qualityInspection>
 
     <nc-report ref="ncReportRef" @refreshList="reload"></nc-report>
   </div>
@@ -845,6 +850,10 @@
         }
       },
 
+      close() {
+        this.reload();
+      },
+
       reload(where) {
         this.$refs.table.reload({ page: 1, where });
       },
@@ -886,8 +895,10 @@
           qualifiedWeight: row.qualifiedWeight,
           remark: row.assigneeRemark,
           qualifiedQuantity: row.qualifiedQuantity,
-          reportQuantity: row.reportQuantity,
-          lossQuantity: row.lossQuantity
+          reportQuantity: row.reportQuantity
+            ? row.reportQuantity
+            : row.formingNum,
+          lossQuantity: row.lossQuantity ? row.lossQuantity : 0
         };
         if (this.tabValue == '4') {
           const data = {