Jelajahi Sumber

修改班组排程bug

695593266@qq.com 2 minggu lalu
induk
melakukan
8f1879ce1d

+ 22 - 3
src/views/productionPlan/components/newFactoryProductionScheduling.vue

@@ -71,6 +71,7 @@
           :height="planTableHeight"
           :page-size="20"
           :pagination-class="planPaginationClass"
+          @update:selection="handlePlanSelectionChange"
         >
           <template v-slot:action="{ row }">
             <el-link
@@ -78,7 +79,7 @@
               :underline="false"
               @click="handlePublish(row)"
             >
-              {{ isOrderScheduling ? '派单' : '布点' }}
+              布点
             </el-link>
           </template>
           <template v-slot:dotLineStatus="{ row }">
@@ -266,6 +267,7 @@
         planPickerSelection: [],
         planPickerSelectionAll: [],
         planPickerSelectionSyncing: false,
+        planTableSelectionSyncing: false,
         planTableRenderKey: 0,
         dialogRenderKey: 0,
         dotLineLoading: false,
@@ -509,6 +511,9 @@
           if (refName === 'planPickerTable') {
             this.planPickerSelectionSyncing = true;
           }
+          if (refName === 'planTable') {
+            this.planTableSelectionSyncing = true;
+          }
           setTimeout(() => {
             if (typeof table?.setSelectedRows === 'function') {
               table.setSelectedRows(rows || []);
@@ -523,6 +528,11 @@
                 this.planPickerSelectionSyncing = false;
               });
             }
+            if (refName === 'planTable') {
+              this.$nextTick(() => {
+                this.planTableSelectionSyncing = false;
+              });
+            }
           }, 0);
         });
       },
@@ -638,7 +648,17 @@
 
       // Selected plan detail
       handlePlanSelectionChange(rows) {
-        this.selection = Array.isArray(rows) ? rows : [];
+        if (this.planTableSelectionSyncing) {
+          return;
+        }
+        const nextRows = Array.isArray(rows) ? rows : [];
+        const row = nextRows[nextRows.length - 1];
+        if (!row) {
+          this.selection = [];
+          this.syncTableSelection('planTable', []);
+          return;
+        }
+        this.handlePublish(row);
       },
       resolveCurrentPlan(row) {
         if (!this.isOrderScheduling) {
@@ -1094,7 +1114,6 @@
         if (!this.isOrderScheduling) {
           return;
         }
-        // 编辑已有班组排程时,后端保存的是原始人员/工位 id。
         // 前端下拉为避免人员和工位 id 冲突,会加 person:/workstation: 前缀,
         // 所以工位选项加载完成后需要把原始 id 回填成下拉可识别的值。
         this.taskList.forEach((row) => {

+ 28 - 4
src/views/productionPlan/components/newFactoryProductionScheduling/TaskConfigPanel.vue

@@ -924,6 +924,12 @@
       getDispatchAssignment(row) {
         return this.dispatchAssignmentMap[this.getDispatchAssignmentKey(row)];
       },
+      removeDispatchAssignment(row) {
+        const key = this.getDispatchAssignmentKey(row);
+        if (key) {
+          this.$delete(this.dispatchAssignmentMap, key);
+        }
+      },
       getDispatchWorkOrderId() {
         const plan = this.currentPlan || {};
         return plan.workOrderId || plan.orderId || plan.sourceWorkOrderId || '';
@@ -976,10 +982,23 @@
         }
         return '';
       },
+      pickDispatchTeamId(groups = []) {
+        for (const group of groups) {
+          const source = group?.source || {};
+          const keys = Array.isArray(group?.keys) ? group.keys : [];
+          for (const key of keys) {
+            const value = this.normalizeDispatchSingleValue(source[key]);
+            if (value && !String(value).includes(':')) {
+              return value;
+            }
+          }
+        }
+        return '';
+      },
       getDispatchTeamId() {
         const plan = this.currentPlan || {};
         const task = this.activeTask || {};
-        return this.pickDispatchSingleValue([
+        return this.pickDispatchTeamId([
           { source: task, keys: DISPATCH_TEAM_ID_KEYS },
           { source: plan, keys: DISPATCH_TEAM_ID_KEYS }
         ]);
@@ -1001,11 +1020,10 @@
           'teamIds',
           'executionTeamId'
         ];
-        const teamId = this.pickDispatchSingleValue([
+        return this.pickDispatchTeamId([
           { source: row || {}, keys: teamIdKeys },
           { source: this.currentPlan || {}, keys: teamIdKeys }
         ]);
-        return String(teamId).includes(':') ? '' : teamId;
       },
       getDispatchTaskLeaderId(row = this.activeTask) {
         const leaderKeys = [
@@ -1127,6 +1145,9 @@
         return String(status);
       },
       canResetDispatchRow(row) {
+        if (!this.getDispatchToolbarPermissionState('reset').allowed) {
+          return false;
+        }
         const data = this.getDispatchActionRowData(row);
         if (
           data.status === null ||
@@ -1618,6 +1639,9 @@
         return !!row?.changeId && !!statusCode;
       },
       async handleDispatchRowReset(row) {
+        if (!this.validateDispatchToolbarPermission('reset')) {
+          return;
+        }
         const data = this.getDispatchActionRowData(row);
         if (!data.changeId) {
           this.$message.warning('只能对已撤回跟已保存的数据进行重置');
@@ -1627,8 +1651,8 @@
         try {
           const res = await resetAssignee(data.changeId);
           if (res) {
+            this.removeDispatchAssignment(row);
             this.clearDispatchObject(row);
-            await this.loadDispatchAssignData();
             this.$message.success('操作成功');
             this.$emit('dispatch-action-success', {
               type: 'reset',

+ 1 - 1
src/views/workOrder/index.vue

@@ -20,7 +20,7 @@
           class="ele-btn-icon"
           size="small"
           type="primary"
-          v-if="$hasPermission('aps:productionplan:scheduling‌')"
+          v-if="$hasPermission('aps:workorder:teamScheduling')"
           @click="openFactoryScheduling"
           >班组排程
         </el-button>