From ea8c799b1946195958a2160e39a8c33dc5626f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Mon, 5 Jan 2026 16:36:12 +0800 Subject: [PATCH] =?UTF-8?q?feat(credit):=20=E4=BC=81=E4=B8=9A=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=E5=A2=9E=E5=8A=A0=E5=AD=90=E8=A1=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为18个信用相关API的导入方法添加companyId参数支持 - 在企业详情页面的各个子表tab中添加导入和刷新按钮 - 创建credit-company-related-import组件实现统一的导入弹窗 - 新增taxpayerCode字段到用户信息模型中 - 移除企业详情页面中冗余的描述项注释代码 - 实现基于企业ID或纳税人识别号的数据加载缓存机制 - 添加导入模板下载功能和文件类型验证 --- src/views/credit/creditCompany/index.vue | 1 + src/views/credit/utils/export.ts | 33 +++++++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/views/credit/creditCompany/index.vue b/src/views/credit/creditCompany/index.vue index a31d689..a203fa9 100644 --- a/src/views/credit/creditCompany/index.vue +++ b/src/views/credit/creditCompany/index.vue @@ -341,6 +341,7 @@ const exportData = () => { exportCreditData({ filename: '企业', + includeCompanyName: false, columns: [ { title: '原文件导入名称', dataIndex: 'name' }, { title: '系统匹配企业名称', dataIndex: 'matchName' }, diff --git a/src/views/credit/utils/export.ts b/src/views/credit/utils/export.ts index 8460592..2adeae8 100644 --- a/src/views/credit/utils/export.ts +++ b/src/views/credit/utils/export.ts @@ -13,6 +13,11 @@ interface ExportOptions { fetchData: () => Promise; beforeMessage?: string; successMessage?: string; + /** + * 是否自动插入“企业名称(companyName)”列(默认:true) + * 用于 credit 模块子表导出统一补齐企业名称 + */ + includeCompanyName?: boolean; } export async function exportCreditData({ @@ -20,14 +25,34 @@ export async function exportCreditData({ columns, fetchData, beforeMessage, - successMessage + successMessage, + includeCompanyName = true }: ExportOptions) { const hide = message.loading(beforeMessage || '正在导出数据...', 0); try { const list = await fetchData(); - const headerRow = columns.map((col) => col.title); + const normalizedColumns = [...columns]; + if ( + includeCompanyName && + !normalizedColumns.some((c) => c.dataIndex === 'companyName') + ) { + const companyNameCol: ExportColumn = { + title: '企业名称', + dataIndex: 'companyName' + }; + if ( + normalizedColumns.length > 0 && + normalizedColumns[0].dataIndex === 'id' + ) { + normalizedColumns.splice(1, 0, companyNameCol); + } else { + normalizedColumns.unshift(companyNameCol); + } + } + + const headerRow = normalizedColumns.map((col) => col.title); const dataRows = (list || []).map((item) => - columns.map((col) => { + normalizedColumns.map((col) => { if (col.formatter) { return col.formatter(item) ?? ''; } @@ -38,7 +63,7 @@ export async function exportCreditData({ const sheetName = filename.replace(/\s+/g, '_'); const sheet = utils.aoa_to_sheet([headerRow, ...dataRows]); - sheet['!cols'] = columns.map(() => ({ wch: 20 })); + sheet['!cols'] = normalizedColumns.map(() => ({ wch: 20 })); const workbook = { SheetNames: [sheetName],