style:修复甘特图保存后弹框报错

pull/1/head
黄伟杰 4 weeks ago
parent 0ac051e4fc
commit 7574ca1324

@ -492,6 +492,11 @@ const movePlanDataToDevice = (task: any, targetDeviceTaskId: string | number, so
} }
const normalizeDeviceChildren = (deviceTaskId: string | number, priorityTaskId?: string | number) => { const normalizeDeviceChildren = (deviceTaskId: string | number, priorityTaskId?: string | number) => {
try {
gantt.getTask(deviceTaskId)
} catch {
return
}
const childTaskIds = gantt.getChildren(deviceTaskId) const childTaskIds = gantt.getChildren(deviceTaskId)
if (!Array.isArray(childTaskIds) || !childTaskIds.length) return if (!Array.isArray(childTaskIds) || !childTaskIds.length) return
const childTasks = childTaskIds const childTasks = childTaskIds
@ -513,28 +518,32 @@ const normalizeDeviceChildren = (deviceTaskId: string | number, priorityTaskId?:
} }
const refreshPlanLinksByRowOrder = () => { const refreshPlanLinksByRowOrder = () => {
const allLinks = gantt.getLinks() try {
allLinks.forEach((item: any) => gantt.deleteLink(item.id)) const allLinks = gantt.getLinks()
let linkIndex = 1 allLinks.forEach((item: any) => gantt.deleteLink(item.id))
const deviceTaskIds = gantt.getChildren(0) let linkIndex = 1
deviceTaskIds.forEach((deviceTaskId: string | number) => { const deviceTaskIds = gantt.getChildren(0)
const childTaskIds = gantt.getChildren(deviceTaskId).filter((childId: string | number) => { deviceTaskIds.forEach((deviceTaskId: string | number) => {
const task = gantt.getTask(childId) try {
return !!task?._planData const childTaskIds = gantt.getChildren(deviceTaskId).filter((childId: string | number) => {
}) const task = gantt.getTask(childId)
let previousTaskId: string | number | null = null return !!task?._planData
childTaskIds.forEach((taskId: string | number) => {
if (previousTaskId !== null) {
gantt.addLink({
id: `link-${linkIndex++}`,
source: previousTaskId,
target: taskId,
type: '0'
}) })
} let previousTaskId: string | number | null = null
previousTaskId = taskId 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) => { const getDeviceInsertIndex = (deviceTaskId: string | number, startDate: dayjs.Dayjs) => {
@ -672,8 +681,8 @@ const applyTaskAdjust = (task: any, targetDeviceTaskId: string | number, startDa
syncPlanTimeFromTask(task) syncPlanTimeFromTask(task)
normalizeDeviceChildren(targetDeviceTaskId, task.id) normalizeDeviceChildren(targetDeviceTaskId, task.id)
if (sourceDeviceTaskId && sourceDeviceTaskId !== targetDeviceTaskId) { if (sourceDeviceTaskId && sourceDeviceTaskId !== targetDeviceTaskId) {
normalizeDeviceChildren(sourceDeviceTaskId)
removeDeviceFromGanttIfNoCurrent(sourceDeviceTaskId) removeDeviceFromGanttIfNoCurrent(sourceDeviceTaskId)
normalizeDeviceChildren(sourceDeviceTaskId)
} }
refreshPlanLinksByRowOrder() refreshPlanLinksByRowOrder()
refreshTimelineRangeByTasks() refreshTimelineRangeByTasks()

Loading…
Cancel
Save