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/modules/form.vue |   11 ++
 src/views/crm/refund/index.vue              |  128 +++++++++++++++++++------
 src/views/crm/refund/modules/form.vue       |   11 ++
 src/views/crm/cancellation/index.vue        |  131 +++++++++++++++++++------
 4 files changed, 218 insertions(+), 63 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 ?? '',
diff --git a/src/views/crm/cancellation/modules/form.vue b/src/views/crm/cancellation/modules/form.vue
index 5a7fe02..77e8255 100644
--- a/src/views/crm/cancellation/modules/form.vue
+++ b/src/views/crm/cancellation/modules/form.vue
@@ -18,11 +18,17 @@
 
 type CancellationFormModalData = {
   cancellation?: Pick<CrmCancellationApi.Cancellation, 'id'>;
+  /** 鍙妯″紡锛氬鏍搁�氳繃鐨勯攢鎴风敵璇蜂粎鍏佽鏌ョ湅璇︽儏 */
+  readonly?: boolean;
 };
 
 const emit = defineEmits(['success']);
 const formData = ref<Partial<CrmCancellationApi.Cancellation>>();
+const readonly = ref(false);
 const getTitle = computed(() => {
+  if (readonly.value) {
+    return '閿�鎴风敵璇疯鎯�';
+  }
   return formData.value?.id
     ? $t('ui.actionTitle.edit', ['閿�鎴风敵璇�'])
     : $t('ui.actionTitle.create', ['閿�鎴风敵璇�']);
@@ -67,11 +73,16 @@
   async onOpenChange(isOpen: boolean) {
     if (!isOpen) {
       formData.value = undefined;
+      readonly.value = false;
       return;
     }
     formApi.setState({ schema: useFormSchema(formApi) });
     await formApi.resetForm();
     const data = modalApi.getData() as null | CancellationFormModalData;
+    // 鍙璇︽儏锛氱鐢ㄥ叏閮ㄥ瓧娈靛苟闅愯棌銆岀‘瀹氥�嶆寜閽紱缂栬緫/鏂板鍒欐仮澶嶅彲鎿嶄綔
+    readonly.value = !!data?.readonly;
+    formApi.setDisabled(readonly.value);
+    modalApi.setState({ showConfirmButton: !readonly.value });
     if (!data?.cancellation?.id) {
       return;
     }
diff --git a/src/views/crm/refund/index.vue b/src/views/crm/refund/index.vue
index bb053b4..e60b264 100644
--- a/src/views/crm/refund/index.vue
+++ b/src/views/crm/refund/index.vue
@@ -2,31 +2,66 @@
 import type { VxeTableGridOptions } from '#/adapter/vxe-table';
 import type { CrmRefundApi } from '#/api/crm/refund';
 
+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 {
-  auditRefund,
   deleteRefund,
   exportRefund,
+  getRefundApproverIds,
   getRefundPage,
+  submitRefund,
 } from '#/api/crm/refund';
 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 getRefundApproverIds()) ?? [];
+  } catch {
+    approverIds.value = [];
+  }
+}
+
+/** 褰撳墠鐧诲綍鐢ㄦ埛鏄惁涓鸿涓氬姟鐨勫鎵逛汉锛屼笖閫�璐瑰崟澶勪簬瀹℃壒涓紙10锛� */
+function canAudit(row: CrmRefundApi.Refund) {
+  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({ refund: row }).open();
 }
 
+/** 鏌ョ湅璇︽儏锛堝鏍搁�氳繃鍚庝粎鍙煡鐪嬶紝涓嶅彲淇敼/鍒犻櫎锛� */
+function handleView(row: CrmRefundApi.Refund) {
+  formModalApi.setData({ refund: row, readonly: true }).open();
+}
+
 /** 鍒犻櫎 */
 async function handleDelete(row: CrmRefundApi.Refund) {
   const hideLoading = message.loading({
@@ -61,19 +101,24 @@
   }
 }
 
-/** 瀹℃壒锛堥�氳繃/椹冲洖锛� */
-async function handleAudit(row: CrmRefundApi.Refund, pass: boolean) {
+/** 鎻愪氦瀹℃壒 - 瀹℃壒浜虹敱銆岀郴缁熺鐞� - 瀹℃壒閰嶇疆銆嶇粺涓�鎸囧畾锛屾澶勬棤闇�閫夋嫨 */
+async function handleSubmit(row: CrmRefundApi.Refund) {
   const hideLoading = message.loading({
-    content: pass ? '瀹℃壒閫氳繃涓�...' : '瀹℃壒椹冲洖涓�...',
+    content: '姝e湪鎻愪氦瀹℃壒...',
     duration: 0,
   });
   try {
-    await auditRefund({ id: row.id!, auditStatus: pass ? 20 : 30 });
-    message.success(pass ? '瀹℃壒閫氳繃' : '瀹℃壒椹冲洖');
+    await submitRefund(row.id!);
+    message.success('鎻愪氦瀹℃壒鎴愬姛');
     handleRefresh();
   } finally {
     hideLoading();
   }
+}
+
+/** 瀹℃牳 - 閫氳繃 / 涓嶉�氳繃 */
+function handleAudit(row: CrmRefundApi.Refund, pass: boolean) {
+  auditModalApi.setData({ pass, row }).open();
 }
 
 const [Grid, gridApi] = useVbenVxeGrid({
@@ -104,11 +149,15 @@
     },
   } as VxeTableGridOptions<CrmRefundApi.Refund>,
 });
