From fe950251bf133b5f715534df6d4bf98de05558ae Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期三, 16 九月 2026 16:48:26 +0800
Subject: [PATCH] feat(crm): 退费单/销户申请审核通过后隐藏编辑删除并提供只读详情
---
src/views/crm/cancellation/index.vue | 131 ++++++++++++++++++++++++++++++++-----------
1 files changed, 98 insertions(+), 33 deletions(-)
diff --git a/src/views/crm/cancellation/index.vue b/src/views/crm/cancellation/index.vue
index 731d4e1..700c67e 100644
--- a/src/views/crm/cancellation/index.vue
+++ b/src/views/crm/cancellation/index.vue
@@ -2,31 +2,66 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { CrmCancellationApi } from '#/api/crm/cancellation';
+import { ref } from 'vue';
+
import { Page, useVbenModal } from '@vben/common-ui';
+import { useUserStore } from '@vben/stores';
import { downloadFileFromBlobPart } from '@vben/utils';
import { message } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
- auditCancellation,
deleteCancellation,
exportCancellation,
+ getCancellationApproverIds,
getCancellationPage,
+ submitCancellation,
} from '#/api/crm/cancellation';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
+import AuditModal from './modules/audit-modal.vue';
import Form from './modules/form.vue';
+
+const userStore = useUserStore();
+const currentUserId = userStore.userInfo?.id; // 褰撳墠鐧诲綍鐢ㄦ埛 ID锛岀敤浜庡鎵逛汉鏉冮檺鍒ゆ柇
+
+/** 瀹℃壒閰嶇疆涓涓氬姟鐨勫鎵逛汉缂栧彿闆嗗悎锛屽喅瀹氥�屽鏍� / 瀹℃牳涓嶉�氳繃銆嶆寜閽槸鍚﹀睍绀� */
+const approverIds = ref<number[]>([]);
+
+/** 鎷夊彇瀹℃壒浜洪泦鍚堬紱澶辫触鏃朵繚鎸佷负绌猴紙鎸夐挳涓嶅睍绀猴級锛屼笉闃绘柇鍒楄〃鍔犺浇 */
+async function loadApproverIds() {
+ try {
+ approverIds.value = (await getCancellationApproverIds()) ?? [];
+ } catch {
+ approverIds.value = [];
+ }
+}
+
+/** 褰撳墠鐧诲綍鐢ㄦ埛鏄惁涓鸿涓氬姟鐨勫鎵逛汉锛屼笖閿�鎴风敵璇峰浜庡鎵逛腑锛�10锛� */
+function canAudit(row: CrmCancellationApi.Cancellation) {
+ return (
+ row.auditStatus === 10 &&
+ !!currentUserId &&
+ approverIds.value.includes(currentUserId)
+ );
+}
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
destroyOnClose: true,
});
-/** 鍒锋柊琛ㄦ牸 */
+const [AuditModalComp, auditModalApi] = useVbenModal({
+ connectedComponent: AuditModal,
+ destroyOnClose: true,
+});
+
+/** 鍒锋柊琛ㄦ牸涓庡鎵逛汉闆嗗悎 */
function handleRefresh() {
gridApi.query();
+ loadApproverIds();
}
/** 瀵煎嚭琛ㄦ牸 */
@@ -46,6 +81,11 @@
formModalApi.setData({ cancellation: row }).open();
}
+/** 鏌ョ湅璇︽儏锛堝鏍搁�氳繃鍚庝粎鍙煡鐪嬶紝涓嶅彲淇敼/鍒犻櫎锛� */
+function handleView(row: CrmCancellationApi.Cancellation) {
+ formModalApi.setData({ cancellation: row, readonly: true }).open();
+}
+
/** 鍒犻櫎 */
async function handleDelete(row: CrmCancellationApi.Cancellation) {
const hideLoading = message.loading({
@@ -63,22 +103,24 @@
}
}
-/** 瀹℃壒锛堥�氳繃/椹冲洖锛� */
-async function handleAudit(
- row: CrmCancellationApi.Cancellation,
- pass: boolean,
-) {
+/** 鎻愪氦瀹℃壒 - 瀹℃壒浜虹敱銆岀郴缁熺鐞� - 瀹℃壒閰嶇疆銆嶇粺涓�鎸囧畾锛屾澶勬棤闇�閫夋嫨 */
+async function handleSubmit(row: CrmCancellationApi.Cancellation) {
const hideLoading = message.loading({
- content: pass ? '瀹℃壒閫氳繃涓�...' : '瀹℃壒椹冲洖涓�...',
+ content: '姝e湪鎻愪氦瀹℃壒...',
duration: 0,
});
try {
- await auditCancellation({ id: row.id!, auditStatus: pass ? 20 : 30 });
- message.success(pass ? '瀹℃壒閫氳繃' : '瀹℃壒椹冲洖');
+ await submitCancellation(row.id!);
+ message.success('鎻愪氦瀹℃壒鎴愬姛');
handleRefresh();
} finally {
hideLoading();
}
+}
+
+/** 瀹℃牳 - 閫氳繃 / 涓嶉�氳繃 */
+function handleAudit(row: CrmCancellationApi.Cancellation, pass: boolean) {
+ auditModalApi.setData({ pass, row }).open();
}
const [Grid, gridApi] = useVbenVxeGrid({
@@ -109,11 +151,15 @@
},
} as VxeTableGridOptions<CrmCancellationApi.Cancellation>,
});
+
+// 杩涘叆椤甸潰鍗虫媺鍙栧鎵逛汉闆嗗悎锛岀敤浜庢帶鍒跺鏍告寜閽樉闅�
+loadApproverIds();
</script>
<template>
<Page auto-content-height>
<FormModal @success="handleRefresh" />
+ <AuditModalComp @success="handleRefresh" />
<Grid table-title="閿�鎴风敵璇峰垪琛�">
<template #toolbar-tools>
<TableAction
@@ -139,34 +185,51 @@
<TableAction
:actions="[
{
- label: '閫氳繃',
- type: 'link',
- icon: ACTION_ICON.AUDIT,
- auth: ['crm:cancellation:update'],
- ifShow: row.auditStatus === 0 || row.auditStatus === 10,
- popConfirm: {
- title: '纭瀹℃壒閫氳繃璇ラ攢鎴风敵璇凤紵',
- confirm: handleAudit.bind(null, row, true),
- },
- },
- {
- label: '椹冲洖',
- type: 'link',
- danger: true,
- icon: ACTION_ICON.AUDIT,
- auth: ['crm:cancellation:update'],
- ifShow: row.auditStatus === 0 || row.auditStatus === 10,
- popConfirm: {
- title: '纭椹冲洖璇ラ攢鎴风敵璇凤紵',
- confirm: handleAudit.bind(null, row, false),
- },
- },
- {
label: $t('common.edit'),
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['crm:cancellation:update'],
+ // 瀹℃牳閫氳繃(20)鐨勯攢鎴风敵璇蜂笉鍏佽淇敼锛岄殣钘忕紪杈戞寜閽紙鍚庣鍚屾寮烘牎楠屾嫤鎴級
+ ifShow: row.auditStatus !== 20,
onClick: handleEdit.bind(null, row),
+ },
+ {
+ label: '鏌ョ湅',
+ type: 'link',
+ auth: ['crm:cancellation:query'],
+ // 瀹℃牳閫氳繃鍚庝粎鎻愪緵鍙璇︽儏鍏ュ彛
+ ifShow: row.auditStatus === 20,
+ onClick: handleView.bind(null, row),
+ },
+ {
+ label: '鎻愪氦瀹℃壒',
+ type: 'link',
+ auth: ['crm:cancellation:update'],
+ // 瀹℃壒浜虹敱瀹℃壒閰嶇疆缁熶竴鎸囧畾锛屾彁浜ゅ墠浠呬簩娆$‘璁わ紝涓嶅啀寮归�夋祦绋嬫
+ popConfirm: {
+ title: '纭鎻愪氦瀹℃壒锛熸彁浜ゅ悗鐢卞鎵归厤缃腑鎸囧畾鐨勫鎵逛汉澶勭悊銆�',
+ confirm: handleSubmit.bind(null, row),
+ },
+ // 鏈彁浜�(0) 涓� 瀹℃牳涓嶉�氳繃(30) 鍧囧彲鎻愪氦锛屽悗鑰呴渶淇敼鍚庨噸鏂版彁浜�
+ ifShow: row.auditStatus === 0 || row.auditStatus === 30,
+ },
+ {
+ label: '瀹℃牳',
+ type: 'link',
+ icon: ACTION_ICON.AUDIT,
+ auth: ['crm:cancellation:audit'],
+ // 浠呫�屽鎵逛腑 + 褰撳墠鐧诲綍鐢ㄦ埛鍦ㄥ鎵归厤缃殑瀹℃壒浜哄悕鍗曞唴銆嶆墠鏄剧ず
+ ifShow: canAudit(row),
+ onClick: handleAudit.bind(null, row, true),
+ },
+ {
+ label: '瀹℃牳涓嶉�氳繃',
+ type: 'link',
+ danger: true,
+ auth: ['crm:cancellation:audit'],
+ // 鍚屼笂锛屼笌銆屽鏍搞�嶆垚瀵瑰嚭鐜�
+ ifShow: canAudit(row),
+ onClick: handleAudit.bind(null, row, false),
},
{
label: $t('common.delete'),
@@ -174,6 +237,8 @@
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['crm:cancellation:delete'],
+ // 瀹℃牳閫氳繃(20)鐨勯攢鎴风敵璇蜂笉鍏佽鍒犻櫎锛堝悗绔悓姝ュ己鏍¢獙鎷︽埅锛�
+ ifShow: row.auditStatus !== 20,
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [
row.cancellationNo ?? '',
--
Gitblit v1.9.3