From 749cb2f4ad815c5a68c19fe961d5ca2149a84dd4 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期四, 17 九月 2026 11:28:54 +0800
Subject: [PATCH] feat(mes): 新增员工排班明细页面,修复计划排程菜单404

---
 src/views/mes/pro/task/components/gantt-chart.vue |   48 +++++++++++++++++++++++++++++++-----------------
 1 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/src/views/mes/pro/task/components/gantt-chart.vue b/src/views/mes/pro/task/components/gantt-chart.vue
index d889324..8f67c32 100644
--- a/src/views/mes/pro/task/components/gantt-chart.vue
+++ b/src/views/mes/pro/task/components/gantt-chart.vue
@@ -1,7 +1,7 @@
-<script lang="ts" setup>
+锘�<script lang="ts" setup>
 import { onBeforeUnmount, onMounted, ref, watch } from 'vue';
 
-import { BarcodeBizTypeEnum } from '..\..\..\..\..\packages\constants\src';
+import { BarcodeBizTypeEnum } from '@vben/constants';
 
 import { gantt } from 'dhtmlx-gantt';
 
@@ -10,10 +10,10 @@
 /**
  * 鐢樼壒鍥剧粍浠讹紙鍩轰簬 dhtmlx-gantt锛�
  *
- * 1. 鎸夊伐鍗曞垎缁勫睍绀虹敓浜т换鍔★紝宸ュ崟涓� project 琛岋紝浠诲姟涓哄瓙琛�
+ * 1. 鎸夎鍗曞垎缁勫睍绀虹敓浜т换鍔★紝璁㈠崟涓� project 琛岋紝浠诲姟涓哄瓙琛�
  * 2. 鏀寔鍙棰勮鍜屾嫋鎷界紪杈戜袱绉嶆ā寮�
  * 3. 鎷栨嫿鍚庤Е鍙� taskUpdate 浜嬩欢锛岄�氱煡鐖剁粍浠舵壒閲忎繚瀛�
- * 4. 鏃堕棿鍒诲害锛氬懆 鈫� 鏃� 鈫� 8 灏忔椂锛�1 宸ヤ綔鏃� = 8 灏忔椂锛�
+ * 4. 鏃堕棿鍒诲害锛氬懆 鈫� 鏃� 鈫� 灏忔椂
  */
 defineOptions({ name: 'GanttChart', inheritAttrs: false });
 
@@ -47,8 +47,8 @@
 
   gantt.config.readonly = props.readonly;
   gantt.config.date_format = '%Y-%m-%d %H:%i:%s';
-  gantt.config.duration_unit = 'hour'; // 鎸佺画鏃堕棿鍗曚綅涓哄皬鏃讹紝閰嶅悎 duration_step 瀹炵幇宸ヤ綔鏃ュ崟浣�
-  gantt.config.duration_step = 8; // 1 宸ヤ綔鏃� = 8 灏忔椂
+  gantt.config.duration_unit = 'hour'; // 鎸佺画鏃堕棿鍗曚綅涓哄皬鏃�
+  gantt.config.duration_step = 1; // duration 瀛楁鍗充负瀹為檯灏忔椂鏁�
   gantt.config.row_height = 36;
   gantt.config.bar_height = 24;
   gantt.config.fit_tasks = true;
@@ -70,7 +70,7 @@
   gantt.config.buttons_left = ['gantt_save_btn'];
   gantt.config.buttons_right = ['gantt_cancel_btn'];
 
