From ae92f333c49d230b535d04f16f2b80da91f9f381 Mon Sep 17 00:00:00 2001 From: zzlgreat Date: Sun, 23 Nov 2025 15:40:58 +0800 Subject: [PATCH] update pay function --- src/views/Company/CompanyOverview.js | 1101 ++++++++++++++------------ 1 file changed, 600 insertions(+), 501 deletions(-) diff --git a/src/views/Company/CompanyOverview.js b/src/views/Company/CompanyOverview.js index 83e80fff..d1fc62fe 100644 --- a/src/views/Company/CompanyOverview.js +++ b/src/views/Company/CompanyOverview.js @@ -240,18 +240,21 @@ const BusinessTreeItem = ({ business, depth = 0 }) => { // 产业链节点卡片 const ValueChainNodeCard = ({ node, isCompany = false, level = 0 }) => { const { isOpen, onOpen, onClose } = useDisclosure(); - + const [relatedCompanies, setRelatedCompanies] = useState([]); + const [loadingRelated, setLoadingRelated] = useState(false); + const toast = useToast(); + const getColorScheme = () => { if (isCompany) return 'blue'; if (level < 0) return 'orange'; if (level > 0) return 'green'; return 'gray'; }; - + const colorScheme = getColorScheme(); const bgColor = useColorModeValue(`${colorScheme}.50`, `${colorScheme}.900`); const borderColor = useColorModeValue(`${colorScheme}.200`, `${colorScheme}.600`); - + const getNodeTypeIcon = (type) => { const icons = { 'company': FaBuilding, @@ -264,13 +267,53 @@ const ValueChainNodeCard = ({ node, isCompany = false, level = 0 }) => { }; return icons[type] || FaBuilding; }; - + const getImportanceColor = (score) => { if (score >= 80) return 'red'; if (score >= 60) return 'orange'; if (score >= 40) return 'yellow'; return 'green'; }; + + // 获取相关公司 + const fetchRelatedCompanies = async () => { + setLoadingRelated(true); + try { + const response = await fetch( + `${API_BASE_URL}/api/company/value-chain/related-companies?node_name=${encodeURIComponent(node.node_name)}` + ); + const data = await response.json(); + if (data.success) { + setRelatedCompanies(data.data || []); + } else { + toast({ + title: '获取相关公司失败', + description: data.message, + status: 'error', + duration: 3000, + isClosable: true, + }); + } + } catch (error) { + logger.error('ValueChainNodeCard', 'fetchRelatedCompanies', error, { node_name: node.node_name }); + toast({ + title: '获取相关公司失败', + description: error.message, + status: 'error', + duration: 3000, + isClosable: true, + }); + } finally { + setLoadingRelated(false); + } + }; + + const handleCardClick = () => { + onOpen(); + if (relatedCompanies.length === 0) { + fetchRelatedCompanies(); + } + }; return ( <> @@ -281,9 +324,9 @@ const ValueChainNodeCard = ({ node, isCompany = false, level = 0 }) => { borderWidth={isCompany ? 3 : 1} shadow={isCompany ? 'lg' : 'sm'} cursor="pointer" - onClick={onOpen} - _hover={{ - shadow: 'xl', + onClick={handleCardClick} + _hover={{ + shadow: 'xl', transform: 'translateY(-4px)', borderColor: `${colorScheme}.400` }} @@ -350,7 +393,7 @@ const ValueChainNodeCard = ({ node, isCompany = false, level = 0 }) => { - + @@ -374,35 +417,35 @@ const ValueChainNodeCard = ({ node, isCompany = false, level = 0 }) => { {node.node_description} )} - + 重要度评分 {node.importance_score || 0} - - + {node.market_share && ( 市场份额 {node.market_share}% )} - + {node.dependency_degree && ( 依赖程度 {node.dependency_degree}% - 50 ? 'orange' : 'green'} borderRadius="full" @@ -411,6 +454,58 @@ const ValueChainNodeCard = ({ node, isCompany = false, level = 0 }) => { )} + + + + {/* 相关公司列表 */} + + + 相关公司 + {loadingRelated && } + + {loadingRelated ? ( +
+ +
+ ) : relatedCompanies.length > 0 ? ( + + {relatedCompanies.map((company, idx) => ( + + + + + + {company.stock_name} + {company.stock_code} + + {company.company_name && ( + {company.company_name} + )} + + } + variant="ghost" + colorScheme="blue" + onClick={() => { + window.location.href = `/company?stock_code=${company.stock_code}`; + }} + aria-label="查看公司详情" + /> + + + + ))} + + ) : ( +
+ + + 暂无相关公司 + +
+ )} +
@@ -1060,15 +1155,476 @@ const CompanyAnalysisComplete = ({ stockCode: propStockCode }) => { )} - {/* 主要内容区 - 分为企业概览和深度分析 */} - + {/* 主要内容区 - 分为深度分析、基本信息和新闻动态 */} + - 企业概览 深度分析 + 基本信息 + 新闻动态 - {/* 企业概览标签页 */} + {/* 深度分析标签页 */} + + + {/* 核心定位卡片 */} + {comprehensiveData?.qualitative_analysis && ( + + + + + 核心定位 + + + + + + {comprehensiveData.qualitative_analysis.core_positioning?.one_line_intro && ( + + + {comprehensiveData.qualitative_analysis.core_positioning.one_line_intro} + + )} + + + + + 投资亮点 + + + {comprehensiveData.qualitative_analysis.core_positioning?.investment_highlights || '暂无数据'} + + + + + + + + 商业模式 + + + {comprehensiveData.qualitative_analysis.core_positioning?.business_model_desc || '暂无数据'} + + + + + + + + + )} + + {/* 竞争地位分析 */} + {comprehensiveData?.competitive_position && ( + + + + + 竞争地位分析 + {comprehensiveData.competitive_position.ranking && ( + + 行业排名 {comprehensiveData.competitive_position.ranking.industry_rank}/{comprehensiveData.competitive_position.ranking.total_companies} + + )} + + + + + {comprehensiveData.competitive_position.analysis?.main_competitors && ( + + 主要竞争对手 + + {comprehensiveData.competitive_position.analysis.main_competitors + .split(',') + .map((competitor, idx) => ( + + + {competitor.trim()} + + ))} + + + )} + + + + + + + + + + + + + + + + + {getRadarChartOption() && ( + + )} + + + + + + + + 竞争优势 + + {comprehensiveData.competitive_position.analysis?.competitive_advantages || '暂无数据'} + + + + 竞争劣势 + + {comprehensiveData.competitive_position.analysis?.competitive_disadvantages || '暂无数据'} + + + + + + )} + + {/* 业务结构分析 */} + {comprehensiveData?.business_structure && comprehensiveData.business_structure.length > 0 && ( + + + + + 业务结构分析 + {comprehensiveData.business_structure[0]?.report_period} + + + + + + {comprehensiveData.business_structure.map((business, idx) => ( + + ))} + + + + )} + + {/* 产业链分析 */} + {valueChainData && ( + + + + + 产业链分析 + + + 上游 {valueChainData.analysis_summary?.upstream_nodes || 0} + + + 核心 {valueChainData.analysis_summary?.company_nodes || 0} + + + 下游 {valueChainData.analysis_summary?.downstream_nodes || 0} + + + + + + + + + 层级视图 + 流向关系 + + + + + + {(valueChainData.value_chain_structure?.nodes_by_level?.['level_-2'] || + valueChainData.value_chain_structure?.nodes_by_level?.['level_-1']) && ( + + + 上游供应链 + 原材料与供应商 + + + {[ + ...(valueChainData.value_chain_structure?.nodes_by_level?.['level_-2'] || []), + ...(valueChainData.value_chain_structure?.nodes_by_level?.['level_-1'] || []) + ].map((node, idx) => ( + + ))} + + + )} + + {valueChainData.value_chain_structure?.nodes_by_level?.['level_0'] && ( + + + 核心企业 + 公司主体与产品 + + + {valueChainData.value_chain_structure.nodes_by_level['level_0'].map((node, idx) => ( + + ))} + + + )} + + {(valueChainData.value_chain_structure?.nodes_by_level?.['level_1'] || + valueChainData.value_chain_structure?.nodes_by_level?.['level_2']) && ( + + + 下游客户 + 客户与终端市场 + + + {[ + ...(valueChainData.value_chain_structure?.nodes_by_level?.['level_1'] || []), + ...(valueChainData.value_chain_structure?.nodes_by_level?.['level_2'] || []) + ].map((node, idx) => ( + + ))} + + + )} + + + + + {getSankeyChartOption() ? ( + + ) : ( +
+ 暂无流向数据 +
+ )} +
+
+
+
+
+ )} + + {/* 关键因素与发展时间线 */} + + + {keyFactorsData?.key_factors && ( + + + + + 关键因素 + {keyFactorsData.key_factors.total_factors} 项 + + + + + + {keyFactorsData.key_factors.categories.map((category, idx) => ( + + + + + {category.category_name} + + {category.factors.length} + + + + + + + + {category.factors.map((factor, fidx) => ( + + ))} + + + + ))} + + + + )} + + + + {keyFactorsData?.development_timeline && ( + + + + + 发展时间线 + + + 正面 {keyFactorsData.development_timeline.statistics?.positive_events || 0} + + + 负面 {keyFactorsData.development_timeline.statistics?.negative_events || 0} + + + + + + + + + + + + )} + + + + {/* 业务板块详情 */} + {comprehensiveData?.business_segments && comprehensiveData.business_segments.length > 0 && ( + + + + + 业务板块详情 + {comprehensiveData.business_segments.length} 个板块 + + + + + + {comprehensiveData.business_segments.map((segment, idx) => { + const isExpanded = expandedSegments[idx]; + + return ( + + + + + {segment.segment_name} + + + + + 业务描述 + + {segment.segment_description || '暂无描述'} + + + + + 竞争地位 + + {segment.competitive_position || '暂无数据'} + + + + + 未来潜力 + + {segment.future_potential || '暂无数据'} + + + + {isExpanded && segment.key_products && ( + + 主要产品 + + {segment.key_products} + + + )} + + {isExpanded && segment.market_share && ( + + 市场份额 + + + {segment.market_share}% + + + + )} + + {isExpanded && segment.revenue_contribution && ( + + 营收贡献 + + + {segment.revenue_contribution}% + + + + )} + + + + ); + })} + + + + )} + + {/* 战略分析 */} + {comprehensiveData?.qualitative_analysis?.strategy && ( + + + + + 战略分析 + + + + + + + + 战略方向 + + + {comprehensiveData.qualitative_analysis.strategy.strategy_description || '暂无数据'} + + + + + + + + 战略举措 + + + {comprehensiveData.qualitative_analysis.strategy.strategic_initiatives || '暂无数据'} + + + + + + + + )} +
+
+ + {/* 基本信息标签页 */} @@ -1077,9 +1633,8 @@ const CompanyAnalysisComplete = ({ stockCode: propStockCode }) => { 股权结构 管理团队 公司公告 - 新闻动态 分支机构 - 基本信息 + 工商信息 @@ -1449,28 +2004,6 @@ const CompanyAnalysisComplete = ({ stockCode: propStockCode }) => { - {/* 新闻动态标签页 */} - - - - - - - - - -
- - - 新闻接口待接入 - - 即将展示最新的公司新闻动态 - - -
-
-
- {/* 分支机构标签页 */} {branches.length > 0 ? ( @@ -1529,7 +2062,7 @@ const CompanyAnalysisComplete = ({ stockCode: propStockCode }) => { )} - {/* 基本信息标签页 */} + {/* 工商信息标签页 */} {basicInfo && ( @@ -1593,464 +2126,30 @@ const CompanyAnalysisComplete = ({ stockCode: propStockCode }) => { - {/* 深度分析标签页 */} + {/* 新闻动态标签页 */} - - {/* 核心定位卡片 */} - {comprehensiveData?.qualitative_analysis && ( - - - - - 核心定位 - - - - - - {comprehensiveData.qualitative_analysis.core_positioning?.one_line_intro && ( - - - {comprehensiveData.qualitative_analysis.core_positioning.one_line_intro} - - )} - - - - - 投资亮点 - - - {comprehensiveData.qualitative_analysis.core_positioning?.investment_highlights || '暂无数据'} - - - - - - - - 商业模式 - - - {comprehensiveData.qualitative_analysis.core_positioning?.business_model_desc || '暂无数据'} - - - - - + + + + + + + + + + +
+ + + 新闻接口待接入 + + 即将展示最新的公司新闻动态 + - - - )} - - {/* 竞争地位分析 */} - {comprehensiveData?.competitive_position && ( - - - - - 竞争地位分析 - {comprehensiveData.competitive_position.ranking && ( - - 行业排名 {comprehensiveData.competitive_position.ranking.industry_rank}/{comprehensiveData.competitive_position.ranking.total_companies} - - )} - - - - - {comprehensiveData.competitive_position.analysis?.main_competitors && ( - - 主要竞争对手 - - {comprehensiveData.competitive_position.analysis.main_competitors - .split(',') - .map((competitor, idx) => ( - - - {competitor.trim()} - - ))} - - - )} - - - - - - - - - - - - - - - - - {getRadarChartOption() && ( - - )} - - - - - - - - 竞争优势 - - {comprehensiveData.competitive_position.analysis?.competitive_advantages || '暂无数据'} - - - - 竞争劣势 - - {comprehensiveData.competitive_position.analysis?.competitive_disadvantages || '暂无数据'} - - - - - - )} - - {/* 业务结构分析 */} - {comprehensiveData?.business_structure && comprehensiveData.business_structure.length > 0 && ( - - - - - 业务结构分析 - {comprehensiveData.business_structure[0]?.report_period} - - - - - - {comprehensiveData.business_structure.map((business, idx) => ( - - ))} - - - - )} - - {/* 产业链分析 */} - {valueChainData && ( - - - - - 产业链分析 - - - 上游 {valueChainData.analysis_summary?.upstream_nodes || 0} - - - 核心 {valueChainData.analysis_summary?.company_nodes || 0} - - - 下游 {valueChainData.analysis_summary?.downstream_nodes || 0} - - - - - - - - - 层级视图 - 流向关系 - - - - - - {(valueChainData.value_chain_structure?.nodes_by_level?.['level_-2'] || - valueChainData.value_chain_structure?.nodes_by_level?.['level_-1']) && ( - - - 上游供应链 - 原材料与供应商 - - - {[ - ...(valueChainData.value_chain_structure?.nodes_by_level?.['level_-2'] || []), - ...(valueChainData.value_chain_structure?.nodes_by_level?.['level_-1'] || []) - ].map((node, idx) => ( - - ))} - - - )} - - {valueChainData.value_chain_structure?.nodes_by_level?.['level_0'] && ( - - - 核心企业 - 公司主体与产品 - - - {valueChainData.value_chain_structure.nodes_by_level['level_0'].map((node, idx) => ( - - ))} - - - )} - - {(valueChainData.value_chain_structure?.nodes_by_level?.['level_1'] || - valueChainData.value_chain_structure?.nodes_by_level?.['level_2']) && ( - - - 下游客户 - 客户与终端市场 - - - {[ - ...(valueChainData.value_chain_structure?.nodes_by_level?.['level_1'] || []), - ...(valueChainData.value_chain_structure?.nodes_by_level?.['level_2'] || []) - ].map((node, idx) => ( - - ))} - - - )} - - - - - {getSankeyChartOption() ? ( - - ) : ( -
- 暂无流向数据 -
- )} -
-
-
-
-
- )} - - {/* 关键因素与发展时间线 */} - - - {keyFactorsData?.key_factors && ( - - - - - 关键因素 - {keyFactorsData.key_factors.total_factors} 项 - - - - - - {keyFactorsData.key_factors.categories.map((category, idx) => ( - - - - - {category.category_name} - - {category.factors.length} - - - - - - - - {category.factors.map((factor, fidx) => ( - - ))} - - - - ))} - - - - )} - - - - {keyFactorsData?.development_timeline && ( - - - - - 发展时间线 - - - 正面 {keyFactorsData.development_timeline.statistics?.positive_events || 0} - - - 负面 {keyFactorsData.development_timeline.statistics?.negative_events || 0} - - - - - - - - - - - - )} - - - - {/* 业务板块详情 */} - {comprehensiveData?.business_segments && comprehensiveData.business_segments.length > 0 && ( - - - - - 业务板块详情 - {comprehensiveData.business_segments.length} 个板块 - - - - - - {comprehensiveData.business_segments.map((segment, idx) => { - const isExpanded = expandedSegments[idx]; - - return ( - - - - - {segment.segment_name} - - - - - 业务描述 - - {segment.segment_description || '暂无描述'} - - - - - 竞争地位 - - {segment.competitive_position || '暂无数据'} - - - - - 未来潜力 - - {segment.future_potential || '暂无数据'} - - - - {isExpanded && segment.key_products && ( - - 主要产品 - - {segment.key_products} - - - )} - - {isExpanded && segment.market_share && ( - - 市场份额 - - - {segment.market_share}% - - - - )} - - {isExpanded && segment.revenue_contribution && ( - - 营收贡献 - - - {segment.revenue_contribution}% - - - - )} - - - - ); - })} - - - - )} - - {/* 战略分析 */} - {comprehensiveData?.qualitative_analysis?.strategy && ( - - - - - 战略分析 - - - - - - - - 战略方向 - - - {comprehensiveData.qualitative_analysis.strategy.strategy_description || '暂无数据'} - - - - - - - - 战略举措 - - - {comprehensiveData.qualitative_analysis.strategy.strategic_initiatives || '暂无数据'} - - - - - - - - )} - +
+
+
+
@@ -2095,4 +2194,4 @@ const CompanyAnalysisComplete = ({ stockCode: propStockCode }) => { ); }; -export default CompanyAnalysisComplete; \ No newline at end of file +export default CompanyAnalysisComplete;