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/wls/itemreceipt/index.vue | 64 +++++++++++++++++++++++++++++++
1 files changed, 63 insertions(+), 1 deletions(-)
diff --git a/src/views/wls/itemreceipt/index.vue b/src/views/wls/itemreceipt/index.vue
index 552e77a..407af51 100644
--- a/src/views/wls/itemreceipt/index.vue
+++ b/src/views/wls/itemreceipt/index.vue
@@ -2,8 +2,11 @@
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';
@@ -14,16 +17,47 @@
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,
});
@@ -32,9 +66,10 @@
destroyOnClose: true,
});
-/** 鍒锋柊琛ㄦ牸 */
+/** 鍒锋柊琛ㄦ牸涓庡鏍镐汉闆嗗悎 */
function handleRefresh() {
gridApi.query();
+ loadApproverIds();
}
/** 鍒涘缓閲囪喘鍏ュ簱鍗� */
@@ -106,6 +141,11 @@
}
}
+/** 瀹℃牳 - 閫氳繃 / 涓嶉�氳繃 */
+function handleAudit(row: MesWmItemReceiptApi.ItemReceipt, pass: boolean) {
+ auditModalApi.setData({ pass, row }).open();
+}
+
/** 瀵煎嚭琛ㄦ牸 */
async function handleExport() {
const data = await exportItemReceipt(await gridApi.formApi.getValues());
@@ -141,11 +181,15 @@
},
} as VxeTableGridOptions<MesWmItemReceiptApi.ItemReceipt>,
});
+
+// 杩涘叆椤甸潰鍗虫媺鍙栧鏍镐汉闆嗗悎锛岀敤浜庢帶鍒跺鏍告寜閽樉闅�
+loadApproverIds();
</script>
<template>
<Page auto-content-height>
<FormModal @success="handleRefresh" />
+ <AuditModalComp @success="handleRefresh" />
<AnSelectModal @selected="handleArrivalNoticeSelected" />
<Grid table-title="閲囪喘鍏ュ簱鍗曞垪琛�">
@@ -212,6 +256,24 @@
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'],
--
Gitblit v1.9.3