Переглянути джерело

feat: 请托多个工序适配

wuzh 1 місяць тому
батько
коміт
5cd07f385a

+ 6 - 1
src/views/entrust/components/goodsDetail.vue

@@ -346,7 +346,12 @@
             .then((res) => {
               this.loading.close();
               this.$message.success('收货成功');
-              this.$emit('done');
+              // 将收货上下文继续传给生产工单页,用于切换到下一工序并打开报工。
+              this.$emit('done', {
+                action: 'pleaseEntrustReceive',
+                item: this.itemData,
+                details: this.goodsList
+              });
               this.visible = false;
             })
             .catch(() => {

+ 1 - 1
src/views/produce/components/outsourcing/addPlease.vue

@@ -367,7 +367,7 @@
           let URL;
 
           const clearOrderIds = () => {
-            this.orderList.forEach((it) => (it.id = ''));
+            this.form.id = '';
           };
 
           if (type === 1 && this.form.id) {

+ 8 - 1
src/views/produce/components/outsourcing/details.vue

@@ -327,7 +327,7 @@
     <detail ref="detailsRef"></detail>
 
     <timeDialog ref="timeDialogRef"></timeDialog>
-    <goodsDetail ref="goodsDetailRef" @done="reloads"></goodsDetail>
+    <goodsDetail ref="goodsDetailRef" @done="handleGoodsDone"></goodsDetail>
 
     <Create ref="create" @refresh="reloads" />
   </div>
@@ -953,6 +953,13 @@
         });
       },
 
+      handleGoodsDone(payload) {
+        this.reloads();
+        if (payload && payload.action === 'pleaseEntrustReceive') {
+          this.$emit('pleaseEntrustReceived', payload);
+        }
+      },
+
       handleRelease(row) {
         this.$refs.releaseRef.open(row);
       },

+ 64 - 12
src/views/produce/components/outsourcing/index.vue

@@ -239,10 +239,13 @@
             <template slot="append">{{ form.measuringUnit }}</template>
           </el-input>
         </el-form-item>
-        <el-form-item label="请托工序:" prop="taskId">
+        <el-form-item label="请托工序:" prop="taskIdList">
           <el-select
-            v-model="form.taskId"
-            placeholder="请选择"
+            v-model="form.taskIdList"
+            multiple
+            filterable
+            collapse-tags
+            placeholder="请从当前工序开始连续选择"
             style="width: 260px"
             @change="taskListChange"
           >
@@ -467,7 +470,14 @@
           totalCount: [
             { required: true, message: '请输入', trigger: 'change' }
           ],
-          taskId: [{ required: true, message: '请选择', trigger: 'change' }]
+          taskIdList: [
+            {
+              type: 'array',
+              required: true,
+              message: '请选择请托工序',
+              trigger: 'change'
+            }
+          ]
         },
 
         form: {
@@ -482,6 +492,7 @@
           isLast: 0,
           describes: '',
           taskId: '',
+          taskIdList: [],
           planDeliveryTime: '',
           beEntrustedDeptName: '',
           beEntrustedFactoriesName: '',
@@ -697,15 +708,25 @@
           let { data } = res;
           if (data.length) {
             data = data.filter((item) => item.taskId != -2);
-            let arr = data.findIndex((item) =>
-              item.name ? item.sourceTaskId : item.taskId == this.form.taskId
-            );
+            const currentTaskId = this.form.taskId;
+            const arr = data.findIndex((item) => item.taskId == currentTaskId);
 
             if (arr != -1) {
               data.splice(0, arr);
             }
 
             this.pleaseNewStepsList = data;
+            const selectedTaskIds = Array.isArray(this.form.taskIdList)
+              ? this.form.taskIdList
+              : [];
+            const initialTaskIds = selectedTaskIds.length
+              ? selectedTaskIds
+              : currentTaskId
+              ? [currentTaskId]
+              : data.length
+              ? [data[0].taskId]
+              : [];
+            this.taskListChange(initialTaskIds, false);
           }
         });
       },
@@ -813,12 +834,43 @@
         this.$refs.timeDialogRef.open(this.attributeData, null, false);
       },
 
-      taskListChange() {
-        const data = this.pleaseNewStepsList.filter(
-          (it) => it.taskId == this.form.taskId
-        );
+      taskListChange(taskIdList, showWarning = true) {
+        const selected = Array.isArray(taskIdList) ? taskIdList : [];
+        if (selected.length === 0) {
+          this.form.taskIdList = [];
+          this.form.taskId = '';
+          this.form.taskIds = '';
+          this.form.taskName = '';
+          return;
+        }
+
+        const selectedIndexes = selected
+          .map((id) =>
+            this.pleaseNewStepsList.findIndex((item) => item.taskId == id)
+          )
+          .filter((index) => index >= 0);
+        if (selectedIndexes.length === 0) {
+          this.form.taskIdList = [];
+          return;
+        }
 
-        this.form.taskName = data[0].taskTypeName;
+        const endIndex = Math.max(...selectedIndexes);
+        const normalizedTasks = this.pleaseNewStepsList.slice(0, endIndex + 1);
+        const normalizedTaskIds = normalizedTasks.map((item) => item.taskId);
+        const isContinuous =
+          selectedIndexes.length === normalizedTaskIds.length &&
+          selectedIndexes.every((index) => index <= endIndex);
+
+        this.form.taskIdList = normalizedTaskIds;
+        this.form.taskId = normalizedTaskIds[0] || '';
+        this.form.taskIds = normalizedTaskIds.join(',');
+        this.form.taskName = normalizedTasks.length
+          ? normalizedTasks[0].taskTypeName
+          : '';
+
+        if (!isContinuous && showWarning) {
+          this.$message.info('请托工序必须连续,已自动补齐中间工序');
+        }
       },
 
       changeTaskId(e) {

+ 24 - 0
src/views/produceOrder/workReport.vue

@@ -220,6 +220,7 @@
                       <outsourcingDetails
                         ref="outsourcingListRef"
                         @outsourcingAdd="outsourcingAdd"
+                        @pleaseEntrustReceived="handlePleaseEntrustReceived"
                         v-if="!isStep && !isOutsource && !isPleaseEntrust"
                         :chooseType="chooseType"
                       ></outsourcingDetails>
@@ -996,6 +997,29 @@
         this.getOrderData();
         this.getTaskFn();
       },
+      /**
+       * 请托最终收货后刷新工单当前工序,并打开下一工序的报工区域。
+       * 收货生成的在制品由 jobBooking 重新查询,报工数量直接使用实际收货数量。
+       */
+      async handlePleaseEntrustReceived() {
+        try {
+          await this.getOrderData();
+          await this.getTaskFn();
+          this.isStep = false;
+          this.isOutsource = false;
+          this.isPleaseEntrust = false;
+          this.isFinalCheckProduction = true;
+          this.operationType = 'job';
+          console.info('[请托收货] 已刷新工单并打开下一工序报工', {
+            workOrderId: this.workOrderInfo.id,
+            taskId: this.workOrderInfo.taskId,
+            sourceTaskId: this.taskObj.id
+          });
+        } catch (error) {
+          console.error('[请托收货] 打开下一工序报工失败', error);
+          this.$message.error('收货成功,但打开下一工序报工失败,请重新进入工单报工');
+        }
+      },
       reloadData() {
         this.getOrderData();
         this.getTaskFn();