| | |
| | | import { ref } from 'vue'; |
| | | |
| | | import { Page, useVbenModal } from '@vben/common-ui'; |
| | | import { downloadFileFromBlobPart } from '@vben/utils'; |
| | | |
| | | import { message } from 'ant-design-vue'; |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { deleteItemType, getItemTypeList } from '#/api/mes/md/item/type'; |
| | | import { |
| | | deleteItemType, |
| | | exportItemType, |
| | | getItemTypeList, |
| | | } from '#/api/mes/md/item/type'; |
| | | import { getItemPage as getMesItemPage } from '#/api/mes/md/item'; |
| | | import { getItemPage as getMdmItemPage } from '#/api/mdm/item'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | | import Form from './modules/form.vue'; |
| | | import ImportForm from './modules/import-form.vue'; |
| | | |
| | | const [FormModal, formModalApi] = useVbenModal({ |
| | | connectedComponent: Form, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const [ImportModal, importModalApi] = useVbenModal({ |
| | | connectedComponent: ImportForm, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | |
| | | formModalApi.setData(null).open(); |
| | | } |
| | | |
| | | /** 导入分类 */ |
| | | function handleImport() { |
| | | importModalApi.open(); |
| | | } |
| | | |
| | | /** 导出分类(按当前列表查询条件导出全部命中数据) */ |
| | | async function handleExport() { |
| | | const data = await exportItemType(await gridApi.formApi.getValues()); |
| | | downloadFileFromBlobPart({ fileName: '物料分类数据.xls', source: data }); |
| | | } |
| | | |
| | | /** 添加下级分类 */ |
| | | function handleAppend(row: MesMdItemTypeApi.ItemType) { |
| | | formModalApi.setData({ parentId: row.id }).open(); |
| | |
| | | |
| | | /** 删除分类 */ |
| | | async function handleDelete(row: MesMdItemTypeApi.ItemType) { |
| | | try { |
| | | const [mesResult, mdmResult] = await Promise.all([ |
| | | getMesItemPage({ pageNo: 1, pageSize: 1, itemTypeId: row.id }), |
| | | getMdmItemPage({ pageNo: 1, pageSize: 1, categoryId: row.id } as any), |
| | | ]); |
| | | if (mesResult.total > 0 || mdmResult.total > 0) { |
| | | message.error('该分类下存在物料,无法删除'); |
| | | return; |
| | | } |
| | | } catch { |
| | | // 查询异常时继续执行删除,由后端兜底校验 |
| | | } |
| | | const hideLoading = message.loading({ |
| | | content: $t('ui.actionMessage.deleting', [row.name]), |
| | | duration: 0, |
| | |
| | | </script> |
| | | |
| | | <template> |
| | | <Page auto-content-height><FormModal @success="handleRefresh" /> |
| | | <Page auto-content-height><FormModal @success="handleRefresh" /><ImportModal @success="handleRefresh" /> |
| | | <Grid table-title="物料分类列表"> |
| | | <template #toolbar-tools> |
| | | <TableAction |
| | |
| | | onClick: handleCreate, |
| | | }, |
| | | { |
| | | label: $t('ui.actionTitle.import', ['物料分类']), |
| | | type: 'primary', |
| | | icon: ACTION_ICON.UPLOAD, |
| | | auth: ['mes:md-item-type:import'], |
| | | onClick: handleImport, |
| | | }, |
| | | { |
| | | label: $t('ui.actionTitle.export'), |
| | | type: 'primary', |
| | | icon: ACTION_ICON.DOWNLOAD, |
| | | auth: ['mes:md-item-type:export'], |
| | | onClick: handleExport, |
| | | }, |
| | | { |
| | | label: isExpanded ? '收缩' : '展开', |
| | | type: 'primary', |
| | | onClick: handleExpand, |