| | |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MesWmStockTakingTaskApi } from '#/api/mes/wm/stocktaking/task'; |
| | | |
| | | import { Page, useVbenModal } from '../../../../packages/effects/common-ui/src'; |
| | | import { MesWmStockTakingTaskStatusEnum } from '../../../../packages/constants/src'; |
| | | import { downloadFileFromBlobPart } from '../../../../packages/utils/src'; |
| | | import { ref } from 'vue'; |
| | | |
| | | import { Page, useVbenModal } from '@vben/common-ui'; |
| | | import { MesWmStockTakingTaskStatusEnum } from '@vben/constants'; |
| | | import { downloadFileFromBlobPart } from '@vben/utils'; |
| | | |
| | | import { Button, message } from 'ant-design-vue'; |
| | | |
| | |
| | | exportStockTaking, |
| | | getStockTakingPage, |
| | | } from '#/api/mes/wm/stocktaking/task'; |
| | | import { |
| | | importStockTakingQuantity, |
| | | importStockTakingQuantityTemplate, |
| | | } from '#/api/wls/stocktaking/task/line'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | |
| | | downloadFileFromBlobPart({ fileName: '盘点任务.xls', source: data }); |
| | | } |
| | | |
| | | /** 下载盘点导入模板 */ |
| | | async function handleImportTemplate() { |
| | | const data = await importStockTakingQuantityTemplate(); |
| | | downloadFileFromBlobPart({ fileName: '盘点实盘数导入模板.xls', source: data }); |
| | | } |
| | | |
| | | const importFileRef = ref<HTMLInputElement>(); |
| | | const importTaskId = ref<number>(); |
| | | |
| | | /** 触发导入文件选择 */ |
| | | function handleImport(row: MesWmStockTakingTaskApi.StockTakingTask) { |
| | | importTaskId.value = row.id!; |
| | | importFileRef.value?.click(); |
| | | } |
| | | |
| | | /** 导入实盘数文件选择后上传 */ |
| | | async function handleImportFileChange(event: Event) { |
| | | const file = (event.target as HTMLInputElement).files?.[0]; |
| | | if (!file || !importTaskId.value) { |
| | | return; |
| | | } |
| | | const hideLoading = message.loading({ content: '正在导入实盘数...', duration: 0 }); |
| | | try { |
| | | const result = await importStockTakingQuantity(importTaskId.value, file); |
| | | message.success(`导入完成:成功 ${result.successCount ?? 0} 条,失败 ${result.failureCount ?? 0} 条`); |
| | | if (result.failureMessages?.length) { |
| | | message.warning(result.failureMessages.slice(0, 5).join(';')); |
| | | } |
| | | handleRefresh(); |
| | | } finally { |
| | | (event.target as HTMLInputElement).value = ''; |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | const [Grid, gridApi] = useVbenVxeGrid({ |
| | | formOptions: { |
| | | schema: useGridFormSchema(), |
| | |
| | | auth: ['mes:wm-stock-taking-task:export'], |
| | | onClick: handleExport, |
| | | }, |
| | | { |
| | | label: '导入模板', |
| | | type: 'primary', |
| | | icon: ACTION_ICON.DOWNLOAD, |
| | | auth: ['mes:wm-stock-taking-task:query'], |
| | | onClick: handleImportTemplate, |
| | | }, |
| | | ]" |
| | | /> |
| | | </template> |
| | |
| | | onClick: handleExecute.bind(null, row), |
| | | }, |
| | | { |
| | | label: '导入实盘数', |
| | | type: 'link', |
| | | icon: ACTION_ICON.UPLOAD, |
| | | auth: ['mes:wm-stock-taking-task:update'], |
| | | ifShow: row.status === StatusEnum.APPROVING, |
| | | onClick: handleImport.bind(null, row), |
| | | }, |
| | | { |
| | | label: '取消', |
| | | type: 'link', |
| | | danger: true, |
| | |
| | | /> |
| | | </template> |
| | | </Grid> |
| | | <input |
| | | ref="importFileRef" |
| | | class="hidden" |
| | | type="file" |
| | | accept=".xls,.xlsx" |
| | | @change="handleImportFileChange" |
| | | /> |
| | | </Page> |
| | | </template> |