فهرست منبع

修改拆单的计划结束时间判断

695593266@qq.com 9 ماه پیش
والد
کامیت
7f57b9dfab
1فایلهای تغییر یافته به همراه76 افزوده شده و 3 حذف شده
  1. 76 3
      src/views/workOrder/components/unpackDialog.vue

+ 76 - 3
src/views/workOrder/components/unpackDialog.vue

@@ -431,13 +431,86 @@
 
       checkEndTimeValid(row) {
         const { planStartTime: start, planCompleteTime: end } = row;
+        // console.log(start, end, '时间1111');
         if (!start || !end) return; // 开始/结束时间未填,跳过
-        const startTime = new Date(start);
-        const endTime = new Date(end);
+        this.handleChange(start, end, row);
+        // const startTime = new Date(start);
+        // const endTime = new Date(end);
+        // if (endTime < startTime) {
+        //   row.planCompleteTime = new Date(startTime); // 修正为开始时间
+        //   this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
+        // }
+      },
+
+      handleChange(start, end, row) {
+        const startTime = new Date(start).getTime();
+        const endTime = new Date(end).getTime();
+        const planStartTime = new Date(this.formData.planStartTime).getTime();
+        const planEndTime = new Date(this.formData.planCompleteTime).getTime();
+
+        console.log(startTime, endTime, '1231');
+
         if (endTime < startTime) {
           row.planCompleteTime = new Date(startTime); // 修正为开始时间
-          this.$message.info('结束时间不能早于开始时间,已自动设为开始时间');
+          return this.$message.info(
+            '结束时间不能早于开始时间,已自动设为开始时间'
+          );
         }
+
+        if (planStartTime > startTime) {
+          this.$confirm('所选的开始时间小于计划开始时间, 是否继续?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          })
+            .then(() => {
+              // this.$message({
+              //   type: 'success',
+              //   message: '删除成功!'
+              // });
+            })
+            .catch(() => {
+              row.planStartTime = this.formData.planStartTime;
+              // this.form.unpackList[index].reqMoldTime =
+              //   this.formData.reqMoldTime;
+              // this.$message({
+              //   type: 'info',
+              //   message: '已取消删除'
+              // });
+            });
+        }
+
+        if (endTime > planEndTime) {
+          this.$confirm('所选的结束时间大于计划完成时间, 是否继续?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          })
+            .then(() => {
+              // this.$message({
+              //   type: 'success',
+              //   message: '删除成功!'
+              // });
+            })
+            .catch(() => {
+              row.planCompleteTime = this.formData.planCompleteTime;
+              // row.planStartTime = this.formData.planStartTime;
+              // this.form.unpackList[index].reqMoldTime =
+              //   this.formData.reqMoldTime;
+              // this.$message({
+              //   type: 'info',
+              //   message: '已取消删除'
+              // });
+            });
+        }
+
+        // if (startTime > base) {
+        //   this.compareResult = '选择的时间比默认值晚';
+        // } else if (startTime < base) {
+        //   this.compareResult = '选择的时间比默认值早';
+        // } else {
+        //   this.compareResult = '选择的时间等于默认值';
+        // }
       },
 
       // 【开始时间变化时】触发