695593266@qq.com 1 неделя назад
Родитель
Сommit
f632bdd0b1

+ 2 - 2
src/views/productionPlan/components/gantt/project-gantt.constants.js

@@ -2,8 +2,8 @@ export const DAY_MS = 24 * 60 * 60 * 1000;
 
 export const RESOURCE_TABS = Object.freeze([
   { key: 'factory', label: '工厂' },
-  { key: 'team', label: '班组' },
-  { key: 'line', label: '产线' }
+  { key: 'team', label: '班组' }
+  // { key: 'line', label: '产线' }
 ]);
 
 export const WEEK_MAP = Object.freeze([

+ 20 - 1
src/views/productionPlan/components/gantt/project-gantt.vue

@@ -1475,6 +1475,24 @@
           end_date: this.formatGanttRenderDate(renderEnd)
         };
       },
+      getGanttTaskStartTime(task) {
+        const start = parseDate(task.rawStartDate || task.start_date);
+        return start ? start.getTime() : Number.MAX_SAFE_INTEGER;
+      },
+      sortGanttTasksByStartTime(tasks = []) {
+        return tasks
+          .map((task, index) => ({ task, index }))
+          .sort((a, b) => {
+            const startDiff =
+              this.getGanttTaskStartTime(a.task) -
+              this.getGanttTaskStartTime(b.task);
+            if (startDiff !== 0) {
+              return startDiff;
+            }
+            return a.index - b.index;
+          })
+          .map((item) => item.task);
+      },
       initData() {
         const sourceTasks = this.filteredGanttTasks;
         const parentTaskMap = sourceTasks.reduce((result, item) => {
@@ -1483,7 +1501,7 @@
           }
           return result;
         }, {});
-        this.ganttData = sourceTasks
+        const ganttData = sourceTasks
           .filter((item) => !(item.render === 'split' && !item.parent))
           .map((current) => {
             const hasHiddenParent =
@@ -1550,6 +1568,7 @@
             }
             return this.applyGanttFullDayRange(newObj);
           });
+        this.ganttData = this.sortGanttTasksByStartTime(ganttData);
 
         this.reload();
       }