/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import React, { useCallback, useMemo, useState } from 'react'; import { Button, Card, Typography } from '@/components/ui'; import { ActionCenter, ACTION_TABS } from './ActionCenter'; import { ChangeAttribution, TiersAndRankings, TopModels, TrendChart, } from './Analysis'; import { HealthSegments, KeyFindings, KpiGrid, ReportHeader } from './Overview'; import { SectionTitle } from './shared'; import { EMPTY_DETAIL_FILTER, exportOrgDetail, OrgDetailTable, SalesRepTable, } from './Tables'; import { deriveActionLists, deriveFindings, deriveSalesReps, getCnyParams, } from './utils'; const { Text } = Typography; // 页签内锚点跳转:顶栏与跑马灯为 fixed,元素上已加 scroll-mt 让位 const scrollToId = (id) => { const el = document.getElementById(id); if (el) el.scrollIntoView({ behavior: 'smooth', block: 'start' }); }; const ReportSkeleton = () => (
{Array.from({ length: 8 }).map((_, i) => (
))}
); const OrgReportPanel = ({ report, loading, error, onRetry, t }) => { const cny = useMemo(getCnyParams, []); const [actionTab, setActionTab] = useState('renewal'); const [detailFilter, setDetailFilter] = useState(EMPTY_DETAIL_FILTER); const lists = useMemo( () => deriveActionLists(report?.orgs, report?.meta), [report], ); const findings = useMemo( () => deriveFindings(report, lists, cny, t), [report, lists, cny, t], ); const reps = useMemo( () => deriveSalesReps(report?.orgs, lists), [report, lists], ); const jump = useCallback((target) => { if (ACTION_TABS.includes(target)) { setActionTab(target); scrollToId('org-report-actions'); return; } scrollToId(`org-report-${target}`); }, []); const filterDetail = useCallback((patch) => { setDetailFilter({ ...EMPTY_DETAIL_FILTER, ...patch }); scrollToId('org-report-detail'); }, []); if (!report) { if (error) { return (
{t('企业经营报表加载失败,请稍后重试')}
); } return ; } return (
exportOrgDetail(report.orgs || [], cny, t)} t={t} />
segment ? filterDetail({ segment }) : setDetailFilter(EMPTY_DETAIL_FILTER) } t={t} /> filterDetail({ tier })} t={t} />
filterDetail({ salesRep })} t={t} />
); }; export default OrgReportPanel;