-  // 鏃堕棿鍒诲害锛氬懆 > 鏃� > 8 灏忔椂
+  // 鏃堕棿鍒诲害锛氬懆 > 鏃� > 灏忔椂
   const weekScaleTemplate = (date: Date) => {
     const dateToStr = gantt.date.date_to_str('%M %d');
     const endDate = gantt.date.add(gantt.date.add(date, 1, 'week'), -1, 'day');
@@ -82,7 +82,7 @@
   gantt.config.scales = [
     { unit: 'week', step: 1, format: weekScaleTemplate },
     { unit: 'day', step: 1, format: dayTemplate, css: daysStyle },
-    { unit: 'hour', step: 8, format: '%H:%i' },
+    { unit: 'hour', step: 1, format: '%H:%i' },
   ];
   gantt.config.scale_height = 50;
   gantt.config.show_task_cells = true;
@@ -113,7 +113,7 @@
   gantt.templates.task_text = (_start: any, _end: any, task: any) => {
     const percent = Math.round((task.progress || 0) * 100);
     if (task.type === 'project') {
-      return `<b>鐢熶骇宸ュ崟:</b> ${task.text} <span>瀹屾垚姣斾緥锛�${percent}%</span>`;
+      return `<b>鐢熶骇璁㈠崟:</b> ${task.text} <span>瀹屾垚姣斾緥锛�${percent}%</span>`;
     }
     return `<b>鐢熶骇浠诲姟:</b> ${task.process || ''} ${task.text} <span>瀹屾垚姣斾緥锛�${percent}%</span>`;
   };
@@ -121,7 +121,7 @@
   gantt.templates.tooltip_text = (_start: any, _end: any, task: any) => {
     const percent = Math.round((task.progress || 0) * 100);
     if (task.type === 'project') {
-      return `<b>鐢熶骇宸ュ崟:</b> ${task.text} <span>瀹屾垚姣斾緥锛�${percent}%</span>`;
+      return `<b>鐢熶骇璁㈠崟:</b> ${task.text} <span>瀹屾垚姣斾緥锛�${percent}%</span>`;
     }
     return `<b>鐢熶骇浠诲姟:</b> ${task.process || ''} ${task.text} <span>瀹屾垚姣斾緥锛�${percent}%</span>`;
   };
@@ -135,7 +135,7 @@
   if (!props.readonly) {
     gantt.attachEvent('onAfterTaskUpdate', (id: number | string) => {
       const task = gantt.getTask(id);
-      // 鍙洖鍐� task 鑺傜偣锛岄伩鍏嶆妸宸ュ崟(project)鑺傜偣褰撴垚浠诲姟淇濆瓨
+      // 鍙洖鍐� task 鑺傜偣锛岄伩鍏嶆妸璁㈠崟(project)鑺傜偣褰撴垚浠诲姟淇濆瓨
       if (task.type !== gantt.config.types.task || !task.originalId) {
         return;
       }
@@ -168,15 +168,29 @@
     [BarcodeBizTypeEnum.WORKORDER]: 'project',
     [BarcodeBizTypeEnum.TASK]: 'task',
   };
-  gantt.parse({
-    data: tasks.map((item: any) => ({
+  const data = tasks
+    .map((item: any) => ({
       ...item,
       type: typeMap[item.type] || item.type,
       start_date: item.startDate ? new Date(item.startDate) : undefined,
       end_date: item.endDate ? new Date(item.endDate) : undefined,
-    })),
-    links: [],
-  });
+    }))
+    // 杩囨护缂哄け/闈炴硶鏃ユ湡鐨勪换鍔★紝閬垮厤 dhtmlx-gantt 璁$畻鏃堕棿杞存椂鎶� valueOf 寮傚父
+    .filter(
+      (task: any) =>
+        task.start_date instanceof Date &&
+        task.end_date instanceof Date &&
+        !Number.isNaN(task.start_date.getTime()) &&
+        !Number.isNaN(task.end_date.getTime()),
+    );
+  if (data.length === 0) {
+    return;
+  }
+  try {
+    gantt.parse({ data, links: [] });
+  } catch (error) {
+    console.error('鐢樼壒鍥炬覆鏌撳け璐ワ細', error);
+  }
 }
 
 watch(
@@ -227,7 +241,7 @@
   color: #f44;
 }
 
-/* 宸ュ崟锛坧roject锛夎鏍峰紡 */
+/* 璁㈠崟锛坧roject锛夎鏍峰紡 */
 .gantt-project-bar .gantt_task_progress {
   background: #7b68ee;
 }

--
Gitblit v1.9.3