+
+// 杩涘叆椤甸潰鍗虫媺鍙栧鎵逛汉闆嗗悎锛岀敤浜庢帶鍒跺鏍告寜閽樉闅�
+loadApproverIds();
 </script>
 
 <template>
   <Page auto-content-height>
     <FormModal @success="handleRefresh" />
+    <AuditModalComp @success="handleRefresh" />
     <Grid table-title="閫�璐瑰崟鍒楄〃">
       <template #toolbar-tools>
         <TableAction
@@ -134,34 +183,51 @@
         <TableAction
           :actions="[
             {
-              label: '閫氳繃',
-              type: 'link',
-              icon: ACTION_ICON.AUDIT,
-              auth: ['crm:refund: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:refund: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:refund:update'],
+              // 瀹℃牳閫氳繃(20)鐨勯��璐瑰崟涓嶅厑璁镐慨鏀癸紝闅愯棌缂栬緫鎸夐挳锛堝悗绔悓姝ュ己鏍¢獙鎷︽埅锛�
+              ifShow: row.auditStatus !== 20,
               onClick: handleEdit.bind(null, row),
+            },
+            {
+              label: '鏌ョ湅',
+              type: 'link',
+              auth: ['crm:refund:query'],
+              // 瀹℃牳閫氳繃鍚庝粎鎻愪緵鍙璇︽儏鍏ュ彛
+              ifShow: row.auditStatus === 20,
+              onClick: handleView.bind(null, row),
+            },
+            {
+              label: '鎻愪氦瀹℃壒',
+              type: 'link',
+              auth: ['crm:refund: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:refund:audit'],
+              // 浠呫�屽鎵逛腑 + 褰撳墠鐧诲綍鐢ㄦ埛鍦ㄥ鎵归厤缃殑瀹℃壒浜哄悕鍗曞唴銆嶆墠鏄剧ず
+              ifShow: canAudit(row),
+              onClick: handleAudit.bind(null, row, true),
+            },
+            {
+              label: '瀹℃牳涓嶉�氳繃',
+              type: 'link',
+              danger: true,
+              auth: ['crm:refund:audit'],
+              // 鍚屼笂锛屼笌銆屽鏍搞�嶆垚瀵瑰嚭鐜�
+              ifShow: canAudit(row),
+              onClick: handleAudit.bind(null, row, false),
             },
             {
               label: $t('common.delete'),
@@ -169,6 +235,8 @@
               danger: true,
               icon: ACTION_ICON.DELETE,
               auth: ['crm:refund:delete'],
+              // 瀹℃牳閫氳繃(20)鐨勯��璐瑰崟涓嶅厑璁稿垹闄わ紙鍚庣鍚屾寮烘牎楠屾嫤鎴級
+              ifShow: row.auditStatus !== 20,
               popConfirm: {
                 title: $t('ui.actionMessage.deleteConfirm', [
                   row.refundNo ?? '',
diff --git a/src/views/crm/refund/modules/form.vue b/src/views/crm/refund/modules/form.vue
index 60ae9e6..e0dd436 100644
--- a/src/views/crm/refund/modules/form.vue
+++ b/src/views/crm/refund/modules/form.vue
@@ -18,11 +18,17 @@
 
 type RefundFormModalData = {
   refund?: Pick<CrmRefundApi.Refund, 'id'>;
+  /** 鍙妯″紡锛氬鏍搁�氳繃鐨勯��璐瑰崟浠呭厑璁告煡鐪嬭鎯� */
+  readonly?: boolean;
 };
 
 const emit = defineEmits(['success']);
 const formData = ref<Partial<CrmRefundApi.Refund>>();
+const readonly = ref(false);
 const getTitle = computed(() => {
+  if (readonly.value) {
+    return '閫�璐瑰崟璇︽儏';
+  }
   return formData.value?.id
     ? $t('ui.actionTitle.edit', ['閫�璐瑰崟'])
     : $t('ui.actionTitle.create', ['閫�璐瑰崟']);
@@ -64,11 +70,16 @@
   async onOpenChange(isOpen: boolean) {
     if (!isOpen) {
       formData.value = undefined;
+      readonly.value = false;
       return;
     }
     formApi.setState({ schema: useFormSchema(formApi) });
     await formApi.resetForm();
     const data = modalApi.getData() as null | RefundFormModalData;
+    // 鍙璇︽儏锛氱鐢ㄥ叏閮ㄥ瓧娈靛苟闅愯棌銆岀‘瀹氥�嶆寜閽紱缂栬緫/鏂板鍒欐仮澶嶅彲鎿嶄綔
+    readonly.value = !!data?.readonly;
+    formApi.setDisabled(readonly.value);
+    modalApi.setState({ showConfirmButton: !readonly.value });
     if (!data?.refund?.id) {
       return;
     }

--
Gitblit v1.9.3