feat:排产-甘特图添加双击弹框-调整任务

main
黄伟杰 1 week ago
parent 8c3f7a5aec
commit 182e9e9712

@ -4583,6 +4583,8 @@ export default {
latestStartColon: 'Latest Start: ', latestStartColon: 'Latest Start: ',
emptyDescription: 'No Schedule Info', emptyDescription: 'No Schedule Info',
adjustTaskTitle: 'Adjust Task', adjustTaskTitle: 'Adjust Task',
taskLabel: 'Task',
taskPlaceholder: 'Please select task',
deviceLabel: 'Device', deviceLabel: 'Device',
devicePlaceholder: 'Please select device', devicePlaceholder: 'Please select device',
startDateLabel: 'Start Date', startDateLabel: 'Start Date',

@ -4794,6 +4794,8 @@ export default {
latestStartColon: '最晚开工:', latestStartColon: '最晚开工:',
emptyDescription: '暂无计划信息', emptyDescription: '暂无计划信息',
adjustTaskTitle: '调整任务', adjustTaskTitle: '调整任务',
taskLabel: '任务',
taskPlaceholder: '请选择任务',
deviceLabel: '设备', deviceLabel: '设备',
devicePlaceholder: '请选择设备', devicePlaceholder: '请选择设备',
startDateLabel: '开始日期', startDateLabel: '开始日期',

@ -42,8 +42,13 @@
</div> </div>
</div> </div>
<el-dialog v-model="taskAdjustDialogVisible" :title="t('GanttChart.GanttPanel.adjustTaskTitle')" width="420px" append-to-body> <el-dialog v-model="taskAdjustDialogVisible" :title="t('GanttChart.GanttPanel.adjustTaskTitle')" width="420px" append-to-body draggable>
<el-form label-width="110px"> <el-form label-width="110px">
<el-form-item v-if="adjustFromGrid" :label="t('GanttChart.GanttPanel.taskLabel')">
<el-select v-model="taskAdjustForm.planIdentity" :placeholder="t('GanttChart.GanttPanel.taskPlaceholder')" class="!w-full" @change="handleAdjustPlanChange">
<el-option v-for="item in currentDevicePlanOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item :label="t('GanttChart.GanttPanel.deviceLabel')"> <el-form-item :label="t('GanttChart.GanttPanel.deviceLabel')">
<el-select v-model="taskAdjustForm.deviceTaskId" :placeholder="t('GanttChart.GanttPanel.devicePlaceholder')" class="!w-full"> <el-select v-model="taskAdjustForm.deviceTaskId" :placeholder="t('GanttChart.GanttPanel.devicePlaceholder')" class="!w-full">
<el-option v-for="item in previewDeviceOptions" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in previewDeviceOptions" :key="item.value" :label="item.label" :value="item.value" />
@ -105,8 +110,10 @@ const activePreviewTask = ref<any>()
const ganttEventIds = ref<string[]>([]) const ganttEventIds = ref<string[]>([])
const ganttSyncing = ref(false) const ganttSyncing = ref(false)
const taskAdjustDialogVisible = ref(false) const taskAdjustDialogVisible = ref(false)
const adjustFromGrid = ref(false)
const taskAdjustForm = reactive({ const taskAdjustForm = reactive({
deviceTaskId: '', deviceTaskId: '',
planIdentity: '',
startDate: '', startDate: '',
endDate: '' 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) => const hasCurrentPlan = (device: any) =>
(device?.plans ?? []).some((plan: any) => String(plan.sourceType ?? '').toUpperCase() === 'CURRENT') (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) => { const openTaskAdjustDialogForPlan = (plan: any, device: any) => {
adjustFromGrid.value = false
taskAdjustForm.deviceTaskId = `device-${device?.deviceId ?? ''}` taskAdjustForm.deviceTaskId = `device-${device?.deviceId ?? ''}`
taskAdjustForm.planIdentity = makePlanIdentity(plan)
taskAdjustForm.startDate = plan.planStartTimeStr || '' taskAdjustForm.startDate = plan.planStartTimeStr || ''
taskAdjustForm.endDate = plan.planEndTimeStr || '' taskAdjustForm.endDate = plan.planEndTimeStr || ''
editingPlanIdentity.value = makePlanIdentity(plan) editingPlanIdentity.value = makePlanIdentity(plan)
taskAdjustDialogVisible.value = true 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 = () => { const handleTaskAdjustSubmit = () => {
if (!taskAdjustForm.deviceTaskId || !taskAdjustForm.startDate || !taskAdjustForm.endDate) { if (!taskAdjustForm.deviceTaskId || !taskAdjustForm.startDate || !taskAdjustForm.endDate) {
message.warning(t('GanttChart.GanttPanel.warningCompleteDeviceDate')) message.warning(t('GanttChart.GanttPanel.warningCompleteDeviceDate'))
return return
} }
if (!editingPlanIdentity.value) return
const planIdentity = adjustFromGrid.value ? taskAdjustForm.planIdentity : editingPlanIdentity.value
if (!planIdentity) return
saveUndoSnapshot() saveUndoSnapshot()
@ -591,7 +643,7 @@ const handleTaskAdjustSubmit = () => {
let sourceDevice: any = null let sourceDevice: any = null
for (const device of previewScheduleList.value) { for (const device of previewScheduleList.value) {
const plan = (device?.plans ?? []).find( const plan = (device?.plans ?? []).find(
(p: any) => makePlanIdentity(p) === editingPlanIdentity.value (p: any) => makePlanIdentity(p) === planIdentity
) )
if (plan) { if (plan) {
foundPlan = plan foundPlan = plan
@ -726,6 +778,15 @@ const initGanttPreview = () => {
}) })
ganttEventIds.value.push(clickEventId) 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(() => { nextTick(() => {
renderCustomPlanBars() renderCustomPlanBars()
}) })

Loading…
Cancel
Save