Kaynağa Gözat

派单功能优化

jingshuyong 11 ay önce
ebeveyn
işleme
067e8132f1

+ 17 - 3
src/api/mainData/index.js

@@ -151,7 +151,10 @@ export async function checkAssignConfirm(params) {
 
 // 获取工序的工作中心和班组列表
 export async function listByRoutingIds(data) {
-  const res = await request.post(`/main/producerouting/taskinstance/listByRoutingIds`, data);
+  const res = await request.post(
+    `/main/producerouting/taskinstance/listByRoutingIds`,
+    data
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -160,7 +163,9 @@ export async function listByRoutingIds(data) {
 
 // 根据任务实例id查询工序id
 export async function getTaskIdByInstanceId(taskInstanceId) {
-  const res = await request.get(`/main/producetask/getTaskIdByInstanceId/${taskInstanceId}`);
+  const res = await request.get(
+    `/main/producetask/getTaskIdByInstanceId/${taskInstanceId}`
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -174,4 +179,13 @@ export async function listByFactoryId(factoryId) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}
+}
+
+// 查询是否派单
+export async function checkExists(params) {
+  const res = await request.get(`/aps/assign/checkExists`, { params });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 99 - 17
src/views/workOrder/components/releaseDialog.vue

@@ -80,8 +80,8 @@
           <el-form-item label="报工类型:" required>
             <el-radio-group v-model="form.singleReport">
               <!-- v-if="clientEnvironmentId != 2" -->
-              <el-radio :label="1">单件报工</el-radio>
-              <el-radio :label="0">批量报工</el-radio>
+              <el-radio :label="1" :disabled="singleDis">单件报工</el-radio>
+              <el-radio :label="0" :disabled="batchDis">批量报工</el-radio>
             </el-radio-group>
           </el-form-item>
         </el-row>
@@ -89,7 +89,7 @@
           <el-form-item label="派单方式:" prop="taskAss">
             <!-- @change="changeDispatch" -->
             <el-radio-group v-model="form.taskAss">
-              <el-radio :label="1">生产订单派单</el-radio>
+              <el-radio :label="1" :disabled="orderDis">生产订单派单</el-radio>
               <el-radio :label="0" :disabled="procTaskDis"
                 >工序任务派单</el-radio
               >
@@ -253,6 +253,7 @@
               </template>
               <template v-slot:teamTimeDetailId="{ row }">
                 <el-select
+                  :disabled="permissions(row)"
                   v-model="row.teamTimeDetailId"
                   placeholder="班次"
                   @change="(e) => shiftSelection(e, row)"
@@ -343,7 +344,8 @@
     checkAssignConfirm,
     resetAssignee,
     listByRoutingIds,
-    listByFactoryId
+    listByFactoryId,
+    checkExists
   } from '@/api/mainData/index.js';
   import { releaseWorkOrder } from '@/api/workOrder/index.js';
   export default {
@@ -399,7 +401,11 @@
           { label: '计划结束时间:', prop: 'planCompleteTime' }
         ],
         shiftList: [],
-        dateValue: ''
+        dateValue: '',
+        orderDis: false, // 生产订单派单
+        singleDis: false, // 单个报工
+        batchDis: false, // 批量报工
+        isDispatchRow: {}
       };
     },
     computed: {
@@ -540,8 +546,9 @@
     },
     watch: {},
     created() {
-      this.workCenterData();
-      this.getClassesData();
+      this.workCenterData(); // 查询工作中心
+      this.getClassesData(); // 查询班次
+      this.queryCheckExists(); // 查询是否派单
       this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
       this.dateValue = this.getFormattedDate();
     },
@@ -562,6 +569,42 @@
         this.$set(row, 'startTime', startTime);
         this.$set(row, 'endTime', endTime);
       },
+      // 查询是否派单
+      queryCheckExists() {
+        let params = {
+          workOrderId: this.current.id,
+          workCenterId: 123,
+          teamId: 345
+        };
+        checkExists(params)
+          .then((res) => {
+            if (!res) return;
+            this.isDispatchRow = res;
+            if (res.hasExists) {
+              this.form.taskAss = 0;
+              this.orderDis = true;
+              this.procTaskDis = false;
+              // 报工类型 判断
+              this.form.singleReport = res.dispatchType;
+              if (res.dispatchType == 1) {
+                this.batchDis = true;
+                this.singleDis = false;
+              } else {
+                this.singleDis = true;
+                this.batchDis = false;
+              }
+            } else {
+              this.batchDis = false;
+              this.singleDis = false;
+              this.orderDis = false;
+              this.procTaskDis = false;
+            }
+            console.log(res, '是否派单');
+          })
+          .catch((err) => {
+            this.$message.error(err.message);
+          });
+      },
       // 获取当前年月日
       getFormattedDate() {
         const now = new Date();
@@ -582,6 +625,10 @@
           await this.changeWork(res[0].id); // 选择工作中心
           this.getProductionData(res[0].id); // 查询产线
           this.FirstTaskIdFn(); // 查询工位数据
+        } else {
+          this.$message.warning(
+            `${this.current.firstTaskName}工序没有工作中心,请到主数据工序管理维护工序信息!`
+          );
         }
       },
       // 查询工序列表数据
