From 91eff4781fa4142d1f62d30a0fa1de5cae424eaf Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期三, 16 九月 2026 18:23:12 +0800
Subject: [PATCH] refactor: 单据审核改为审批配置状态机(前端统一审核弹窗)
---
src/views/erp/finance/payment/index.vue | 113 +++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 83 insertions(+), 30 deletions(-)
diff --git a/src/views/erp/finance/payment/index.vue b/src/views/erp/finance/payment/index.vue
index 8a9658e..cf696df 100644
--- a/src/views/erp/finance/payment/index.vue
+++ b/src/views/erp/finance/payment/index.vue
@@ -2,10 +2,10 @@
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';
@@ -14,33 +14,56 @@
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)
+ );
}
/** 瀵煎嚭琛ㄦ牸 */
@@ -74,36 +97,43 @@
}
}
-/** 鎻愪氦瀹℃壒 - 鍏堣幏鍙栨祦绋嬪垪琛� */
+/** 鎻愪氦瀹℃牳 - 鍚庣鎸夊鎵归厤缃牎楠屽鎵逛汉锛屾棤闇�鍓嶇閫夋嫨娴佺▼ */
async function handleSubmit(row: ErpFinancePaymentApi.FinancePayment) {
const hideLoading = message.loading({
- content: '鑾峰彇瀹℃壒娴佺▼...',
+ content: '姝e湪鎻愪氦瀹℃牳...',
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[]>([]);
@@ -153,11 +183,15 @@
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
@@ -221,16 +255,35 @@
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'),
--
Gitblit v1.9.3