| | |
| | | |
| | | import { Page, useVbenModal } from '@vben/common-ui'; |
| | | import { |
| | | MesProWorkOrderProductionStatusEnum, |
| | | MesProWorkOrderStatusEnum, |
| | | MesProWorkOrderTypeEnum, |
| | | } from '@vben/constants'; |
| | | |
| | | import { Button, Card, Progress, Tabs } from 'ant-design-vue'; |
| | | import { Button, Card, Progress, Tabs, message } from 'ant-design-vue'; |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { getGanttTaskList } from '#/api/mes/pro/task'; |
| | |
| | | import { GanttChart } from './components'; |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | | import ScheduleForm from './modules/schedule-form.vue'; |
| | | import AutoSchedule from './modules/auto-schedule.vue'; |
| | | |
| | | const router = useRouter(); |
| | | const ganttTasks = ref<any[]>([]); // 甘特图预览数据 |
| | |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const [AutoScheduleModal, autoScheduleModalApi] = useVbenModal({ |
| | | connectedComponent: AutoSchedule, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | function canAutoSchedule(row: MesProWorkOrderApi.WorkOrder) { |
| | | return row.status === MesProWorkOrderStatusEnum.CONFIRMED |
| | | && row.type === MesProWorkOrderTypeEnum.SELF |
| | | && !isCompletedWorkOrder(row) |
| | | && (row.quantity ?? 0) > 0 |
| | | && (row.quantityScheduled ?? 0) < (row.quantity ?? 0); |
| | | } |
| | | |
| | | function handleAutoSchedule(row?: MesProWorkOrderApi.WorkOrder) { |
| | | const rows: MesProWorkOrderApi.WorkOrder[] = row ? [row] : gridApi.grid.getCheckboxRecords(); |
| | | if (!rows.length) return message.warning('请先勾选待排产工单'); |
| | | if (rows.length > 30) return message.warning('一次最多选择30个工单,请分批排产'); |
| | | if (rows.some((order) => !canAutoSchedule(order))) return message.warning('请选择已确认且仍需排产的自行生产工单'); |
| | | autoScheduleModalApi.setData({ workOrderIds: rows.map((order) => order.id!) }).open(); |
| | | } |
| | | |
| | | |
| | | /** 刷新表格 */ |
| | | function handleRefresh() { |
| | | gridApi.grid.clearCheckboxRow(); |
| | | gridApi.query(); |
| | | loadGanttPreview(); |
| | | } |
| | |
| | | router.push({ name: 'MesProTaskGanttEdit' }); |
| | | } |
| | | |
| | | /** 判断订单是否为“已完成类型”:订单状态=已完成 或 生产状态=生产完成 */ |
| | | /** 判断订单是否为“已完成类型”:订单状态=已完成 */ |
| | | function isCompletedWorkOrder(row: MesProWorkOrderApi.WorkOrder): boolean { |
| | | return ( |
| | | row.status === MesProWorkOrderStatusEnum.FINISHED || |
| | | row.productionStatus === MesProWorkOrderProductionStatusEnum.FINISHED |
| | | ); |
| | | return row.status === MesProWorkOrderStatusEnum.FINISHED; |
| | | } |
| | | |
| | | /** |
| | |
| | | gridOptions: { |
| | | columns: useGridColumns(), |
| | | keepSource: true, |
| | | checkboxConfig: { |
| | | checkStrictly: true, |
| | | showHeader: true, |
| | | checkMethod: ({ row }: { row: MesProWorkOrderApi.WorkOrder }) => canAutoSchedule(row), |
| | | }, |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues) => { |
| | |
| | | <template> |
| | | <Page auto-content-height> |
| | | <ScheduleModal @success="handleRefresh" /> |
| | | <AutoScheduleModal @success="handleRefresh" /> |
| | | <!-- 排产甘特图预览 --> |
| | | <Card title="排产甘特图" class="mb-4"> |
| | | <template #extra> |
| | |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | label: '甘特图编辑', |
| | | label: '一键排产', |
| | | type: 'primary', |
| | | icon: ACTION_ICON.ADD, |
| | | auth: ['mes:pro-task:create'], |
| | | onClick: () => handleAutoSchedule(), |
| | | }, |
| | | { |
| | | label: '甘特图编辑', |
| | | icon: ACTION_ICON.EDIT, |
| | | onClick: handleGanttEdit, |
| | | }, |
| | |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | label: '一键排产', |
| | | type: 'link', |
| | | auth: ['mes:pro-task:create'], |
| | | ifShow: canAutoSchedule(row), |
| | | onClick: () => handleAutoSchedule(row), |
| | | }, |
| | | { |
| | | label: '排产维护', |
| | | type: 'link', |
| | | auth: ['mes:pro-task:create'], |