| | |
| | | deleteBatch, |
| | | exportBatchExcel, |
| | | exportBatchQr, |
| | | exportBatchBusinessQr, |
| | | generateBatchBusinessCodes, |
| | | getBatchPage, |
| | | updateBatchStatus, |
| | | } from "#/api/mes/pro/batch"; |
| | | import { IconifyIcon } from "@vben/icons"; |
| | | import { $t } from "#/locales"; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from "./data"; |
| | | import Form from "./modules/form.vue"; |
| | | import PreGenerateModal from "./modules/pre-generate.vue"; |
| | | import QrTraceModal from "../components/qr-trace-modal.vue"; |
| | | import BusinessQrModal from "../components/business-qr.vue"; |
| | | |
| | | const [FormModal, formModalApi] = useVbenModal({ |
| | | connectedComponent: Form, |
| | |
| | | }); |
| | | |
| | | /** 刷新表格 */ |
| | | const [BusinessQrViewModal, businessQrApi] = useVbenModal({ connectedComponent: BusinessQrModal, destroyOnClose: true }); |
| | | function handleBusinessQr(row: MesProBatchApi.Batch) { |
| | | businessQrApi.setData({ code: row.businessCode }).open(); |
| | | } |
| | | async function handleGenerateBusiness(row: MesProBatchApi.Batch) { |
| | | if (row.id == null) return; |
| | | const count = await generateBatchBusinessCodes([row.id]); |
| | | message.success(`已补生成 ${count} 份业务码,已有码值保持不变`); handleRefresh(); |
| | | } |
| | | async function handleExportBusiness(row: MesProBatchApi.Batch) { |
| | | if (row.id == null) return; |
| | | const data = await exportBatchBusinessQr(row.id); |
| | | downloadFileFromBlobPart({ fileName: '批次与托盘业务二维码.zip', source: data }); |
| | | } |
| | | |
| | | function handleRefresh() { |
| | | gridApi.query(); |
| | | } |
| | |
| | | <FormModal @success="handleRefresh" /> |
| | | <PreGenerateModalApi @success="handlePreGenerateSuccess" /> |
| | | <QrTraceQueryModal /> |
| | | <BusinessQrViewModal /> |
| | | <Grid table-title="生产批次列表"> |
| | | <template #table-title><span class="text-[1rem] font-bold" style="white-space:nowrap">生产批次列表</span></template> |
| | | <template #toolbar-tools> |
| | | <TableAction :actions="[ |
| | | { |
| | | label: '预生成二维码', |
| | | icon: ACTION_ICON.ADD, |
| | | auth: ['mes:pro-batch:create'], |
| | | onClick: handlePreGenerate, |
| | | }, |
| | | { |
| | | label: $t('ui.actionTitle.create', ['批次']), |
| | | type: 'primary', |
| | | icon: ACTION_ICON.ADD, |
| | | auth: ['mes:pro-batch:create'], |
| | | onClick: handleCreate, |
| | | }, |
| | | { |
| | | label: '扫码追溯', |
| | | icon: ACTION_ICON.SEARCH, |
| | | auth: ['mes:pro-batch:query'], |
| | | onClick: handleTrace, |
| | | }, |
| | | { |
| | | label: $t('ui.actionTitle.export'), |
| | | type: 'primary', |
| | | icon: ACTION_ICON.DOWNLOAD, |
| | | auth: ['mes:pro-batch:export'], |
| | | onClick: handleExport, |
| | | }, |
| | | ]" /> |
| | | <div class="mes-code-toolbar"> |
| | | <TableAction :actions="[{ label: '预生成二维码', type: 'primary', icon: ACTION_ICON.ADD, auth: ['mes:pro-batch:create'], onClick: handlePreGenerate }, |
| | | { label: '新增批次', auth: ['mes:pro-batch:create'], onClick: handleCreate }, |
| | | { label: '扫码追溯', icon: ACTION_ICON.SEARCH, auth: ['mes:pro-batch:query'], onClick: handleTrace }]" /> |
| | | <TableAction :dropdown-trigger="['click']" :drop-down-actions="[{ label: 'Excel 数据', auth: ['mes:pro-batch:export'], onClick: handleExport }]"> |
| | | <template #more><Button>导出 <IconifyIcon icon="lucide:chevron-down" /></Button></template> |
| | | </TableAction> |
| | | </div> |
| | | </template> |
| | | <template #code="{ row }"> |
| | | <Button type="link" @click="handleDetail(row)"> |
| | |
| | | <template #actions="{ row }"> |
| | | <TableAction :actions="[ |
| | | { |
| | | label: '查看二维码', |
| | | label: '追溯二维码', |
| | | type: 'link', |
| | | auth: ['mes:pro-batch:query'], |
| | | onClick: handleViewQr.bind(null, row), |
| | |
| | | }, |
| | | ]" |
| | | :drop-down-actions="[ |
| | | { label: '业务二维码', auth: ['mes:pro-batch:query'], ifShow: !!row.businessCode, onClick: () => handleBusinessQr(row) }, |
| | | { label: '补生成业务码', auth: ['mes:pro-batch:create'], ifShow: !row.businessCode && row.status !== MesProBatchStatusEnum.CANCELED, onClick: () => handleGenerateBusiness(row) }, |
| | | { label: '导出整套业务二维码', auth: ['mes:pro-batch:export'], ifShow: row.status !== MesProBatchStatusEnum.CANCELED, onClick: () => handleExportBusiness(row) }, |
| | | { |
| | | label: '开始生产', |
| | | auth: ['mes:pro-batch:update'], |
| | |
| | | }, |
| | | }, |
| | | { |
| | | label: '打印整套二维码', |
| | | label: '打印整套追溯二维码', |
| | | auth: ['mes:pro-batch:export'], |
| | | onClick: () => handlePrintQrSet(row), |
| | | }, |
| | |
| | | </Grid> |
| | | </Page> |
| | | </template> |
| | | |
| | | <style scoped> |
| | | .mes-code-toolbar { display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px; } |
| | | .mes-code-toolbar :deep(.ant-btn) { white-space:nowrap; } |
| | | .mes-code-toolbar :deep(.ant-btn > .iconify) { display:inline-block;width:14px;height:14px;vertical-align:middle; } |
| | | </style> |