diff --git a/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue b/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue index c45f4467..38f00989 100644 --- a/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue +++ b/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue @@ -492,6 +492,11 @@ const movePlanDataToDevice = (task: any, targetDeviceTaskId: string | number, so } const normalizeDeviceChildren = (deviceTaskId: string | number, priorityTaskId?: string | number) => { + try { + gantt.getTask(deviceTaskId) + } catch { + return + } const childTaskIds = gantt.getChildren(deviceTaskId) if (!Array.isArray(childTaskIds) || !childTaskIds.length) return const childTasks = childTaskIds @@ -513,28 +518,32 @@ const normalizeDeviceChildren = (deviceTaskId: string | number, priorityTaskId?: } const refreshPlanLinksByRowOrder = () => { - const allLinks = gantt.getLinks() - allLinks.forEach((item: any) => gantt.deleteLink(item.id)) - let linkIndex = 1 - const deviceTaskIds = gantt.getChildren(0) - deviceTaskIds.forEach((deviceTaskId: string | number) => { - const childTaskIds = gantt.getChildren(deviceTaskId).filter((childId: string | number) => { - const task = gantt.getTask(childId) - return !!task?._planData - }) - let previousTaskId: string | number | null = null - childTaskIds.forEach((taskId: string | number) => { - if (previousTaskId !== null) { - gantt.addLink({ - id: `link-${linkIndex++}`, - source: previousTaskId, - target: taskId, - type: '0' + try { + const allLinks = gantt.getLinks() + allLinks.forEach((item: any) => gantt.deleteLink(item.id)) + let linkIndex = 1 + const deviceTaskIds = gantt.getChildren(0) + deviceTaskIds.forEach((deviceTaskId: string | number) => { + try { + const childTaskIds = gantt.getChildren(deviceTaskId).filter((childId: string | number) => { + const task = gantt.getTask(childId) + return !!task?._planData }) - } - previousTaskId = taskId + let previousTaskId: string | number | null = null + childTaskIds.forEach((taskId: string | number) => { + if (previousTaskId !== null) { + gantt.addLink({ + id: `link-${linkIndex++}`, + source: previousTaskId, + target: taskId, + type: '0' + }) + } + previousTaskId = taskId + }) + } catch {} }) - }) + } catch {} } const getDeviceInsertIndex = (deviceTaskId: string | number, startDate: dayjs.Dayjs) => { @@ -672,8 +681,8 @@ const applyTaskAdjust = (task: any, targetDeviceTaskId: string | number, startDa syncPlanTimeFromTask(task) normalizeDeviceChildren(targetDeviceTaskId, task.id) if (sourceDeviceTaskId && sourceDeviceTaskId !== targetDeviceTaskId) { - normalizeDeviceChildren(sourceDeviceTaskId) removeDeviceFromGanttIfNoCurrent(sourceDeviceTaskId) + normalizeDeviceChildren(sourceDeviceTaskId) } refreshPlanLinksByRowOrder() refreshTimelineRangeByTasks()