refactor(FinancialPanorama): 添加 TypeScript 类型定义
- 定义基础类型:StockInfo、财务报表数据结构 - 定义业务类型:主营业务、行业排名、业绩预告 - 定义组件 Props 类型:9个子组件的 Props 接口 - 定义指标配置类型:MetricConfig、MetricSectionConfig 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
437
src/views/Company/components/FinancialPanorama/types.ts
Normal file
437
src/views/Company/components/FinancialPanorama/types.ts
Normal file
@@ -0,0 +1,437 @@
|
||||
/**
|
||||
* FinancialPanorama 组件类型定义
|
||||
*/
|
||||
|
||||
// ==================== 基础类型 ====================
|
||||
|
||||
/** 股票基本信息 */
|
||||
export interface StockInfo {
|
||||
stock_code: string;
|
||||
stock_name: string;
|
||||
key_metrics?: {
|
||||
eps?: number;
|
||||
roe?: number;
|
||||
gross_margin?: number;
|
||||
net_margin?: number;
|
||||
roa?: number;
|
||||
};
|
||||
growth_rates?: {
|
||||
revenue_growth?: number;
|
||||
profit_growth?: number;
|
||||
asset_growth?: number;
|
||||
equity_growth?: number;
|
||||
};
|
||||
financial_summary?: {
|
||||
revenue?: number;
|
||||
net_profit?: number;
|
||||
total_assets?: number;
|
||||
total_liabilities?: number;
|
||||
};
|
||||
latest_forecast?: {
|
||||
forecast_type: string;
|
||||
content: string;
|
||||
};
|
||||
}
|
||||
|
||||
// ==================== 财务报表类型 ====================
|
||||
|
||||
/** 资产负债表数据 */
|
||||
export interface BalanceSheetData {
|
||||
period: string;
|
||||
assets: {
|
||||
current_assets: {
|
||||
cash?: number;
|
||||
trading_financial_assets?: number;
|
||||
notes_receivable?: number;
|
||||
accounts_receivable?: number;
|
||||
prepayments?: number;
|
||||
other_receivables?: number;
|
||||
inventory?: number;
|
||||
contract_assets?: number;
|
||||
other_current_assets?: number;
|
||||
total?: number;
|
||||
};
|
||||
non_current_assets: {
|
||||
long_term_equity_investments?: number;
|
||||
investment_property?: number;
|
||||
fixed_assets?: number;
|
||||
construction_in_progress?: number;
|
||||
right_of_use_assets?: number;
|
||||
intangible_assets?: number;
|
||||
goodwill?: number;
|
||||
deferred_tax_assets?: number;
|
||||
other_non_current_assets?: number;
|
||||
total?: number;
|
||||
};
|
||||
total?: number;
|
||||
};
|
||||
liabilities: {
|
||||
current_liabilities: {
|
||||
short_term_borrowings?: number;
|
||||
notes_payable?: number;
|
||||
accounts_payable?: number;
|
||||
advance_receipts?: number;
|
||||
contract_liabilities?: number;
|
||||
employee_compensation_payable?: number;
|
||||
taxes_payable?: number;
|
||||
other_payables?: number;
|
||||
non_current_liabilities_due_within_one_year?: number;
|
||||
total?: number;
|
||||
};
|
||||
non_current_liabilities: {
|
||||
long_term_borrowings?: number;
|
||||
bonds_payable?: number;
|
||||
lease_liabilities?: number;
|
||||
deferred_tax_liabilities?: number;
|
||||
other_non_current_liabilities?: number;
|
||||
total?: number;
|
||||
};
|
||||
total?: number;
|
||||
};
|
||||
equity: {
|
||||
share_capital?: number;
|
||||
capital_reserve?: number;
|
||||
surplus_reserve?: number;
|
||||
undistributed_profit?: number;
|
||||
treasury_stock?: number;
|
||||
other_comprehensive_income?: number;
|
||||
parent_company_equity?: number;
|
||||
minority_interests?: number;
|
||||
total?: number;
|
||||
};
|
||||
}
|
||||
|
||||
/** 利润表数据 */
|
||||
export interface IncomeStatementData {
|
||||
period: string;
|
||||
revenue: {
|
||||
total_operating_revenue?: number;
|
||||
operating_revenue?: number;
|
||||
other_income?: number;
|
||||
};
|
||||
costs: {
|
||||
total_operating_cost?: number;
|
||||
operating_cost?: number;
|
||||
taxes_and_surcharges?: number;
|
||||
selling_expenses?: number;
|
||||
admin_expenses?: number;
|
||||
rd_expenses?: number;
|
||||
financial_expenses?: number;
|
||||
interest_expense?: number;
|
||||
interest_income?: number;
|
||||
three_expenses_total?: number;
|
||||
four_expenses_total?: number;
|
||||
asset_impairment_loss?: number;
|
||||
credit_impairment_loss?: number;
|
||||
};
|
||||
other_gains: {
|
||||
fair_value_change?: number;
|
||||
investment_income?: number;
|
||||
investment_income_from_associates?: number;
|
||||
exchange_income?: number;
|
||||
asset_disposal_income?: number;
|
||||
};
|
||||
profit: {
|
||||
operating_profit?: number;
|
||||
total_profit?: number;
|
||||
income_tax_expense?: number;
|
||||
net_profit?: number;
|
||||
parent_net_profit?: number;
|
||||
minority_profit?: number;
|
||||
continuing_operations_net_profit?: number;
|
||||
discontinued_operations_net_profit?: number;
|
||||
};
|
||||
non_operating: {
|
||||
non_operating_income?: number;
|
||||
non_operating_expenses?: number;
|
||||
};
|
||||
per_share: {
|
||||
basic_eps?: number;
|
||||
diluted_eps?: number;
|
||||
};
|
||||
comprehensive_income: {
|
||||
other_comprehensive_income?: number;
|
||||
total_comprehensive_income?: number;
|
||||
parent_comprehensive_income?: number;
|
||||
minority_comprehensive_income?: number;
|
||||
};
|
||||
}
|
||||
|
||||
/** 现金流量表数据 */
|
||||
export interface CashflowData {
|
||||
period: string;
|
||||
operating_activities: {
|
||||
inflow: {
|
||||
cash_from_sales?: number;
|
||||
};
|
||||
outflow: {
|
||||
cash_for_goods?: number;
|
||||
};
|
||||
net_flow?: number;
|
||||
};
|
||||
investment_activities: {
|
||||
net_flow?: number;
|
||||
};
|
||||
financing_activities: {
|
||||
net_flow?: number;
|
||||
};
|
||||
cash_changes: {
|
||||
net_increase?: number;
|
||||
ending_balance?: number;
|
||||
};
|
||||
key_metrics: {
|
||||
free_cash_flow?: number;
|
||||
};
|
||||
}
|
||||
|
||||
/** 财务指标数据 */
|
||||
export interface FinancialMetricsData {
|
||||
period: string;
|
||||
profitability: {
|
||||
roe?: number;
|
||||
roe_deducted?: number;
|
||||
roe_weighted?: number;
|
||||
roa?: number;
|
||||
gross_margin?: number;
|
||||
net_profit_margin?: number;
|
||||
operating_profit_margin?: number;
|
||||
cost_profit_ratio?: number;
|
||||
ebit?: number;
|
||||
};
|
||||
per_share_metrics: {
|
||||
eps?: number;
|
||||
basic_eps?: number;
|
||||
diluted_eps?: number;
|
||||
deducted_eps?: number;
|
||||
bvps?: number;
|
||||
operating_cash_flow_ps?: number;
|
||||
capital_reserve_ps?: number;
|
||||
undistributed_profit_ps?: number;
|
||||
};
|
||||
growth: {
|
||||
revenue_growth?: number;
|
||||
net_profit_growth?: number;
|
||||
deducted_profit_growth?: number;
|
||||
parent_profit_growth?: number;
|
||||
operating_cash_flow_growth?: number;
|
||||
total_asset_growth?: number;
|
||||
equity_growth?: number;
|
||||
fixed_asset_growth?: number;
|
||||
};
|
||||
operational_efficiency: {
|
||||
total_asset_turnover?: number;
|
||||
fixed_asset_turnover?: number;
|
||||
current_asset_turnover?: number;
|
||||
receivable_turnover?: number;
|
||||
receivable_days?: number;
|
||||
inventory_turnover?: number;
|
||||
inventory_days?: number;
|
||||
working_capital_turnover?: number;
|
||||
};
|
||||
solvency: {
|
||||
current_ratio?: number;
|
||||
quick_ratio?: number;
|
||||
cash_ratio?: number;
|
||||
conservative_quick_ratio?: number;
|
||||
asset_liability_ratio?: number;
|
||||
interest_coverage?: number;
|
||||
cash_to_maturity_debt_ratio?: number;
|
||||
tangible_asset_debt_ratio?: number;
|
||||
};
|
||||
expense_ratios: {
|
||||
selling_expense_ratio?: number;
|
||||
admin_expense_ratio?: number;
|
||||
financial_expense_ratio?: number;
|
||||
rd_expense_ratio?: number;
|
||||
three_expense_ratio?: number;
|
||||
four_expense_ratio?: number;
|
||||
cost_ratio?: number;
|
||||
};
|
||||
cash_flow_quality: {
|
||||
operating_cash_to_profit_ratio?: number;
|
||||
cash_to_profit_ratio?: number;
|
||||
cash_revenue_ratio?: number;
|
||||
cash_recovery_rate?: number;
|
||||
operating_cash_to_short_debt?: number;
|
||||
operating_cash_to_total_debt?: number;
|
||||
};
|
||||
}
|
||||
|
||||
// ==================== 业务分析类型 ====================
|
||||
|
||||
/** 业务项目 */
|
||||
export interface BusinessItem {
|
||||
content: string;
|
||||
revenue?: number;
|
||||
gross_margin?: number;
|
||||
profit_margin?: number;
|
||||
profit?: number;
|
||||
}
|
||||
|
||||
/** 主营业务产品分类 */
|
||||
export interface ProductClassification {
|
||||
period: string;
|
||||
report_type: string;
|
||||
products: BusinessItem[];
|
||||
}
|
||||
|
||||
/** 主营业务行业分类 */
|
||||
export interface IndustryClassification {
|
||||
period: string;
|
||||
report_type: string;
|
||||
industries: BusinessItem[];
|
||||
}
|
||||
|
||||
/** 主营业务数据 */
|
||||
export interface MainBusinessData {
|
||||
product_classification?: ProductClassification[];
|
||||
industry_classification?: IndustryClassification[];
|
||||
}
|
||||
|
||||
/** 行业排名指标 */
|
||||
export interface RankingMetric {
|
||||
value?: number;
|
||||
rank?: number;
|
||||
industry_avg?: number;
|
||||
}
|
||||
|
||||
/** 行业排名数据 */
|
||||
export interface IndustryRankData {
|
||||
period: string;
|
||||
report_type: string;
|
||||
rankings?: {
|
||||
industry_name: string;
|
||||
level_description: string;
|
||||
metrics?: {
|
||||
eps?: RankingMetric;
|
||||
bvps?: RankingMetric;
|
||||
roe?: RankingMetric;
|
||||
revenue_growth?: RankingMetric;
|
||||
profit_growth?: RankingMetric;
|
||||
operating_margin?: RankingMetric;
|
||||
debt_ratio?: RankingMetric;
|
||||
receivable_turnover?: RankingMetric;
|
||||
};
|
||||
}[];
|
||||
}
|
||||
|
||||
/** 业绩预告数据 */
|
||||
export interface ForecastData {
|
||||
forecasts?: {
|
||||
forecast_type: string;
|
||||
report_date: string;
|
||||
content: string;
|
||||
reason?: string;
|
||||
change_range?: {
|
||||
lower?: number;
|
||||
upper?: number;
|
||||
};
|
||||
}[];
|
||||
}
|
||||
|
||||
/** 对比数据 */
|
||||
export interface ComparisonData {
|
||||
period: string;
|
||||
performance: {
|
||||
revenue?: number;
|
||||
net_profit?: number;
|
||||
};
|
||||
}
|
||||
|
||||
// ==================== 组件 Props 类型 ====================
|
||||
|
||||
/** 主组件 Props */
|
||||
export interface FinancialPanoramaProps {
|
||||
stockCode?: string;
|
||||
}
|
||||
|
||||
/** 股票信息头部 Props */
|
||||
export interface StockInfoHeaderProps {
|
||||
stockInfo: StockInfo | null;
|
||||
positiveColor: string;
|
||||
negativeColor: string;
|
||||
}
|
||||
|
||||
/** 表格通用 Props */
|
||||
export interface TableProps {
|
||||
data: unknown[];
|
||||
showMetricChart: (name: string, key: string, data: unknown[], path: string) => void;
|
||||
calculateYoYChange: (value: number, period: string, data: unknown[], path: string) => { change: number; intensity: number };
|
||||
getCellBackground: (change: number, intensity: number) => string;
|
||||
positiveColor: string;
|
||||
negativeColor: string;
|
||||
bgColor: string;
|
||||
hoverBg: string;
|
||||
}
|
||||
|
||||
/** 资产负债表 Props */
|
||||
export interface BalanceSheetTableProps extends TableProps {
|
||||
data: BalanceSheetData[];
|
||||
}
|
||||
|
||||
/** 利润表 Props */
|
||||
export interface IncomeStatementTableProps extends TableProps {
|
||||
data: IncomeStatementData[];
|
||||
}
|
||||
|
||||
/** 现金流量表 Props */
|
||||
export interface CashflowTableProps extends TableProps {
|
||||
data: CashflowData[];
|
||||
}
|
||||
|
||||
/** 财务指标表 Props */
|
||||
export interface FinancialMetricsTableProps extends TableProps {
|
||||
data: FinancialMetricsData[];
|
||||
}
|
||||
|
||||
/** 主营业务分析 Props */
|
||||
export interface MainBusinessAnalysisProps {
|
||||
mainBusiness: MainBusinessData | null;
|
||||
}
|
||||
|
||||
/** 行业排名 Props */
|
||||
export interface IndustryRankingViewProps {
|
||||
industryRank: IndustryRankData[];
|
||||
bgColor: string;
|
||||
borderColor: string;
|
||||
}
|
||||
|
||||
/** 股票对比 Props */
|
||||
export interface StockComparisonProps {
|
||||
currentStock: string;
|
||||
stockInfo: StockInfo | null;
|
||||
positiveColor: string;
|
||||
negativeColor: string;
|
||||
}
|
||||
|
||||
/** 综合对比分析 Props */
|
||||
export interface ComparisonAnalysisProps {
|
||||
comparison: ComparisonData[];
|
||||
}
|
||||
|
||||
// ==================== 指标定义类型 ====================
|
||||
|
||||
/** 指标配置 */
|
||||
export interface MetricConfig {
|
||||
name: string;
|
||||
key: string;
|
||||
path: string;
|
||||
isCore?: boolean;
|
||||
isTotal?: boolean;
|
||||
isSubtotal?: boolean;
|
||||
}
|
||||
|
||||
/** 指标分类配置 */
|
||||
export interface MetricSectionConfig {
|
||||
title: string;
|
||||
key: string;
|
||||
metrics: MetricConfig[];
|
||||
}
|
||||
|
||||
/** 指标分类映射 */
|
||||
export interface MetricsCategoryMap {
|
||||
[key: string]: {
|
||||
title: string;
|
||||
metrics: MetricConfig[];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user