Преглед изворни кода

Merge branch 'test' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-mes into dengfei

695593266@qq.com пре 11 месеци
родитељ
комит
cb40863fca
1 измењених фајлова са 78 додато и 37 уклоњено
  1. 78 37
      src/views/produceOrder/components/releaseDialog/index.vue

+ 78 - 37
src/views/produceOrder/components/releaseDialog/index.vue

@@ -411,7 +411,8 @@
           { label: '计划结束时间:', prop: 'planCompleteTime' }
         ],
         shiftList: [],
-        dateValue: ''
+        dateValue: '',
+        dispatchType:1
       };
     },
     computed: {
@@ -543,6 +544,8 @@
     },
     watch: {},
     created() {
+      this.dispatchType = this.current.singleReport;
+      console.log(this.current,'1111111')
       this.workCenterData();
       this.getClassesData();
       this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
@@ -599,13 +602,17 @@
             produceRoutingId: this.current.produceRoutingId
           };
           let existRes = await listByMesWorkOrder(params); // 存在的工序数据
+          console.log(existRes, 'existRes ++++++');
           let res = [];
           if (!existRes || existRes.length === 0) {
             res = allRes;
           } else {
             // 先将 存在的工序数据 数组的 id 存入 Set
             const existIds = new Map(
-              existRes.map((item) => [item.taskId, true])
+              existRes.map((item) => [
+                item.assignees.length ? item.taskId : null,
+                true
+              ])
             );
             // 过滤 全部工序数据 数组
             // res = allRes.map((aItem) => !existIds.has(aItem.sourceTaskId));
@@ -639,10 +646,12 @@
               isSpecialField: item.isSpecialField,
               radioBun: {
                 // 指派按钮的操作状态 绑定 默认false(可操作)
-                stationDis: false,
-                staffDis: false,
-                lineDis: false
-              }
+                stationDis: false, // 工位按钮
+                staffDis: false, // 人员按钮
+                lineDis: false // 产线按钮
+              },
+              startDate: '', // 开始日期 (当前工序中最早的计划开始时间)
+              endDate: '' // 结束日期 (当前工序中最晚的计划结束时间)
             };
             list.push(obj);
           });
@@ -656,7 +665,7 @@
         }
       },
       // 选择工作中心
-      changeWork(e) {
+      async changeWork(e) {
         this.form.workCenterId = e;
         // this.changeDispatch(); // 查询工序列表
         let data = this.workCenterList.find((item) => item.id == e);
@@ -664,7 +673,15 @@
         this.teamList = data.teamList || [];
         if (this.teamList.length > 0) {
           this.form.teamId = this.teamList[0].id;
-          this.changeGroups(this.teamList[0].id);
+          await this.changeGroups(this.teamList[0].id);
+        } else {
+          // 如果没有 班组数据 将人员数据清空 并且判断
+          this.crewList = [];
+          this.form.teamId = '';
+          let data = this.processList.find((item) => item.id == this.processId);
+          if (data.assignType == 2) {
+            this.$set(data, 'list', []);
+          }
         }
       },
       // 选择班组 查询人员的数据
@@ -674,24 +691,24 @@
         try {
           const res = await listUserByIds([e]);
           this.crewList = res || [];
-          // 查看当前的工序数据是不是 选择的人员 是的话同步更改
-          // if (this.form.taskAss == 1) {
-          //   return;
-          // }
           if (!this.processId || this.processId == 0) {
             return;
           }
-          let data = this.processList.find(
-            (item) => item.id === this.processId
-          );
-          if (data.assignType == 2) {
-            this.handleClick({ name: this.processId });
-            // this.$set(data, 'list', res);
-          }
+          this.handleClick({ name: this.processId });
+          this.btnInit();
         } catch {
           this.crewList = [];
         }
       },
