diff --git a/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue b/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue
index 2c0adf5f..54d20bfd 100644
--- a/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue
+++ b/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue
@@ -36,46 +36,34 @@
-
+
-
+
-
-
-
-
-
- 取消
- 确定
-
-
-
-
-
-
+
- 取消
- 确定
+ 取消
+ 确定
@@ -101,9 +89,6 @@ const message = useMessage()
const ganttContainerRef = ref()
const activePreviewDevice = ref()
const activePreviewTask = ref()
-const startDateEditorVisible = ref(false)
-const startDateEditorTaskId = ref(null)
-const startDateEditorValue = ref('')
const tooltipCleanupFns = ref<(() => void)[]>([])
const ganttEventIds = ref([])
const ganttSyncing = ref(false)
@@ -112,7 +97,7 @@ const taskAdjustTaskId = ref(null)
const taskAdjustForm = reactive({
deviceTaskId: '',
startDate: '',
- duration: 1
+ endDate: ''
})
const taskMoveFromParentMap = ref>({})
const taskDragDurationMap = ref>({})
@@ -549,15 +534,16 @@ const getDeviceInsertIndex = (deviceTaskId: string | number, startDate: dayjs.Da
return childTaskIds.length
}
-const applyTaskAdjust = (task: any, targetDeviceTaskId: string | number, startDate: string, durationValue: number) => {
+const applyTaskAdjust = (task: any, targetDeviceTaskId: string | number, startDate: string, endDate: string) => {
const targetDeviceTask = gantt.getTask(targetDeviceTaskId)
if (!targetDeviceTask || targetDeviceTask?._planData) return
const sourceDeviceTaskId = task.parent
- const nextStart = dayjs(startDate).startOf('day')
- const duration = Math.max(Number(durationValue) || 1, 1)
+ const nextStart = dayjs(startDate)
+ const nextEnd = dayjs(endDate)
+ const duration = Math.max(nextEnd.diff(nextStart, 'day') + 1, 1)
task.parent = targetDeviceTaskId
task.start_date = nextStart.toDate()
- task.end_date = nextStart.add(duration - 1, 'day').endOf('day').toDate()
+ task.end_date = nextEnd.toDate()
task.duration = duration
movePlanDataToDevice(task, targetDeviceTaskId, sourceDeviceTaskId)
const targetIndex = getDeviceInsertIndex(targetDeviceTaskId, nextStart)
@@ -576,61 +562,28 @@ const openTaskAdjustDialog = (task: any) => {
if (!task?._planData) return
taskAdjustTaskId.value = task.id
taskAdjustForm.deviceTaskId = String(task.parent ?? '')
- taskAdjustForm.startDate = dayjs(task.start_date).format('YYYY-MM-DD')
- taskAdjustForm.duration = Math.max(Number(task.duration) || 1, 1)
+ taskAdjustForm.startDate = dayjs(task.start_date).format('YYYY-MM-DD HH:mm:ss')
+ taskAdjustForm.endDate = dayjs(task.end_date).format('YYYY-MM-DD HH:mm:ss')
taskAdjustDialogVisible.value = true
}
const handleTaskAdjustSubmit = () => {
if (!taskAdjustTaskId.value) return
- if (!taskAdjustForm.deviceTaskId || !taskAdjustForm.startDate) {
- message.warning('请完善设备和开始日期')
+ if (!taskAdjustForm.deviceTaskId || !taskAdjustForm.startDate || !taskAdjustForm.endDate) {
+ message.warning('请完善设备、计划开始日期和计划结束日期')
return
}
const task = gantt.getTask(taskAdjustTaskId.value)
if (!task?._planData) return
ganttSyncing.value = true
try {
- applyTaskAdjust(task, taskAdjustForm.deviceTaskId, taskAdjustForm.startDate, taskAdjustForm.duration)
+ applyTaskAdjust(task, taskAdjustForm.deviceTaskId, taskAdjustForm.startDate, taskAdjustForm.endDate)
} finally {
ganttSyncing.value = false
}
taskAdjustDialogVisible.value = false
}
-const handleStartDateEditorSubmit = () => {
- if (!startDateEditorTaskId.value || !startDateEditorValue.value) {
- startDateEditorVisible.value = false
- return
- }
- const task = gantt.getTask(startDateEditorTaskId.value)
- if (!task?._planData) {
- startDateEditorVisible.value = false
- return
- }
- const newStart = dayjs(startDateEditorValue.value)
- if (!newStart.isValid()) {
- message.warning('请选择有效的时间')
- return
- }
- const duration = Math.max(Number(task.duration) || 1, 1)
- const newEnd = newStart.add(duration - 1, 'day').endOf('day')
- ganttSyncing.value = true
- try {
- task.start_date = newStart.toDate()
- task.end_date = newEnd.toDate()
- task.duration = duration
- syncPlanTimeFromTask(task)
- normalizeDeviceChildren(task.parent)
- refreshPlanLinksByRowOrder()
- refreshTimelineRangeByTasks()
- gantt.updateTask(task.id)
- } finally {
- ganttSyncing.value = false
- }
- startDateEditorVisible.value = false
-}
-
const refreshTimelineRangeByTasks = () => {
let minStart = Number.POSITIVE_INFINITY
let maxEnd = Number.NEGATIVE_INFINITY
@@ -691,28 +644,13 @@ const initGanttPreview = () => {
},
{
name: 'start_date',
- label: '开始时间',
+ label: '计划时间',
align: 'center',
width: 210,
template: (task: any) =>
task?._planData && String(task?._planData?.sourceType ?? '').toUpperCase() === 'CURRENT'
? `${formatGridDateText(task.start_date)}`
: formatGridDateText(task.start_date)
- },
- {
- name: 'duration',
- label: '天数',
- align: 'center',
- width: 60,
- template: (task: any) =>
- task?._planData && String(task?._planData?.sourceType ?? '').toUpperCase() === 'CURRENT'
- ? `${task.duration ?? 0}`
- : String(task.duration ?? 0),
- editor: {
- type: 'number',
- map_to: 'duration',
- min: 1
- }
}
]
@@ -771,9 +709,7 @@ const initGanttPreview = () => {
const field = editableNode?.dataset?.field
if (!field || !task?._planData || String(task?._planData?.sourceType ?? '').toUpperCase() !== 'CURRENT') return true
if (field === 'start_date') {
- startDateEditorTaskId.value = id
- startDateEditorValue.value = dayjs(task.start_date).format('YYYY-MM-DD HH:mm:ss')
- startDateEditorVisible.value = true
+ openTaskAdjustDialog(task)
return false
}
const inlineEditors = (gantt.ext as any)?.inlineEditors
@@ -796,9 +732,7 @@ const initGanttPreview = () => {
const task = gantt.getTask(taskId)
if (!task?._planData || String(task?._planData?.sourceType ?? '').toUpperCase() !== 'CURRENT') return
e.stopPropagation()
- startDateEditorTaskId.value = taskId
- startDateEditorValue.value = dayjs(task.start_date).format('YYYY-MM-DD HH:mm:ss')
- startDateEditorVisible.value = true
+ openTaskAdjustDialog(task)
} catch {}
}
ganttContainerRef.value.addEventListener('click', gridClickHandler, true)