| | |
| | | import type { VxeTableGridOptions } from '#/adapter/vxe-table'; |
| | | import type { ErpFinancePaymentApi } from '#/api/erp/finance/payment'; |
| | | |
| | | import { ref } from 'vue'; |
| | | import { useRouter } from 'vue-router'; |
| | | import { onMounted, ref } from 'vue'; |
| | | |
| | | import { Page, useVbenModal } from '@vben/common-ui'; |
| | | import { useUserStore } from '@vben/stores'; |
| | | import { downloadFileFromBlobPart, isEmpty } from '@vben/utils'; |
| | | |
| | | import { message } from 'ant-design-vue'; |
| | |
| | | import { |
| | | deleteFinancePayment, |
| | | exportFinancePayment, |
| | | getFinancePaymentApproveProcessList, |
| | | getFinancePaymentApproverUserIds, |
| | | getFinancePaymentPage, |
| | | submitFinancePayment, |
| | | } from '#/api/erp/finance/payment'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useGridColumns, useGridFormSchema } from './data'; |
| | | import AuditModal from './modules/audit-modal.vue'; |
| | | import Form from './modules/form.vue'; |
| | | import ProcessSelectModal from './modules/process-select-modal.vue'; |
| | | |
| | | /** ERP 付款单列表 */ |
| | | defineOptions({ name: 'ErpFinancePayment' }); |
| | | |
| | | const router = useRouter(); |
| | | const userStore = useUserStore(); |
| | | |
| | | /** 当前业务类型的审批人编号集合,用于判断是否展示审核按钮 */ |
| | | const approverIds = ref<number[]>([]); |
| | | /** 当前登录用户编号 */ |
| | | const currentUserId = userStore.userInfo?.id; |
| | | |
| | | const [FormModal, formModalApi] = useVbenModal({ |
| | | connectedComponent: Form, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const [ProcessModal, processModalApi] = useVbenModal({ |
| | | connectedComponent: ProcessSelectModal, |
| | | const [AuditModalComp, auditModalApi] = useVbenModal({ |
| | | connectedComponent: AuditModal, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | /** 刷新表格 */ |
| | | /** 刷新表格、审批人集合 */ |
| | | function handleRefresh() { |
| | | gridApi.query(); |
| | | loadApproverIds(); |
| | | } |
| | | |
| | | /** 加载当前业务类型的审批人编号集合 */ |
| | | async function loadApproverIds() { |
| | | try { |
| | | approverIds.value = (await getFinancePaymentApproverUserIds()) ?? []; |
| | | } catch { |
| | | approverIds.value = []; |
| | | } |
| | | } |
| | | |
| | | /** 当前用户是否为该业务类型的审批人,且单据处于审批中 */ |
| | | function canAudit(row: ErpFinancePaymentApi.FinancePayment) { |
| | | return ( |
| | | row.status === 15 && approverIds.value.includes(currentUserId as number) |
| | | ); |
| | | } |
| | | |
| | | /** 导出表格 */ |
| | |
| | | } |
| | | } |
| | | |
| | | /** 提交审批 - 先获取流程列表 */ |
| | | /** 提交审核 - 后端按审批配置校验审批人,无需前端选择流程 */ |
| | | async function handleSubmit(row: ErpFinancePaymentApi.FinancePayment) { |
| | | const hideLoading = message.loading({ |
| | | content: '获取审批流程...', |
| | | content: '正在提交审核...', |
| | | duration: 0, |
| | | }); |
| | | try { |
| | | const processList = await getFinancePaymentApproveProcessList(); |
| | | hideLoading(); |
| | | if (!processList || processList.length === 0) { |
| | | message.warning('暂无可用审批流程,请先配置 BPM 流程'); |
| | | return; |
| | | } |
| | | // 打开流程选择弹窗 |
| | | processModalApi.setData({ id: row.id, processList }).open(); |
| | | } catch { |
| | | await submitFinancePayment(row.id!); |
| | | message.success('提交成功,等待审批人审核'); |
| | | handleRefresh(); |
| | | } finally { |
| | | hideLoading(); |
| | | } |
| | | } |
| | | |
| | | /** 查看审批详情 */ |
| | | function handleProcessDetail(row: ErpFinancePaymentApi.FinancePayment) { |
| | | if (!row.processInstanceId) { |
| | | message.warning('该付款单尚未提交审批'); |
| | | /** 审核 - 通过 / 不通过 */ |
| | | function handleAudit(row: ErpFinancePaymentApi.FinancePayment, pass: boolean) { |
| | | auditModalApi.setData({ pass, row }).open(); |
| | | } |
| | | |
| | | /** 查看审批记录 - 轻量级审批不再跳转 BPM 流程详情 */ |
| | | function handleViewProcess(row: ErpFinancePaymentApi.FinancePayment) { |
| | | const parts: string[] = []; |
| | | if (row.reviewerName) { |
| | | parts.push(`审核人:${row.reviewerName}`); |
| | | } |
| | | if (row.reviewTime) { |
| | | parts.push(`审核时间:${row.reviewTime}`); |
| | | } |
| | | if (row.reviewRemark) { |
| | | parts.push(`审核意见:${row.reviewRemark}`); |
| | | } |
| | | if (parts.length === 0) { |
| | | message.info('该付款单暂无审核记录'); |
| | | return; |
| | | } |
| | | router.push({ |
| | | name: 'BpmProcessInstanceDetail', |
| | | query: { id: row.processInstanceId }, |
| | | }); |
| | | message.info(parts.join(' ')); |
| | | } |
| | | |
| | | const checkedIds = ref<number[]>([]); |
| | |
| | | checkboxChange: handleRowCheckboxChange, |
| | | }, |
| | | }); |
| | | |
| | | onMounted(() => { |
| | | loadApproverIds(); |
| | | }); |
| | | </script> |
| | | |
| | | <template> |
| | | <Page auto-content-height><FormModal @success="handleRefresh" /> |
| | | <ProcessModal @success="handleRefresh" /> |
| | | <AuditModalComp @success="handleRefresh" /> |
| | | <Grid table-title="付款单列表"> |
| | | <template #toolbar-tools> |
| | | <TableAction |
| | |
| | | type: 'link', |
| | | icon: ACTION_ICON.AUDIT, |
| | | auth: ['erp:finance-payment:update'], |
| | | // 未审核(含审核不通过退回)均可提交,退回后需修改再重新提交 |
| | | ifShow: () => row.status === 10, |
| | | onClick: handleSubmit.bind(null, row), |
| | | }, |
| | | { |
| | | label: '审核', |
| | | type: 'link', |
| | | icon: ACTION_ICON.AUDIT, |
| | | auth: ['erp:finance-payment:audit'], |
| | | // 仅「审批中 + 当前登录用户是审批人」才显示,其他人看不到该按钮 |
| | | ifShow: canAudit(row), |
| | | onClick: handleAudit.bind(null, row, true), |
| | | }, |
| | | { |
| | | label: '审核不通过', |
| | | type: 'link', |
| | | danger: true, |
| | | icon: ACTION_ICON.AUDIT, |
| | | auth: ['erp:finance-payment:audit'], |
| | | ifShow: canAudit(row), |
| | | onClick: handleAudit.bind(null, row, false), |
| | | }, |
| | | { |
| | | label: '查看审批', |
| | | type: 'link', |
| | | icon: ACTION_ICON.VIEW, |
| | | auth: ['erp:finance-payment:query'], |
| | | ifShow: () => row.status !== 10 && !!row.processInstanceId, |
| | | onClick: handleProcessDetail.bind(null, row), |
| | | ifShow: () => row.status === 20 || !!row.reviewRemark, |
| | | onClick: handleViewProcess.bind(null, row), |
| | | }, |
| | | { |
| | | label: $t('common.delete'), |