|
|
|
|
@ -1,21 +1,33 @@
|
|
|
|
|
<template>
|
|
|
|
|
<Dialog v-model="previewVisible" title="排产甘特图预览" width="100%" align-center>
|
|
|
|
|
<Dialog v-model="previewVisible" :title="t('GanttChart.GanttPanel.dialogTitle')" width="100%" align-center>
|
|
|
|
|
<div class="preview-options">
|
|
|
|
|
<el-form :inline="true">
|
|
|
|
|
<el-form-item label="领料人">
|
|
|
|
|
<el-select v-model="scheduleOptions.workerId" clearable filterable placeholder="请选择领料人" style="width: 200px">
|
|
|
|
|
<el-form-item :label="t('GanttChart.GanttPanel.workerLabel')">
|
|
|
|
|
<el-select v-model="scheduleOptions.workerId" clearable filterable :placeholder="t('GanttChart.GanttPanel.workerPlaceholder')" style="width: 200px">
|
|
|
|
|
<el-option v-for="item in workerList" :key="item.id" :label="item.nickname" :value="item.id" />
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="是否计算损耗">
|
|
|
|
|
<el-form-item :label="t('GanttChart.GanttPanel.calcLossLabel')">
|
|
|
|
|
<el-switch v-model="scheduleOptions.isCalculateLoss" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button :type="ganttEditable ? 'primary' : 'default'" @click="toggleGanttEditable">
|
|
|
|
|
<Icon :icon="ganttEditable ? 'ep:unlock' : 'ep:lock'" class="mr-4px" />
|
|
|
|
|
{{ ganttEditable ? t('GanttChart.GanttPanel.unlockBtn') : t('GanttChart.GanttPanel.lockBtn') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button :disabled="!ganttEditable" @click="handleUndo">
|
|
|
|
|
<Icon icon="ep:refresh-left" class="mr-4px" />
|
|
|
|
|
{{ t('GanttChart.GanttPanel.undoBtn') }}
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</div>
|
|
|
|
|
<ScheduleGanttPanelEditable :schedule-list="previewScheduleList" height="800px" />
|
|
|
|
|
<ScheduleGanttPanelEditable ref="ganttPanelRef" :schedule-list="previewScheduleList" :editable="ganttEditable" height="800px" />
|
|
|
|
|
<template #footer>
|
|
|
|
|
<el-button type="primary" :loading="previewSaveLoading" @click="handlePreviewSave">保存</el-button>
|
|
|
|
|
<el-button @click="previewVisible = false">关闭</el-button>
|
|
|
|
|
<el-button type="primary" :loading="previewSaveLoading" @click="handlePreviewSave">{{ t('GanttChart.GanttPanel.buttonSave') }}</el-button>
|
|
|
|
|
<el-button @click="previewVisible = false">{{ t('GanttChart.GanttPanel.buttonClose') }}</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</template>
|
|
|
|
|
@ -25,9 +37,12 @@ import { PlanApi } from '@/api/mes/plan'
|
|
|
|
|
import * as UserApi from '@/api/system/user'
|
|
|
|
|
import ScheduleGanttPanelEditable from './ScheduleGanttPanelEditable.vue'
|
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
import { useI18n } from '@/hooks/web/useI18n'
|
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'TaskSchedulePreviewDialog' })
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n()
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
modelValue: boolean
|
|
|
|
|
scheduleList: any[]
|
|
|
|
|
@ -40,6 +55,16 @@ const emit = defineEmits<{
|
|
|
|
|
|
|
|
|
|
const message = useMessage()
|
|
|
|
|
const previewSaveLoading = ref(false)
|
|
|
|
|
const ganttEditable = ref(false)
|
|
|
|
|
const ganttPanelRef = ref<InstanceType<typeof ScheduleGanttPanelEditable>>()
|
|
|
|
|
|
|
|
|
|
const toggleGanttEditable = () => {
|
|
|
|
|
ganttEditable.value = !ganttEditable.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleUndo = () => {
|
|
|
|
|
ganttPanelRef.value?.undo()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const workerList = ref<UserApi.UserVO[]>([])
|
|
|
|
|
const scheduleOptions = reactive({
|
|
|
|
|
@ -61,9 +86,12 @@ const previewVisible = computed({
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
watch(previewVisible, (visible) => {
|
|
|
|
|
if (visible && workerList.value.length === 0) {
|
|
|
|
|
if (visible) {
|
|
|
|
|
if (workerList.value.length === 0) {
|
|
|
|
|
loadWorkerList()
|
|
|
|
|
}
|
|
|
|
|
ganttEditable.value = false
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const previewScheduleList = computed(() => (Array.isArray(props.scheduleList) ? props.scheduleList : []))
|
|
|
|
|
@ -100,14 +128,14 @@ const handlePreviewSave = async () => {
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (!createReqVOList.length) {
|
|
|
|
|
message.warning('暂无可保存的计划数据')
|
|
|
|
|
message.warning(t('GanttChart.GanttPanel.warningNoPlanData'))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
previewSaveLoading.value = true
|
|
|
|
|
try {
|
|
|
|
|
await PlanApi.createBatch({ createReqVOList })
|
|
|
|
|
message.success('排产计划保存成功')
|
|
|
|
|
message.success(t('GanttChart.GanttPanel.saveSuccess'))
|
|
|
|
|
previewVisible.value = false
|
|
|
|
|
emit('saved')
|
|
|
|
|
} finally {
|
|
|
|
|
|