| | |
| | | <script lang="ts" setup> |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MesProWorkOrderApi, TaskInfo } from '#/api/mes/pro/workorder'; |
| | | import type { MesProWorkOrderApi, TaskInfo, WorkOrderProgress } from '#/api/mes/pro/workorder'; |
| | | |
| | | import { ref } from 'vue'; |
| | | import { useRouter } from 'vue-router'; |
| | |
| | | getWorkOrderProgress, |
| | | checkAndAutoFinishWorkOrder, |
| | | } from '#/api/mes/pro/workorder'; |
| | | import { previewAutoGenerate, autoGenerateTasks } from '#/api/mes/pro/task'; |
| | | |
| | | import ArchiveDetail from '#/views/mes/pd/archive/modules/detail.vue'; |
| | | import { useGridColumns, useGridFormSchema, useTaskGridColumns } from './data'; |
| | | import QuickFeedbackForm from './modules/quick-feedback.vue'; |
| | | import SchedulePreviewModal from './modules/schedule-preview.vue'; |
| | | import AutoSchedule from '../task/modules/auto-schedule.vue'; |
| | | |
| | | defineOptions({ name: 'WorkorderCenter' }); |
| | | const archiveDetailRef = ref<InstanceType<typeof ArchiveDetail>>(); |
| | | const archiveVisible = ref(false); |
| | | const archiveProductCode = ref(''); |
| | | |
| | | function handleArchive(row: MesProWorkOrderApi.WorkOrder) { |
| | | archiveProductCode.value = row.productCode ?? ''; |
| | | archiveVisible.value = true; |
| | | } |
| | | |
| | | const router = useRouter(); |
| | | |
| | | const progressData = ref<MesProWorkOrderApi.WorkOrderProgress | null>(null); |
| | | const progressData = ref<WorkOrderProgress | null>(null); |
| | | const activeProcessKeys = ref<string[]>([]); |
| | | const expandedRowId = ref<number | null>(null); |
| | | |
| | |
| | | }); |
| | | |
| | | const [SchedulePreviewModalWrap, schedulePreviewModalApi] = useVbenModal({ |
| | | connectedComponent: SchedulePreviewModal, |
| | | connectedComponent: AutoSchedule, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | |
| | | .open(); |
| | | } |
| | | |
| | | /** 一键排产预览 */ |
| | | async function handleSchedulePreview(row: MesProWorkOrderApi.WorkOrder) { |
| | | try { |
| | | const preview = await previewAutoGenerate({ workOrderId: row.id! }); |
| | | schedulePreviewModalApi |
| | | .setData({ workOrder: row, preview }) |
| | | .open(); |
| | | } catch { |
| | | message.error('获取排产预览失败'); |
| | | } |
| | | } |
| | | |
| | | /** 执行一键排产 */ |
| | | async function handleScheduleExecute(row: MesProWorkOrderApi.WorkOrder) { |
| | | try { |
| | | const result = await autoGenerateTasks({ workOrderId: row.id! }); |
| | | message.success(`排产成功,生成 ${result.taskIds?.length || 0} 个任务`); |
| | | handleRefresh(); |
| | | } catch { |
| | | message.error('排产失败'); |
| | | } |
| | | /** 与生产排产共用校验、预览和执行流程。 */ |
| | | function handleSchedulePreview(row: MesProWorkOrderApi.WorkOrder) { |
| | | schedulePreviewModalApi.setData({ workOrderIds: [row.id!] }).open(); |
| | | } |
| | | |
| | | const [Grid, gridApi] = useVbenVxeGrid({ |
| | |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | label: '排产预览', |
| | | type: 'link', |
| | | auth: ['mes:pro-task:create'], |
| | | ifShow: row.quantityScheduled < row.quantity, |
| | | onClick: handleSchedulePreview.bind(null, row), |
| | | }, |
| | | { |
| | | label: '一键排产', |
| | | type: 'link', |
| | | auth: ['mes:pro-task:create'], |
| | | ifShow: row.quantityScheduled < row.quantity, |
| | | popConfirm: { |
| | | title: '确认一键排产?将按照工艺路线自动生成任务。', |
| | | confirm: handleScheduleExecute.bind(null, row), |
| | | }, |
| | | ifShow: (row.quantityScheduled ?? 0) < (row.quantity ?? 0), |
| | | onClick: handleSchedulePreview.bind(null, row), |
| | | }, |
| | | { |
| | | label: '归档', |
| | | type: 'link', |
| | | onClick: () => archiveDetailRef.value?.open(row.productCode), |
| | | onClick: () => handleArchive(row), |
| | | }, |
| | | ]" |
| | | /> |
| | |
| | | </Collapse.Panel> |
| | | </Collapse> |
| | | </Card> |
| | | <ArchiveDetail ref="archiveDetailRef" /> |
| | | <ArchiveDetail :visible="archiveVisible" :product-code="archiveProductCode" @update:visible="archiveVisible = $event" /> |
| | | </Page> |
| | | </template> |