@@ -757,17 +804,23 @@
         }
         let assignees = [];
         let changeIds = [];
-        let flag = true;
+        let flag = true; // 是否填写 校验
+        let digit = true; // 数字校验
         row.selection.forEach((item) => {
-          if (
-            !item.quantity ||
-            !item.weight ||
-            !item.startTime ||
-            !item.endTime
-          ) {
+          if (!item.quantity || !item.startTime || !item.endTime) {
             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,
@@ -783,9 +836,13 @@
           assignees.push(Aobj);
           changeIds.push(item.changeId);
         });
+        // 校验没过 就不往下进行
+        if (!digit) {
+          return;
+        }
         if (!flag) {
           this.$message.warning(
-            '请将所选数据的 数量,重量,开始时间,完成时间 填写完毕'
+            '请将所选数据的 数量,开始时间,完成时间 填写完毕'
           );
           return;
         }
@@ -803,8 +860,14 @@
             workCenterId: this.form.workCenterId,
             workCenterName: this.form.workCenterName,
             workOrderId: this.current.id,
+            dispatchMethod: 0,
             assignees
           };
+          if (this.isDispatchRow.hasExists) {
+            data.dispatchType = this.isDispatchRow.dispatchType;
+          } else {
+            data.dispatchType = this.form.singleReport;
+          }
         }
         const api =
           type == 1 ? taskAssignment : type == 2 ? taskRevoked : taskSave;
@@ -815,6 +878,8 @@
               this.$message.success('操作成功');
               // 更改当前表格数据
               this.setCurrentTab(row);
+              // 查询是否派单
+              this.queryCheckExists();
             }
           })
           .catch((err) => {
@@ -839,10 +904,13 @@
       },
       // 最后提交
       async confirm() {
-        if (!this.form.singleReport) {
+        if (this.form.singleReport != 1 && this.form.singleReport != 0) {
           this.$message.warning('请先选择报工类型');
           return;
         }
+        // if (!this.form.singleReport) {
+
+        // }
         if (!this.form.teamId) {
           this.$message.warning('请先选择班组');
           return;
@@ -866,11 +934,25 @@
             dispatchArr.push(item.id);
           }
         });
+        // 判断是否进行首工序派单
         if (!isFirstDispatch) {
           this.$message.warning(`请您先进行首工序任务(${data.name}工序)派单`);
           this.handleClick({ name: data.id });
           return;
         }
+        let totalSum = 0;
+        // 判断派单的数据 数量相加是否为 要求生产数量
+        data.list.map((item) => {
+          if (item.status && item.status.code == 1) {
+            totalSum += item.quantity - 0;
+          }
+        });
+        if (totalSum != this.current.formingNum - 0) {
+          this.$message.warning(
+            `已派单的数据数量相加需要等于要求生产数量${this.current.formingNum}`
+          );
+          return;
+        }
         let params = {
           teamId: this.form.teamId,
           workCenterId: this.form.workCenterId,
@@ -910,7 +992,7 @@
             !this.form.workstationIds ||
             this.form.workstationIds.length == 0
           ) {
-            this.$message.warning('请选择工位');
+            this.$message.warning('请选择工位数据');
             return;
           }
         }

+ 1 - 0
src/views/workOrder/components/unpackDialog.vue

@@ -383,6 +383,7 @@
             } else {
               this.$nextTick(() => {
                 this.$set(this.form.unpackList[index], 'formingNum', 0);
+                // 
               });
               this.$message.error('拆单数超过生产数量');