feat(credit): 企业详情页面增加子表数据导入功能

- 为18个信用相关API的导入方法添加companyId参数支持
- 在企业详情页面的各个子表tab中添加导入和刷新按钮
- 创建credit-company-related-import组件实现统一的导入弹窗
- 新增taxpayerCode字段到用户信息模型中
- 移除企业详情页面中冗余的描述项注释代码
- 实现基于企业ID或纳税人识别号的数据加载缓存机制
- 添加导入模板下载功能和文件类型验证
This commit is contained in:
2026-01-05 16:36:12 +08:00
parent 41f273193e
commit ea8c799b19
2 changed files with 30 additions and 4 deletions

View File

@@ -341,6 +341,7 @@
const exportData = () => { const exportData = () => {
exportCreditData<CreditCompany>({ exportCreditData<CreditCompany>({
filename: '企业', filename: '企业',
includeCompanyName: false,
columns: [ columns: [
{ title: '原文件导入名称', dataIndex: 'name' }, { title: '原文件导入名称', dataIndex: 'name' },
{ title: '系统匹配企业名称', dataIndex: 'matchName' }, { title: '系统匹配企业名称', dataIndex: 'matchName' },

View File

@@ -13,6 +13,11 @@ interface ExportOptions<T> {
fetchData: () => Promise<T[]>; fetchData: () => Promise<T[]>;
beforeMessage?: string; beforeMessage?: string;
successMessage?: string; successMessage?: string;
/**
* 是否自动插入“企业名称(companyName)”列默认true
* 用于 credit 模块子表导出统一补齐企业名称
*/
includeCompanyName?: boolean;
} }
export async function exportCreditData<T>({ export async function exportCreditData<T>({
@@ -20,14 +25,34 @@ export async function exportCreditData<T>({
columns, columns,
fetchData, fetchData,
beforeMessage, beforeMessage,
successMessage successMessage,
includeCompanyName = true
}: ExportOptions<T>) { }: ExportOptions<T>) {
const hide = message.loading(beforeMessage || '正在导出数据...', 0); const hide = message.loading(beforeMessage || '正在导出数据...', 0);
try { try {
const list = await fetchData(); 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<T> = {
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) => const dataRows = (list || []).map((item) =>
columns.map((col) => { normalizedColumns.map((col) => {
if (col.formatter) { if (col.formatter) {
return col.formatter(item) ?? ''; return col.formatter(item) ?? '';
} }
@@ -38,7 +63,7 @@ export async function exportCreditData<T>({
const sheetName = filename.replace(/\s+/g, '_'); const sheetName = filename.replace(/\s+/g, '_');
const sheet = utils.aoa_to_sheet([headerRow, ...dataRows]); const sheet = utils.aoa_to_sheet([headerRow, ...dataRows]);
sheet['!cols'] = columns.map(() => ({ wch: 20 })); sheet['!cols'] = normalizedColumns.map(() => ({ wch: 20 }));
const workbook = { const workbook = {
SheetNames: [sheetName], SheetNames: [sheetName],