| | |
| | | <script lang="ts" setup> |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MdmItemApi } from '#/api/mdm/item'; |
| | | import type { MesMdItemTypeApi } from '#/api/mes/md/item/type'; |
| | | |
| | | import { ref } from 'vue'; |
| | | |
| | |
| | | import { |
| | | deleteItem, |
| | | deleteItemList, |
| | | exportItem, |
| | | // exportItem, |
| | | getItemPage, |
| | | updateItemStatus, |
| | | } from '#/api/mdm/item'; |
| | | import { getItemTypeSimpleList } from '#/api/mes/md/item/type'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | // 分类列表缓存 |
| | | const categoryList = ref<MesMdItemTypeApi.ItemType[]>([]); |
| | | |
| | | /** 获取分类名称 */ |
| | | function getCategoryName(categoryId?: number) { |
| | | if (!categoryId || !categoryList.value.length) return ''; |
| | | const category = categoryList.value.find((item) => item.id === categoryId); |
| | | return category?.name || ''; |
| | | } |
| | | |
| | | /** 刷新表格 */ |
| | | function handleRefresh() { |
| | | gridApi.query(); |
| | | } |
| | | |
| | | /** 导出表格 */ |
| | | async function handleExport() { |
| | | const data = await exportItem(await gridApi.formApi.getValues()); |
| | | downloadFileFromBlobPart({ fileName: '物料.xls', source: data }); |
| | | } |
| | | // async function handleExport() { |
| | | // const data = await exportItem(await gridApi.formApi.getValues()); |
| | | // downloadFileFromBlobPart({ fileName: '物料.xls', source: data }); |
| | | // } |
| | | |
| | | /** 创建物料 */ |
| | | function handleCreate() { |
| | |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues) => { |
| | | // 加载分类列表(用于显示分类名称) |
| | | if (!categoryList.value.length) { |
| | | try { |
| | | categoryList.value = await getItemTypeSimpleList(); |
| | | } catch { |
| | | categoryList.value = []; |
| | | } |
| | | } |
| | | return await getItemPage({ |
| | | pageNo: page.currentPage, |
| | | pageSize: page.pageSize, |
| | |
| | | auth: ['mdm:item:create'], |
| | | onClick: handleCreate, |
| | | }, |
| | | { |
| | | label: $t('ui.actionTitle.export'), |
| | | type: 'primary', |
| | | icon: ACTION_ICON.DOWNLOAD, |
| | | auth: ['mdm:item:export'], |
| | | onClick: handleExport, |
| | | }, |
| | | // { |
| | | // label: $t('ui.actionTitle.export'), |
| | | // type: 'primary', |
| | | // icon: ACTION_ICON.DOWNLOAD, |
| | | // auth: ['mdm:item:export'], |
| | | // onClick: handleExport, |
| | | // }, |
| | | { |
| | | label: $t('ui.actionTitle.deleteBatch'), |
| | | type: 'primary', |
| | |
| | | }, |
| | | ]" |
| | | /> |
| | | </template> |
| | | <template #categoryName="{ row }"> |
| | | <Tag v-if="row.categoryId === 1" color="green">{{ getCategoryName(row.categoryId) }}</Tag> |
| | | <Tag v-else-if="row.categoryId === 2" color="orange">{{ getCategoryName(row.categoryId) }}</Tag> |
| | | <Tag v-else-if="row.categoryId === 3" color="blue">{{ getCategoryName(row.categoryId) }}</Tag> |
| | | <Tag v-else-if="row.categoryId === 4" color="purple">{{ getCategoryName(row.categoryId) }}</Tag> |
| | | <Tag v-else-if="row.categoryId === 5" color="cyan">{{ getCategoryName(row.categoryId) }}</Tag> |
| | | <span v-else>{{ getCategoryName(row.categoryId) }}</span> |
| | | </template> |
| | | <template #isBatchManaged="{ row }"> |
| | | <Tag v-if="row.isBatchManaged" color="success">是</Tag> |
| | |
| | | icon: ACTION_ICON.EDIT, |
| | | auth: ['mdm:item:update'], |
| | | onClick: handleEdit.bind(null, row), |
| | | }, |
| | | { |
| | | label: row.status === 0 ? '停用' : '启用', |
| | | type: 'link', |
| | | auth: ['mdm:item:update'], |
| | | onClick: handleStatusChange.bind(null, row, row.status === 0), |
| | | }, |
| | | { |
| | | label: $t('common.delete'), |