From ad793426167d6768ca0439c39e471fcf0469da18 Mon Sep 17 00:00:00 2001 From: hwj Date: Mon, 11 May 2026 17:51:47 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E7=94=98=E7=89=B9=E5=9B=BE-?= =?UTF-8?q?=E6=9D=A1=E5=9D=97=E6=8B=96=E6=8B=BD=E8=B6=85=E5=87=BA=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=BD=B4=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/en.ts | 1 + src/locales/zh-CN.ts | 1 + .../components/ScheduleGanttPanelEditable.vue | 21 +++++++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/locales/en.ts b/src/locales/en.ts index 62412256..27de02b9 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -4654,6 +4654,7 @@ export default { warningCompleteDeviceDate: 'Please complete device, start date and end date', warningValidTime: 'Please select a valid time', warningEndBeforeStart: 'End time cannot be earlier than start time', + warningDragOutOfRange: 'Drag out of date range, reverted to original position', columnTaskName: 'Task Name', columnDeviceName: 'Device Name', columnPlanInfo: 'Plan Info', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index c8c0f053..3f79dd51 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -4865,6 +4865,7 @@ export default { warningCompleteDeviceDate: '请完善设备、计划开始日期和计划结束日期', warningValidTime: '请选择有效的时间', warningEndBeforeStart: '结束时间不能早于开始时间', + warningDragOutOfRange: '拖拽超出日期范围,已恢复原位', columnTaskName: '任务名称', columnDeviceName: '设备名称', columnPlanInfo: '计划信息', diff --git a/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue b/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue index 8a9bf268..639b13ab 100644 --- a/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue +++ b/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue @@ -462,11 +462,18 @@ const attachPlanBarDrag = (bar: HTMLElement, plan: any, task: any) => { if (!moved) return moved = false - saveUndoSnapshot() - const dx = e.clientX - startX const newLeft = Math.max(0, startLeft + dx) const newStartDate = gantt.dateFromPos(newLeft) + + if (!newStartDate || !dayjs(newStartDate).isValid()) { + message.warning(t('GanttChart.GanttPanel.warningDragOutOfRange')) + initGanttPreview() + return + } + + saveUndoSnapshot() + const planDuration = dayjs(plan.planEndTimeStr).diff(dayjs(plan.planStartTimeStr), 'millisecond') const newEndDate = new Date(newStartDate.getTime() + planDuration) @@ -568,13 +575,19 @@ const attachPlanBarResize = (bar: HTMLElement, plan: any, task: any) => { resizing = false bar.style.zIndex = '2' - saveUndoSnapshot() - const newLeft = parseFloat(bar.style.left) || startLeft const newWidth = parseFloat(bar.style.width) || startWidth const newStartDate = gantt.dateFromPos(newLeft) const newEndDate = gantt.dateFromPos(newLeft + newWidth) + if (!newStartDate || !newEndDate || !dayjs(newStartDate).isValid() || !dayjs(newEndDate).isValid()) { + message.warning(t('GanttChart.GanttPanel.warningDragOutOfRange')) + initGanttPreview() + return + } + + saveUndoSnapshot() + const identity = makePlanIdentity(plan) const original = findOriginalPlan(identity) if (original) {