| | |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { MesWmItemReceiptApi } from '#/api/mes/wm/itemreceipt'; |
| | | |
| | | import { ref } from 'vue'; |
| | | |
| | | import { Page, useVbenModal } from '@vben/common-ui'; |
| | | import { MesWmItemReceiptStatusEnum } from '@vben/constants'; |
| | | import { useUserStore } from '@vben/stores'; |
| | | import { downloadFileFromBlobPart } from '@vben/utils'; |
| | | |
| | | import { Button, message } from 'ant-design-vue'; |
| | |
| | | deleteItemReceipt, |
| | | exportItemReceipt, |
| | | generateItemReceiptFromArrivalNotice, |
| | | getItemReceiptApproverIds, |
| | | getItemReceiptPage, |
| | | } from '#/api/mes/wm/itemreceipt'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | | import AuditModal from './modules/audit-modal.vue'; |
| | | import Form from './modules/form.vue'; |
| | | import AnSelectDialog from './modules/an-select-dialog.vue'; |
| | | |
| | | const userStore = useUserStore(); |
| | | const currentUserId = userStore.userInfo?.id; // 当前登录用户 ID,用于审核人权限判断 |
| | | |
| | | /** 审批配置中该业务的审核人编号集合,决定「审核 / 审核不通过」按钮是否展示 */ |
| | | const approverIds = ref<number[]>([]); |
| | | |
| | | /** 拉取审核人集合;失败时保持为空(按钮不展示),不阻断列表加载 */ |
| | | async function loadApproverIds() { |
| | | try { |
| | | approverIds.value = (await getItemReceiptApproverIds()) ?? []; |
| | | } catch { |
| | | approverIds.value = []; |
| | | } |
| | | } |
| | | |
| | | /** 当前登录用户是否为该业务的审核人,且单据处于审批中状态 */ |
| | | function canAudit(row: MesWmItemReceiptApi.ItemReceipt) { |
| | | return ( |
| | | row.status === MesWmItemReceiptStatusEnum.APPROVING && |
| | | !!currentUserId && |
| | | approverIds.value.includes(currentUserId) |
| | | ); |
| | | } |
| | | |
| | | const [FormModal, formModalApi] = useVbenModal({ |
| | | connectedComponent: Form, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const [AuditModalComp, auditModalApi] = useVbenModal({ |
| | | connectedComponent: AuditModal, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | /** 刷新表格 */ |
| | | /** 刷新表格与审核人集合 */ |
| | | function handleRefresh() { |
| | | gridApi.query(); |
| | | loadApproverIds(); |
| | | } |
| | | |
| | | /** 创建采购入库单 */ |
| | |
| | | } |
| | | } |
| | | |
| | | /** 审核 - 通过 / 不通过 */ |
| | | function handleAudit(row: MesWmItemReceiptApi.ItemReceipt, pass: boolean) { |
| | | auditModalApi.setData({ pass, row }).open(); |
| | | } |
| | | |
| | | /** 导出表格 */ |
| | | async function handleExport() { |
| | | const data = await exportItemReceipt(await gridApi.formApi.getValues()); |
| | |
| | | }, |
| | | } as VxeTableGridOptions<MesWmItemReceiptApi.ItemReceipt>, |
| | | }); |
| | | |
| | | // 进入页面即拉取审核人集合,用于控制审核按钮显隐 |
| | | loadApproverIds(); |
| | | </script> |
| | | |
| | | <template> |
| | | <Page auto-content-height> |
| | | <FormModal @success="handleRefresh" /> |
| | | <AuditModalComp @success="handleRefresh" /> |
| | | <AnSelectModal @selected="handleArrivalNoticeSelected" /> |
| | | |
| | | <Grid table-title="采购入库单列表"> |
| | |
| | | onClick: handleStock.bind(null, row), |
| | | }, |
| | | { |
| | | label: '审核', |
| | | type: 'link', |
| | | icon: ACTION_ICON.AUDIT, |
| | | auth: ['mes:wm-item-receipt:audit'], |
| | | // 仅「审批中 + 当前登录用户在审批配置的审核人名单内」才显示 |
| | | ifShow: canAudit(row), |
| | | onClick: handleAudit.bind(null, row, true), |
| | | }, |
| | | { |
| | | label: '审核不通过', |
| | | type: 'link', |
| | | danger: true, |
| | | auth: ['mes:wm-item-receipt:audit'], |
| | | // 同上,与「审核」成对出现 |
| | | ifShow: canAudit(row), |
| | | onClick: handleAudit.bind(null, row, false), |
| | | }, |
| | | { |
| | | label: '执行入库', |
| | | type: 'link', |
| | | auth: ['mes:wm-item-receipt:finish'], |