/* 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 from 'react'; import { Card, Tag, Tooltip } from '@/components/ui'; import { TrendingDown, TrendingUp } from 'lucide-react'; import { changeRate, ORG_STATUS, orgDisplayName, REASONS } from './utils'; import { formatPercent } from '../../../helpers/safeDisplay'; export const SectionCard = ({ id, title, icon, extra, children, bodyStyle, }) => ( {icon} {title} {extra} } styles={{ body: { padding: '16px', ...bodyStyle } }} > {children} ); export const SectionTitle = ({ id, index, title, desc }) => (
{index ? ( {String(index).padStart(2, '0')} ) : null}

{title}

{desc ? ( {desc} ) : null}
); // 变化值:上升绿、下降红;对比期为 0 时无法计算 export const ChangeText = ({ cur, prev, t, size = 'xs', showNew = true }) => { const rate = changeRate(cur, prev); const sizeClass = size === 'sm' ? 'text-sm' : 'text-xs'; if (rate === null) { return cur > 0 && showNew ? ( {t('对比期无数据')} ) : ( — ); } const up = rate >= 0; return ( {up ? ( ) : ( )} {up ? '+' : ''} {formatPercent(rate, 1)} ); }; export const KpiCard = ({ title, value, sub, compare, tip, accent, onClick, }) => (
{title} {tip ? ( ⓘ ) : null}
{value}
{sub} {compare}
); export const OrgNameCell = ({ org, t, showCode = true }) => { const name = orgDisplayName(org, t); const status = ORG_STATUS[org.status]; return (
{name} {!org.deleted && status && org.status !== 1 ? ( {t(status.label)} ) : null}
{showCode && org.code ? (
{org.code}
) : null}
); }; export const ReasonTags = ({ reasons, t }) => (
{(reasons || []).map((r) => ( {t(REASONS[r]?.label || r)} ))}
); export const EmptyBlock = ({ height = 240, text }) => (
{text}
);