|
|
|
|
@ -42,8 +42,13 @@
|
|
|
|
|
</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-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-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" />
|
|
|
|
|
@ -105,8 +110,10 @@ const activePreviewTask = ref<any>()
|
|
|
|
|
const ganttEventIds = ref<string[]>([])
|
|
|
|
|
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()
|
|
|
|
|
})
|
|
|
|
|
|