Răsfoiți Sursa

完善派单功能

jingshuyong 11 luni în urmă
părinte
comite
358fe210ab

+ 9 - 0
src/api/mainData/index.js

@@ -166,3 +166,12 @@ export async function getTaskIdByInstanceId(taskInstanceId) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+
+// 根据工厂查询班次
+export async function listByFactoryId(factoryId) {
+  const res = await request.get(`main/teamtime/listByFactoryId/${factoryId}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 91 - 83
src/views/workOrder/components/releaseDialog.vue

@@ -251,13 +251,17 @@
                   @input="(e) => handleWeightInput(e, row, item)"
                 ></el-input>
               </template>
-              <template v-slot:classes>
-                <el-select v-model="row.classes" clearable placeholder="请选择">
+              <template v-slot:teamTimeDetailId="{ row }">
+                <el-select
+                  v-model="row.teamTimeDetailId"
+                  placeholder="班次"
+                  @change="(e) => shiftSelection(e, row)"
+                >
                   <el-option
-                    v-for="item in options"
-                    :key="item.value"
-                    :label="item.label"
-                    :value="item.value"
+                    v-for="item in shiftList"
+                    :key="item.id"
+                    :label="item.name"
+                    :value="item.id"
                   >
                   </el-option>
                 </el-select>
@@ -338,7 +342,8 @@
     listAssign,
     checkAssignConfirm,
     resetAssignee,
-    listByRoutingIds
+    listByRoutingIds,
+    listByFactoryId
   } from '@/api/mainData/index.js';
   import { releaseWorkOrder } from '@/api/workOrder/index.js';
   export default {
@@ -393,28 +398,8 @@
           { label: '计划开始时间:', prop: 'planStartTime' },
           { label: '计划结束时间:', prop: 'planCompleteTime' }
         ],
-        options: [
-          {
-            value: '选项1',
-            label: '黄金糕'
-          },
-          {
-            value: '选项2',
-            label: '双皮奶'
-          },
-          {
-            value: '选项3',
-            label: '蚵仔煎'
-          },
-          {
-            value: '选项4',
-            label: '龙须面'
-          },
-          {
-            value: '选项5',
-            label: '北京烤鸭'
-          }
-        ]
+        shiftList: [],
+        dateValue: ''
       };
     },
     computed: {
@@ -501,34 +486,6 @@
               return row.status.desc || '';
             }
           },
-          // {
-          //   prop: 'name',
-          //   label: '名称',
-          //   align: 'center',
-          //   showOverflowTooltip: true,
-          //   width: 180
-          // },
-          // {
-          //   prop: 'model',
-          //   label: '型号',
-          //   align: 'center',
-          //   showOverflowTooltip: true,
-          //   width: 180
-          // },
-          // {
-          //   prop: 'specifications',
-          //   label: '规格',
-          //   align: 'center',
-          //   showOverflowTooltip: true,
-          //   width: 180
-          // },
-          // {
-          //   prop: 'brandNumber',
-          //   label: '牌号',
-          //   align: 'center',
-          //   showOverflowTooltip: true,
-          //   width: 180
-          // },
           {
             slot: 'quantity',
             prop: 'quantity',
@@ -546,8 +503,8 @@
             width: 140
           },
           {
-            slot: 'classes',
-            prop: 'classes',
+            slot: 'teamTimeDetailId',
+            prop: 'teamTimeDetailId',
             label: '班次',
             align: 'center',
             showOverflowTooltip: true,
@@ -584,32 +541,51 @@
     watch: {},
     created() {
       this.workCenterData();
+      this.getClassesData();
       this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
+      this.dateValue = this.getFormattedDate();
     },
     methods: {
+      // 查询班次
+      getClassesData() {
+        if (!this.current.factoriesId) return;
+        listByFactoryId(this.current.factoriesId).then((res) => {
+          if (!res) return;
+          this.shiftList = res;
+        });
+      },
+      // 选中班次
+      shiftSelection(e, row) {
+        let data = this.shiftList.find((item) => item.id == e);
+        let startTime = `${this.dateValue} ${data.startTime}`;
+        let endTime = `${this.dateValue} ${data.endTime}`;
+        this.$set(row, 'startTime', startTime);
+        this.$set(row, 'endTime', endTime);
+      },
+      // 获取当前年月日
+      getFormattedDate() {
+        const now = new Date();
+        const year = now.getFullYear();
+        const month = String(now.getMonth() + 1).padStart(2, '0');
+        const date = String(now.getDate()).padStart(2, '0');
+        return `${year}-${month}-${date}`;
+      },
+      // 查询工作中心
       async workCenterData() {
         // const res = await listWorkCenter(this.current.firstTaskId);
-        const res = await listWorkCenter(this.current.taskInstanceId);
+        const res = await listWorkCenter(this.current.firstTaskId);
         this.workCenterList = res;
         if (res.length > 0) {
           this.form.factoryName = res[0].factoryName;
           this.form.workCenterId = res[0].id;
           // 查首工序
-          this.changeWork(res[0].id); // 选择工作中心
+          await this.changeWork(res[0].id); // 选择工作中心
           this.getProductionData(res[0].id); // 查询产线
           this.FirstTaskIdFn(); // 查询工位数据
         }
       },
       // 查询工序列表数据
       changeDispatch(e) {
-        console.log('请求了这里 11');
-        // if (e == 1) {
-        //   return;
-        // }
-        // if (!this.form.workCenterId) {
-        //   this.$message.warning('请先选择工作中心');
-        //   return;
-        // }
         this.tabsLoading = true;
         // listByWorkCenter(this.form.workCenterId)
         listByRoutingIds([this.current.produceRoutingId])
@@ -645,6 +621,7 @@
                 selection: [], // 当前工序下面的指派 选中的数据
                 code: item.code, // 工序 编码
                 index: index, // 当前工序数据的下标
+
                 radioBun: {
                   // 指派按钮的操作状态 绑定 默认false(可操作)
                   stationDis: false,
@@ -673,15 +650,23 @@
           });
       },
       // 选择工作中心
-      changeWork(e) {
+      async changeWork(e) {
         this.form.workCenterId = e;
         // this.changeDispatch(); // 查询工序列表
         let data = this.workCenterList.find((item) => item.id == e);
         this.form.workCenterName = data.name;
-        this.teamList = data.teamList || [];
+        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', []);
+          }
         }
       },
       // 选择班组 查询人员的数据
@@ -692,12 +677,13 @@
           const res = await listUserByIds([e]);
           this.crewList = res || [];
           // 查看当前的工序数据是不是 选择的人员 是的话同步更改
-          if (this.form.taskAss == 1) {
+          if (!this.processId || this.processId == 0) {
             return;
           }
           let data = this.processList.find((item) => item.id == this.processId);
           if (data.assignType == 2) {
-            this.$set(data, 'list', res);
+            this.handleClick({ name: this.processId });
+            // this.$set(data, 'list', res);
           }
         } catch {
           this.crewList = [];
@@ -711,7 +697,7 @@
       // 查询工位数据
       FirstTaskIdFn() {
         // listByFirstTaskId(this.current.firstTaskId)
-        listByFirstTaskId(this.current.taskInstanceId)
+        listByFirstTaskId(this.current.firstTaskId)
           .then((res) => {
             this.stationList = res;
             this.changeDispatch();
@@ -782,7 +768,7 @@
             flag = false;
             return;
           }
-          assignees.push({
+          let Aobj = {
             assigneeId: item.id,
             quantity: item.quantity,
             weight: item.weight,
@@ -790,7 +776,11 @@
             endTime: item.endTime,
             assigneeType: row.assignType,
             assigneeName: item.name
-          });
+          };
+          if (item.teamTimeDetailId) {
+            Aobj.teamTimeDetailId = item.teamTimeDetailId;
+          }
+          assignees.push(Aobj);
           changeIds.push(item.changeId);
         });
         if (!flag) {
@@ -952,14 +942,15 @@
             this.$message.error(err.message);
           });
       },
-      // 工序选择
+      // 工序选择 有问题
       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(1, data.index);
-        }
+        // 传指定的指派类型
+        // if (data.list.length == 0) {
+        this.changeRadio(data.assignType, data.index);
+        // }
       },
       // 指派选择
       changeRadio(e, index) {
@@ -982,6 +973,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.id,
           workCenterId: this.form.workCenterId,
@@ -1073,6 +1068,7 @@
             listArr[idx].quantity = item.quantity;
             listArr[idx].weight = item.weight;
             listArr[idx].changeId = item.id;
+            listArr[idx].teamTimeDetailId = item.teamTimeDetailId;
           }
         });
         this.$set(dataRow, 'list', listArr);
@@ -1090,6 +1086,20 @@
         // 更新绑定值
         row.quantity = value;
         this.calculateQuantity(row, item);
+        this.bringWeight(row.quantity, row);
+      },
+      // 自动算重量
+      bringWeight(value, row) {
+        if (!this.current.formingWeight) {
+          this.$set(row, 'weight', 0);
+          return;
+        }
+        let weight =
+          (this.current.formingWeight / this.current.formingNum) * value;
+        if (weight > 0) {
+          weight = weight.toFixed(4) - 0;
+        }
+        this.$set(row, 'weight', weight);
       },
       calculateQuantity(row, item) {
         // 如果没有该字段 就不做判断
@@ -1119,8 +1129,6 @@
             total = total + (el.weight - 0);
           }
         });
-        console.log(total, 'total');
-        console.log(this.current, 'this.current');
         if (total > this.current.formingWeight - 0) {
           this.$message.warning('列表数量相加不能大于目标要求生产数量');
           row.weight = 0;

+ 33 - 25
src/views/workOrder/index.vue

@@ -121,22 +121,15 @@
                 row.status == 8)
             "
           >
-            派单
-          </el-link>
-          -->
+            派单12
+          </el-link> -->
+
           <el-link
             type="primary"
             :underline="false"
             icon="el-icon-truck"
             @click="toReleaseOpen(row)"
-            v-if="
-              (row.isSplit != 1 &&
-                clientEnvironmentId != '4' &&
-                row.status == 8) ||
-              (clientEnvironmentId == '4' &&
-                !row.productName.includes('板材') &&
-                row.status == 8)
-            "
+            v-if="dispatchPermission(row)"
           >
             派单
           </el-link>
@@ -341,6 +334,21 @@
       };
     },
     computed: {
+      dispatchPermission() {
+        return (row) => {
+          if (!row.firstTaskId) {
+            return false;
+          }
+          return (
+            (row.isSplit != 1 &&
+              this.clientEnvironmentId != '4' &&
+              row.status == 8) ||
+            (this.clientEnvironmentId == '4' &&
+              !row.productName.includes('板材') &&
+              row.status == 8)
+          );
+        };
+      },
       teamId() {
         return this.$store.state.user.info.teamId;
       },
@@ -690,20 +698,20 @@
       },
       //派单
       toReleaseOpen(row) {
-        getTaskIdByInstanceId(row.firstTaskId)
-          .then((res) => {
-            if (res) {
-              this.dispatchRow = { ...row };
-              this.dispatchRow.initialWeight = row.formingWeight
-                ? row.formingWeight + row.newWeightUnit
-                : '';
-              this.dispatchRow.taskInstanceId = res;
-              this.dispatchVisible = true;
-            }
-          })
-          .catch((err) => {
-            this.$message.error(err.message);
-          });
+        this.dispatchRow = { ...row };
+        console.log(row,'row ----')
+        this.dispatchRow.initialWeight = row.formingWeight
+          ? row.formingWeight + row.newWeightUnit
+          : '';
+        this.dispatchVisible = true;
+        // getTaskIdByInstanceId(row.firstTaskId)
+        //   .then((res) => {
+        //     if (res) {
+        // }
+        // })
+        // .catch((err) => {
+        //   this.$message.error(err.message);
+        // });
       },
 
       createSuccess() {