diff --git a/src/locales/en.ts b/src/locales/en.ts index cd6f9386..9e8e2f79 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -4583,6 +4583,8 @@ export default { latestStartColon: 'Latest Start: ', emptyDescription: 'No Schedule Info', adjustTaskTitle: 'Adjust Task', + taskLabel: 'Task', + taskPlaceholder: 'Please select task', deviceLabel: 'Device', devicePlaceholder: 'Please select device', startDateLabel: 'Start Date', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 32a6129d..c4c7f58c 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -4794,6 +4794,8 @@ export default { latestStartColon: '最晚开工:', emptyDescription: '暂无计划信息', adjustTaskTitle: '调整任务', + taskLabel: '任务', + taskPlaceholder: '请选择任务', deviceLabel: '设备', devicePlaceholder: '请选择设备', startDateLabel: '开始日期', diff --git a/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue b/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue index 97d388cd..c86f9693 100644 --- a/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue +++ b/src/views/mes/tasksummary/components/ScheduleGanttPanelEditable.vue @@ -42,8 +42,13 @@ - + + + + + + @@ -105,8 +110,10 @@ const activePreviewTask = ref() const ganttEventIds = ref([]) const ganttSyncing = ref(false) const taskAdjustDialogVisible = ref(false) +const adjustFromGrid = ref(false) const taskAdjustForm = reactive({ deviceTaskId: '', + planIdentity: '', startDate: '', endDate: '' }) @@ -139,6 +146,27 @@ const previewDeviceOptions = computed(() => })) ) +const currentDevicePlanOptions = computed(() => { + const device = previewScheduleList.value.find( + (d: any) => `device-${d.deviceId}` === taskAdjustForm.deviceTaskId + ) + if (!device) return [] + return (device.plans ?? []) + .filter((plan: any) => String(plan.sourceType ?? '').toUpperCase() === 'CURRENT') + .map((plan: any) => ({ + label: `${plan.productCode ?? '-'} / ${plan.productName ?? '-'} / ${plan.taskCode ?? '-'}`, + value: makePlanIdentity(plan) + })) +}) + +const handleAdjustPlanChange = (identity: string) => { + const found = findOriginalPlan(identity) + if (found) { + taskAdjustForm.startDate = found.plan.planStartTimeStr || '' + taskAdjustForm.endDate = found.plan.planEndTimeStr || '' + } +} + const hasCurrentPlan = (device: any) => (device?.plans ?? []).some((plan: any) => String(plan.sourceType ?? '').toUpperCase() === 'CURRENT') @@ -566,19 +594,43 @@ const attachPlanBarResize = (bar: HTMLElement, plan: any, task: any) => { } const openTaskAdjustDialogForPlan = (plan: any, device: any) => { + adjustFromGrid.value = false taskAdjustForm.deviceTaskId = `device-${device?.deviceId ?? ''}` + taskAdjustForm.planIdentity = makePlanIdentity(plan) taskAdjustForm.startDate = plan.planStartTimeStr || '' taskAdjustForm.endDate = plan.planEndTimeStr || '' editingPlanIdentity.value = makePlanIdentity(plan) taskAdjustDialogVisible.value = true } +const openTaskAdjustDialogFromGrid = (device: any) => { + adjustFromGrid.value = true + taskAdjustForm.deviceTaskId = `device-${device?.deviceId ?? ''}` + taskAdjustForm.planIdentity = '' + taskAdjustForm.startDate = '' + taskAdjustForm.endDate = '' + editingPlanIdentity.value = null + const currentPlans = (device?.plans ?? []).filter( + (plan: any) => String(plan.sourceType ?? '').toUpperCase() === 'CURRENT' + ) + if (currentPlans.length === 1) { + const plan = currentPlans[0] + taskAdjustForm.planIdentity = makePlanIdentity(plan) + taskAdjustForm.startDate = plan.planStartTimeStr || '' + taskAdjustForm.endDate = plan.planEndTimeStr || '' + editingPlanIdentity.value = makePlanIdentity(plan) + } + taskAdjustDialogVisible.value = true +} + const handleTaskAdjustSubmit = () => { if (!taskAdjustForm.deviceTaskId || !taskAdjustForm.startDate || !taskAdjustForm.endDate) { message.warning(t('GanttChart.GanttPanel.warningCompleteDeviceDate')) return } - if (!editingPlanIdentity.value) return + + const planIdentity = adjustFromGrid.value ? taskAdjustForm.planIdentity : editingPlanIdentity.value + if (!planIdentity) return saveUndoSnapshot() @@ -591,7 +643,7 @@ const handleTaskAdjustSubmit = () => { let sourceDevice: any = null for (const device of previewScheduleList.value) { const plan = (device?.plans ?? []).find( - (p: any) => makePlanIdentity(p) === editingPlanIdentity.value + (p: any) => makePlanIdentity(p) === planIdentity ) if (plan) { foundPlan = plan @@ -726,6 +778,15 @@ const initGanttPreview = () => { }) ganttEventIds.value.push(clickEventId) + const dblClickEventId = gantt.attachEvent('onTaskDblClick', (id) => { + const ganttTask = gantt.getTask(id) + if (ganttTask?._deviceData && props.editable) { + openTaskAdjustDialogFromGrid(ganttTask._deviceData) + } + return false + }) + ganttEventIds.value.push(dblClickEventId) + nextTick(() => { renderCustomPlanBars() })