695593266@qq.com 2 недель назад
Родитель
Сommit
7d6c9a4abe

+ 41 - 10
src/views/productionPlan/components/newFactoryProductionScheduling.vue

@@ -432,6 +432,13 @@
       normalizeId(value) {
         return value === null || value === undefined ? '' : String(value);
       },
+      normalizeBackendLongId(value) {
+        if (value === null || value === undefined || value === '') {
+          return '';
+        }
+        const text = String(value).trim();
+        return /^\d+$/.test(text) ? text : '';
+      },
       normalizeOrderQuantity(value) {
         if (value === null || value === undefined || value === '') {
           return '';
@@ -1017,10 +1024,10 @@
             assetCode:
               item.assetCode || item.deviceCode || substance.code || '',
             assetId:
-              item.assetId ||
-              item.deviceId ||
-              item.extInfo?.assetId ||
-              substance.id ||
+              this.normalizeBackendLongId(item.assetId) ||
+              this.normalizeBackendLongId(item.deviceId) ||
+              this.normalizeBackendLongId(item.extInfo?.assetId) ||
+              this.normalizeBackendLongId(substance.id) ||
               '',
             assetName:
               item.assetName || item.deviceName || substance.name || '',
@@ -1676,12 +1683,17 @@
         const deviceName =
           item.deviceName || item.equipmentName || item.assetName || '';
         const deviceCode = item.deviceCode || item.assetCode || '';
-        const deviceId = item.deviceId || deviceCode || deviceName;
+        const deviceId =
+          this.normalizeBackendLongId(item.deviceId) ||
+          this.normalizeBackendLongId(item.assetId) ||
+          this.normalizeBackendLongId(item.extInfo?.assetId);
+        const resourceId =
+          deviceId || deviceCode || deviceName || item.resourceId;
         const workstationName = item.name || item.resourceName || '';
         const workstationCode = item.workstationCode || item.code || '';
         return {
           ...item,
-          resourceId: `device:${deviceId || item.resourceId || ''}`,
+          resourceId: `device:${resourceId || ''}`,
           resourceName: deviceName || deviceCode || workstationName,
           resourceCode: deviceCode,
           deviceId,
@@ -1766,7 +1778,11 @@
           resourceType,
           workstationType,
           orderResourceTabType: item.orderResourceTabType || '',
-          deviceId: item.deviceId || '',
+          deviceId:
+            this.normalizeBackendLongId(item.deviceId) ||
+            this.normalizeBackendLongId(item.assetId) ||
+            this.normalizeBackendLongId(item.extInfo?.assetId) ||
+            '',
           deviceCode,
           deviceName,
           assigneeUser: item.assigneeUser || [],
@@ -1855,7 +1871,12 @@
                     (resourceInfo.orderResourceTabType === 'device'
                       ? resourceInfo.resourceName
                       : ''),
-                  deviceId: resource.deviceId || resourceInfo.deviceId || '',
+                  deviceId:
+                    this.normalizeBackendLongId(resource.deviceId) ||
+                    this.normalizeBackendLongId(resource.assetId) ||
+                    this.normalizeBackendLongId(resource.extInfo?.assetId) ||
+                    resourceInfo.deviceId ||
+                    '',
                   deviceCode:
                     resource.deviceCode || resourceInfo.deviceCode || '',
                   deviceName:
@@ -2183,7 +2204,12 @@
               planInfo.deviceName ||
               planInfo.assetName ||
               '',
-            deviceId: item.deviceId || planInfo.deviceId || '',
+            deviceId:
+              this.normalizeBackendLongId(item.deviceId) ||
+              this.normalizeBackendLongId(item.assetId) ||
+              this.normalizeBackendLongId(planInfo.deviceId) ||
+              this.normalizeBackendLongId(planInfo.assetId) ||
+              '',
             deviceCode: item.deviceCode || planInfo.deviceCode || '',
             deviceName: item.deviceName || planInfo.deviceName || '',
             assetName: item.assetName || planInfo.assetName || '',
@@ -2259,7 +2285,12 @@
                 item.deviceName ||
                 item.assetName ||
                 '',
-              deviceId: matchedPlanInfo.deviceId || item.deviceId || '',
+              deviceId:
+                this.normalizeBackendLongId(matchedPlanInfo.deviceId) ||
+                this.normalizeBackendLongId(matchedPlanInfo.assetId) ||
+                this.normalizeBackendLongId(item.deviceId) ||
+                this.normalizeBackendLongId(item.assetId) ||
+                '',
               deviceCode: matchedPlanInfo.deviceCode || item.deviceCode || '',
               deviceName: matchedPlanInfo.deviceName || item.deviceName || '',
               assetName: matchedPlanInfo.assetName || item.assetName || '',

+ 35 - 13
src/views/productionPlan/components/newFactoryProductionScheduling/TaskConfigPanel.vue

@@ -626,7 +626,8 @@
         dispatchRowDraftMap: {},
         dispatchAssignmentMap: {},
         dispatchToolbarLoading: false,
-        dispatchReportType: 1
+        dispatchReportType: 1,
+        suppressTaskListAssignReloadUntil: 0
       };
     },
     computed: {
@@ -815,6 +816,9 @@
           if (!hasActive) {
             this.activeTaskKey = this.dispatchTaskGroupKey(list[0]);
           }
+          if (Date.now() < this.suppressTaskListAssignReloadUntil) {
+            return;
+          }
           this.$nextTick(() => {
             this.loadDispatchAssignData();
           });
@@ -1129,6 +1133,22 @@
           '';
         return String(rawId).replace(/^(workstation|person|team):/, '');
       },
+      normalizeDispatchLongId(value) {
+        if (value === null || value === undefined || value === '') {
+          return '';
+        }
+        const text = String(value).trim();
+        return /^\d+$/.test(text) ? text : '';
+      },
+      getDispatchDeviceId(row) {
+        return (
+          this.normalizeDispatchLongId(row?.assetId) ||
+          this.normalizeDispatchLongId(row?.extInfo?.assetId) ||
+          this.normalizeDispatchLongId(row?.deviceId) ||
+          this.normalizeDispatchLongId(row?.extInfo?.deviceId) ||
+          ''
+        );
+      },
       getAssignmentTypeCode(value) {
         if (value && typeof value === 'object') {
           return value.code ?? value.value ?? value.id ?? '';
@@ -1329,6 +1349,10 @@
           (item) => this.dispatchTaskGroupKey(item) === groupKey
         );
       },
+      emitDispatchTaskListChange(eventName, row) {
+        this.suppressTaskListAssignReloadUntil = Date.now() + 300;
+        this.$emit(eventName, row);
+      },
       clearDispatchSelectionsByTaskKey(groupKey) {
         if (!this.orderDispatchStyle || !groupKey) {
           return;
@@ -1338,7 +1362,7 @@
             return;
           }
           if (task._dispatchDraft) {
-            this.$emit('remove-task-row', task);
+            this.emitDispatchTaskListChange('remove-task-row', task);
             return;
           }
           this.$set(task, 'executionTeamId', '');
@@ -1363,7 +1387,7 @@
             source
           )}-${this.dispatchObjectRowKey(row)}`
         };
-        this.$emit('add-task-row', next);
+        this.emitDispatchTaskListChange('add-task-row', next);
         return next;
       },
       clearDispatchObject(row, task = this.getDispatchRowTask(row)) {
@@ -1378,7 +1402,7 @@
         row.executionStartTime = '';
         row.executionEndTime = '';
         if (task._dispatchDraft) {
-          this.$emit('remove-task-row', task);
+          this.emitDispatchTaskListChange('remove-task-row', task);
           return;
         }
         this.$set(task, 'quantity', '');
@@ -1397,7 +1421,7 @@
           return;
         }
         if (task._dispatchDraft) {
-          this.$emit('remove-task-row', task);
+          this.emitDispatchTaskListChange('remove-task-row', task);
           return;
         }
         this.$set(task, 'quantity', '');
@@ -1489,7 +1513,7 @@
           executionEndTime: row.executionEndTime || task.executionEndTime || ''
         });
         if (task._dispatchDraft) {
-          this.$emit('remove-task-row', task);
+          this.emitDispatchTaskListChange('remove-task-row', task);
           return;
         }
         this.$set(task, 'quantity', '');
@@ -1726,12 +1750,7 @@
             assigneeName,
             measuringUnit,
             isNew: row.isNew ? row.isNew : '',
-            deviceId:
-              row.assetId ||
-              row.deviceId ||
-              row.extInfo?.assetId ||
-              row.extInfo?.assetCode ||
-              '',
+            deviceId: this.getDispatchDeviceId(row),
             deviceName:
               row.assetName || row.deviceName || row.extInfo?.assetName || '',
             workStationId: assigneeId,
@@ -1830,7 +1849,10 @@
           ...item,
           isNew: 1,
           assetCode: item.assetCode || item.extInfo?.assetCode || '',
-          assetId: item.assetId || item.extInfo?.assetId || '',
+          assetId:
+            this.normalizeDispatchLongId(item.assetId) ||
+            this.normalizeDispatchLongId(item.extInfo?.assetId) ||
+            '',
           assetName: item.assetName || item.extInfo?.assetName || ''
         }));
         this.$emit('add-dispatch-stations', {