+      // 工序按钮初始化
+      btnInit() {
+        let data = this.processList.find((item) => item.id == this.processId);
+        this.$set(data.radioBun, 'lineDis', false);
+        this.$set(data.radioBun, 'staffDis', false);
+        this.$set(data.radioBun, 'stationDis', false);
+        this.$set(data, 'assignName', '工位');
+        this.$set(data, 'assignType', 1);
+      },
       // 获取产线数据
       async getProductionData() {
         const res = await lineByCurrentUser(this.form.workCenterId);
@@ -765,16 +782,6 @@
             flag = false;
             return;
           }
-          // if (item.quantity == 0) {
-          //   this.$message.warning('请检查所选数据的数量不能为0');
-          //   digit = false;
-          //   return;
-          // }
-          // if (item.weight == 0) {
-          //   this.$message.warning('请检查所选数据的重量不能为0');
-          //   digit = false;
-          //   return;
-          // }
           let Aobj = {
             assigneeId: item.id,
             quantity: item.quantity,
@@ -790,10 +797,6 @@
           assignees.push(Aobj);
           changeIds.push(item.changeId);
         });
-        // 校验没过 就不往下进行
-        // if (!digit) {
-        //   return;
-        // }
         if (!flag) {
           this.$message.warning(
             '请将所选数据的 数量 ,开始时间,完成时间 填写完毕'
@@ -806,6 +809,8 @@
           data = changeIds;
         } else {
           data = {
+            dispatchMethod: 0,
+            dispatchType:this.dispatchType,
             taskId: this.processId,
             taskName: row.name,
             taskCode: row.code,
@@ -850,13 +855,11 @@
         this.getAssignData(row.index, arr);
       },
       // 工序选择
-      handleClick(tab) {
+      async handleClick(tab) {
         let id = tab.name;
         this.processId = id;
         let data = this.processList.find((item) => item.id == this.processId);
-        // if (data.list.length == 0) {
-        this.changeRadio(data.assignType, data.index);
-        // }
+        await this.changeRadio(data.assignType, data.index);
       },
       // 指派选择
       changeRadio(e, index) {
@@ -879,6 +882,10 @@
       async getAssignData(index, arr) {
         let list = JSON.parse(JSON.stringify(arr));
         let dataRow = this.processList[index];
+        // 不存在 班组数据的话 就不调用这个方法
+        if (!this.form.teamId) {
+          return;
+        }
         let params = {
           workOrderId: this.current.apsWorkOrderId,
           workCenterId: this.form.workCenterId,
@@ -971,11 +978,45 @@
             listArr[idx].weight = item.weight;
             listArr[idx].changeId = item.id;
             listArr[idx].teamTimeDetailId = item.teamTimeDetailId;
+            this.compareAndSetTime(listArr[idx], dataRow);
+            this.compareEndSetTime(listArr[idx], dataRow);
           }
         });
         this.$set(dataRow, 'list', listArr);
         this.$set(dataRow, 'radioBun', radioBun);
       },
+      // 时间比较与赋值方法 开始时间
+      compareAndSetTime(data, dataRow) {
+        // 如果startDate为空,直接赋值为startTime
+        if (!dataRow.startDate) {
+          dataRow.startDate = data['startTime'];
+          return;
+        }
+
+        // 转换为Date对象进行比较
+        const startTimeDate = new Date(data['startTime']);
+        const startDateDate = new Date(dataRow.startDate);
+
+        // 比较时间(getTime()获取时间戳)
+        if (startTimeDate.getTime() < startDateDate.getTime()) {
+          dataRow.startDate = data['startTime'];
+        }
+      },
+      // 时间比较与赋值方法 结束时间时间
+      compareEndSetTime(data, dataRow) {
+        // 如果startDate为空,直接赋值为endTime
+        if (!dataRow.endDate) {
+          dataRow.endDate = data['endTime'];
+          return;
+        }
+        // 转换为Date对象进行比较
+        const endTimeDate = new Date(data['endTime']);
+        const endDateDate = new Date(dataRow.endDate);
+        // 比较时间(getTime()获取时间戳)
+        if (endTimeDate.getTime() > endDateDate.getTime()) {
+          dataRow.endDate = data['endTime'];
+        }
+      },
       assignRadio(e) {},
       // 数量正则 quantity
       handleQuantityInput(e, row, item) {