Selaa lähdekoodia

修改任务的bug

695593266@qq.com 2 kuukautta sitten
vanhempi
commit
988fe79fb0
3 muutettua tiedostoa jossa 33 lisäystä ja 18 poistoa
  1. 22 10
      src/views/produce/components/taskReport.vue
  2. 9 6
      src/views/produce/index.vue
  3. 2 2
      vue.config.js

+ 22 - 10
src/views/produce/components/taskReport.vue

@@ -319,8 +319,6 @@
         if (form.realEndTime) {
         if (form.realEndTime) {
           this.$nextTick(() => {
           this.$nextTick(() => {
             this.form = { ...form };
             this.form = { ...form };
-            this.reportNum = form.reportQuantity ? form.reportQuantity : 0;
-            this.lossNum = form.lossQuantity ? form.lossQuantity : 0;
           });
           });
           if (type !== 'report') {
           if (type !== 'report') {
             listUpdateRealTimeRecord(row.apsAssigneeId)
             listUpdateRealTimeRecord(row.apsAssigneeId)
@@ -334,6 +332,8 @@
               });
               });
           }
           }
         }
         }
+        this.reportNum = Number(this.current.reportQuantityReported) || 0;
+        this.lossNum = Number(this.current.lossQuantityReported) || 0;
         this.getData();
         this.getData();
       },
       },
       cancel() {
       cancel() {
@@ -442,15 +442,17 @@
 
 
       // 计算数量
       // 计算数量
       calculateQuantity(type) {
       calculateQuantity(type) {
+        const taskQuantity = Number(this.current.quantity) || 0;
         const actualQuantity = this.add(this.reportNum, this.lossNum);
         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);
+        const remainingQuantity = this.sub(taskQuantity, actualQuantity);
+        const reportQuantity = Number(this.form.reportQuantity) || 0;
+        const lossQuantity = Number(this.form.lossQuantity) || 0;
+        const total = this.add(reportQuantity, lossQuantity);
         if (total > remainingQuantity) {
         if (total > remainingQuantity) {
-          this.form[type] = 0;
-          this.$message.warning('报工数量加损耗数量不能大于要求完成数量');
+          this.form[type] = '';
+          this.$message.warning(
+            `本次报工数与损耗数之和不能超过任务剩余可报数量(剩余 ${remainingQuantity})`
+          );
         }
         }
       },
       },
       // 数量正则 quantity
       // 数量正则 quantity
@@ -481,11 +483,21 @@
         // 更新绑定值
         // 更新绑定值
         this.form[type] = match ? match[0] : '';
         this.form[type] = match ? match[0] : '';
         this.calculateQuantity(type);
         this.calculateQuantity(type);
-        this.calculateQuantity(type);
       },
       },
       submitAdd() {
       submitAdd() {
         this.$refs.form.validate((valid) => {
         this.$refs.form.validate((valid) => {
           if (!valid) return;
           if (!valid) return;
+          const taskQuantity = Number(this.current.quantity) || 0;
+          const actualQuantity = this.add(this.reportNum, this.lossNum);
+          const remainingQuantity = this.sub(taskQuantity, actualQuantity);
+          const reportQuantity = Number(this.form.reportQuantity) || 0;
+          const lossQuantity = Number(this.form.lossQuantity) || 0;
+          const total = this.add(reportQuantity, lossQuantity);
+          if (total > remainingQuantity) {
+            return this.$message.warning(
+              `本次报工数与损耗数之和不能超过任务剩余可报数量(剩余 ${remainingQuantity})`
+            );
+          }
 
 
           let data = {
           let data = {
             ...this.form,
             ...this.form,

+ 9 - 6
src/views/produce/index.vue

@@ -1166,7 +1166,7 @@
         const form = this.buildForm(row);
         const form = this.buildForm(row);
 
 
         this.$nextTick(() => {
         this.$nextTick(() => {
-          this.$refs.taskReportRef.open('repoort', currentRow, form);
+          this.$refs.taskReportRef.open('report', currentRow, form);
         });
         });
       },
       },
 
 
@@ -1228,7 +1228,9 @@
           productName: row.productName,
           productName: row.productName,
           specification: row.specification,
           specification: row.specification,
           newWeightUnit: row.newWeightUnit,
           newWeightUnit: row.newWeightUnit,
-          measuringUnit: row.measuringUnit
+          measuringUnit: row.measuringUnit,
+          reportQuantityReported: row.reportQuantity || 0,
+          lossQuantityReported: row.lossQuantity || 0
         };
         };
       },
       },
 
 
@@ -1238,7 +1240,10 @@
           row.reportQuantity ? row.reportQuantity : 0,
           row.reportQuantity ? row.reportQuantity : 0,
           row.lossQuantity ? row.lossQuantity : 0
           row.lossQuantity ? row.lossQuantity : 0
         );
         );
-        const remainingQuantity = this.sub(row.formingNum, actualQuantity);
+        const remainingQuantity = Math.max(
+          this.sub(row.quantity || 0, actualQuantity),
+          0
+        );
 
 
         return {
         return {
           realStartTime: row.realStartTime,
           realStartTime: row.realStartTime,
@@ -1247,9 +1252,7 @@
           qualifiedWeight: row.qualifiedWeight,
           qualifiedWeight: row.qualifiedWeight,
           unqualifiedQuantity: row.unqualifiedQuantity,
           unqualifiedQuantity: row.unqualifiedQuantity,
           unqualifiedWeight: row.unqualifiedWeight,
           unqualifiedWeight: row.unqualifiedWeight,
-          reportQuantity: row.reportQuantity
-            ? remainingQuantity
-            : row.formingNum,
+          reportQuantity: remainingQuantity,
           lossQuantity: 0,
           lossQuantity: 0,
           remark: row.assigneeRemark
           remark: row.assigneeRemark
         };
         };

+ 2 - 2
vue.config.js

@@ -32,9 +32,9 @@ module.exports = {
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       '/api': {
       '/api': {
         // target: 'http://124.71.68.31:50001',
         // target: 'http://124.71.68.31:50001',
-        target: 'http://192.168.1.125:18086',
+        // target: 'http://192.168.1.125:18086',
         // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.251:18086',
-        // target: 'http://192.168.1.251:18186',
+        target: 'http://192.168.1.251:18186',
         // target: 'http://192.168.1.251:18086', // 开发环境
         // target: 'http://192.168.1.251:18086', // 开发环境
         // target: 'http://192.168.1.103:18086',192.168.1.116
         // target: 'http://192.168.1.103:18086',192.168.1.116
         // target: 'http://192.168.1.144:18086',
         // target: 'http://192.168.1.144:18086',