diff --git a/src/views/Company/components/FinancialPanorama/components/MainBusinessAnalysis.tsx b/src/views/Company/components/FinancialPanorama/components/MainBusinessAnalysis.tsx index f3d7da2d..7806416a 100644 --- a/src/views/Company/components/FinancialPanorama/components/MainBusinessAnalysis.tsx +++ b/src/views/Company/components/FinancialPanorama/components/MainBusinessAnalysis.tsx @@ -88,19 +88,35 @@ interface HistoricalRowData { } // 历史对比表格组件(整合业务明细) -interface HistoricalComparisonTableProps { +export interface HistoricalComparisonTableProps { historicalData: (ProductClassification | IndustryClassification)[]; businessItems: BusinessItem[]; hasProductData: boolean; latestReportType: string; + /** 是否隐藏标题(用于弹窗中避免重复) */ + hideTitle?: boolean; } -const HistoricalComparisonTable: React.FC = ({ +export const HistoricalComparisonTable: React.FC = ({ historicalData, businessItems, hasProductData, latestReportType, + hideTitle = false, }) => { + // 简化报告类型显示(2024年三季报 -> 24Q3) + const formatReportType = (reportType: string): string => { + const match = reportType.match(/(\d{4})年(.+)/); + if (!match) return reportType; + const year = match[1].slice(2); // 2024 -> 24 + const type = match[2]; + if (type.includes('一季')) return `${year}Q1`; + if (type.includes('中报') || type.includes('半年')) return `${year}Q2`; + if (type.includes('三季')) return `${year}Q3`; + if (type.includes('年报')) return `${year}Y`; + return `${year}`; + }; + // 动态生成列配置 const columns: ColumnsType = useMemo(() => { const cols: ColumnsType = [ @@ -109,23 +125,24 @@ const HistoricalComparisonTable: React.FC = ({ dataIndex: 'business', key: 'business', fixed: 'left', - width: 150, + width: 120, + ellipsis: true, }, { - title: `毛利率(${latestReportType})`, + title: `毛利率`, dataIndex: 'grossMargin', key: 'grossMargin', align: 'right', - width: 120, + width: 80, render: (value: number | undefined) => value !== undefined ? formatUtils.formatPercent(value) : '-', }, { - title: `利润(${latestReportType})`, + title: `利润`, dataIndex: 'profit', key: 'profit', align: 'right', - width: 100, + width: 90, render: (value: number | undefined) => value !== undefined ? formatUtils.formatLargeNumber(value) : '-', }, @@ -133,12 +150,13 @@ const HistoricalComparisonTable: React.FC = ({ // 添加各期间营收列 historicalData.slice(0, 4).forEach((period) => { + const shortPeriod = formatReportType(period.report_type); cols.push({ - title: `营收(${period.report_type})`, + title: shortPeriod, dataIndex: period.period, key: period.period, align: 'right', - width: 120, + width: 90, render: (value: number | string | undefined) => value !== undefined && value !== '-' ? formatUtils.formatLargeNumber(value as number) @@ -179,20 +197,19 @@ const HistoricalComparisonTable: React.FC = ({ return ( - - - 主营业务明细与历史对比 - - - + {!hideTitle && ( + + + 主营业务明细与历史对比 + + + )} + columns={columns}