From 3dcc8b30db96a11e307449ce82fa232b9edaeec2 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Tue, 4 Aug 2026 11:22:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customers/pages/CustomersView.test.ts | 32 ++++++++++++++++++- src/modules/customers/pages/CustomersView.vue | 18 ++++++++--- .../exportTaskCreatedDialog.test.ts | 24 ++++++++++++++ .../components/exportTaskCreatedDialog.ts | 26 +++++++++++++++ 4 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 src/shared/components/exportTaskCreatedDialog.test.ts create mode 100644 src/shared/components/exportTaskCreatedDialog.ts diff --git a/src/modules/customers/pages/CustomersView.test.ts b/src/modules/customers/pages/CustomersView.test.ts index 90ac08c4..0aa90d93 100644 --- a/src/modules/customers/pages/CustomersView.test.ts +++ b/src/modules/customers/pages/CustomersView.test.ts @@ -19,8 +19,16 @@ import { createPlatformExportTask } from '@/modules/downloads' import { useAccessPreviewStore } from '@/core/access/accessPreview' import { useAuthStore } from '@/core/auth/auth' import QueryToolbar from '@/shared/components/QueryToolbar.vue' +import { showExportTaskCreatedDialog } from '@/shared/components/exportTaskCreatedDialog' import CustomersView from './CustomersView.vue' +const { routerPush } = vi.hoisted(() => ({ routerPush: vi.fn() })) + +vi.mock('vue-router', async (importOriginal) => ({ + ...await importOriginal(), + useRouter: () => ({ push: routerPush }), +})) + vi.mock('@/modules/iam', () => ({ approveEnterpriseReview: vi.fn(), changePlatformTenantStatus: vi.fn(), @@ -39,6 +47,7 @@ vi.mock('@/modules/iam', () => ({ })) vi.mock('@/modules/downloads', () => ({ createPlatformExportTask: vi.fn() })) +vi.mock('@/shared/components/exportTaskCreatedDialog', () => ({ showExportTaskCreatedDialog: vi.fn() })) class ResizeObserverStub implements ResizeObserver { observe() {} @@ -97,7 +106,10 @@ describe('CustomersView', () => { vi.mocked(uploadPlatformTenantQualification).mockResolvedValue({ qualificationId: 'qualification-1', reviewId: null, tenantStatus: 'PROFILE_REQUIRED', documentUrl: '/files/license.png', }) - vi.mocked(createPlatformExportTask).mockResolvedValue({ id: 'export-1', status: 'PENDING' } as never) + vi.mocked(createPlatformExportTask).mockResolvedValue({ + id: 'export-1', taskName: '客户列表', taskNo: 'EXP2084', status: 'PENDING', + } as never) + vi.mocked(showExportTaskCreatedDialog).mockResolvedValue(false) }) it('loads the complete customer detail before editing masked list fields', async () => { @@ -272,9 +284,27 @@ describe('CustomersView', () => { exportType: 'CUSTOMER_LIST', format: 'XLSX', taskName: '客户列表', parameters: { keyword: 'Acme', status: 'ACTIVE' }, }) + expect(showExportTaskCreatedDialog).toHaveBeenCalledWith({ taskName: '客户列表', taskNo: 'EXP2084' }) expect(listPlatformTenants).toHaveBeenCalledTimes(1) }) + it('opens the download center when the export-created dialog action is confirmed', async () => { + vi.mocked(createPlatformExportTask).mockResolvedValue({ + id: 'export-1', taskName: '客户列表', taskNo: 'EXP2084', status: 'PENDING', + } as never) + vi.mocked(showExportTaskCreatedDialog).mockResolvedValue(true) + mount(CustomersView, { attachTo: document.body, global: { plugins: [pinia, ElementPlus] } }) + await flushPromises() + + const exportButton = [...document.querySelectorAll('button')] + .find((button) => button.textContent?.trim() === '导出Excel') + exportButton?.click() + await flushPromises() + + expect(showExportTaskCreatedDialog).toHaveBeenCalledWith({ taskName: '客户列表', taskNo: 'EXP2084' }) + expect(routerPush).toHaveBeenCalledWith({ name: 'download-center' }) + }) + it('hides customer export when the stable export permission is absent', async () => { const auth = useAuthStore() auth.permissions = ['platform:customer:list', 'platform:customer:view'] diff --git a/src/modules/customers/pages/CustomersView.vue b/src/modules/customers/pages/CustomersView.vue index ced8fd4e..47ebbfcd 100644 --- a/src/modules/customers/pages/CustomersView.vue +++ b/src/modules/customers/pages/CustomersView.vue @@ -1,5 +1,6 @@