财务页清理说明性小字(概览/毛利/采购成本)
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s

经营总览、商品毛利、订单采购成本(全部 Tab)与 AI 成本深度分析
移除说明性小字,只保留标题/数值/空态/告警/按钮/tooltip。
- FinanceOverview:KPI 提示、空态提示条、模块卡描述、成本结构说明
- CostAccountingPanel:各 Tab 的 KPI/结构/排行/其他成本/商品成本 Tab 说明
- CostRootCausePanel:副标题与空态说明
仅展示层,未改任何取数/口径/计算;i18n 词条保留未删。
This commit is contained in:
雨天
2026-10-19 17:47:56 +08:00
parent 8a08686e1a
commit 22be54affe
3 changed files with 3 additions and 111 deletions
+3 -57
View File
@@ -229,7 +229,8 @@ const StatCard: React.FC<{
icon: React.ElementType;
title: string;
value: string;
hint: string;
/** 补充说明(2026-10-19 起经营总览不再展示小字 ⇒ 不传即不渲染) */
hint?: string;
onActivate?: () => void;
ariaLabel?: string;
}> = ({ icon: Icon, title, value, hint, onActivate, ariaLabel }) => (
@@ -243,7 +244,7 @@ const StatCard: React.FC<{
<div>
<p className="app-foreground-muted text-sm">{title}</p>
<p className="app-foreground mt-2 text-2xl font-bold">{value}</p>
<p className="app-foreground-muted mt-2 text-xs">{hint}</p>
{hint ? <p className="app-foreground-muted mt-2 text-xs">{hint}</p> : null}
</div>
<div className="app-surface-subtle rounded-lg p-2">
<Icon className="h-5 w-5 text-emerald-600" />
@@ -285,7 +286,6 @@ export const FinanceOverview: React.FC = () => {
customerCode: String(searchParams.get('customer_code') || '').trim(),
});
const [rangeError, setRangeError] = useState('');
const dateFieldShortLabel = t(`finance.dateField.${dateField}`);
useLegacyTabRedirect('/finance', { margin: 'margin' });
const tabSegment = useTabChildSegment('/finance');
@@ -424,10 +424,6 @@ export const FinanceOverview: React.FC = () => {
applyToolbarRange(null);
};
const rangeLabel = stats.dateFrom && stats.dateTo
? `${stats.dateFrom} ~ ${stats.dateTo}`
: t('finance.range.recentDays', { days: stats.windowDays });
const handleRenameCostBucket = async (bucket: FinanceStats['costBuckets'][number]) => {
if (!bucket.catKey) {
notify(t('finance.rename.unsupported'));
@@ -455,12 +451,6 @@ export const FinanceOverview: React.FC = () => {
}
};
const hasAnyData =
stats.weekRevenue > 0 ||
stats.receivableTotal > 0 ||
stats.payableTotal > 0 ||
stats.costBuckets.length > 0;
const activeDateFrom = dateFrom || stats.dateFrom || appliedRange.dateFrom;
const activeDateTo = dateTo || stats.dateTo || appliedRange.dateTo;
@@ -675,23 +665,12 @@ export const FinanceOverview: React.FC = () => {
)
) : (
<>
{!loading && !hasAnyData && (
<div className="app-surface-subtle app-foreground-muted app-border rounded-lg border border-dashed px-4 py-3 text-sm">
{t('finance.empty')}
</div>
)}
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-6">
<StatCard
onActivate={() => navigate(marginNavigateUrl())}
icon={DollarSign}
title={t('finance.kpi.margin')}
value={`¥${formatMoney(stats.weekGross)}`}
hint={
stats.weekRevenue > 0
? t('finance.kpi.marginHint', { pct: stats.grossMarginPct.toFixed(1) })
: t('finance.kpi.noOrders', { range: rangeLabel })
}
ariaLabel={t('finance.kpi.openMargin')}
/>
<StatCard
@@ -707,18 +686,6 @@ export const FinanceOverview: React.FC = () => {
icon={CreditCard}
title={t('finance.kpi.revenue')}
value={`¥${formatMoney(stats.weekRevenue)}`}
hint={
stats.receivablePendingCount > 0
? t('finance.kpi.revenueHintPending', {
dateField: dateFieldShortLabel,
amount: formatMoney(stats.receivableTotal),
count: stats.receivablePendingCount,
})
: t('finance.kpi.revenueHint', {
dateField: dateFieldShortLabel,
amount: formatMoney(stats.receivableTotal),
})
}
ariaLabel={t('finance.kpi.openReceivable')}
/>
<StatCard
@@ -726,10 +693,6 @@ export const FinanceOverview: React.FC = () => {
icon={TrendingUp}
title={t('finance.kpi.allCost')}
value={`¥${formatMoney(stats.periodAllCost)}`}
hint={t('finance.kpi.allCostHint', {
dateField: dateFieldShortLabel,
range: rangeLabel,
})}
ariaLabel={t('finance.kpi.openCosts')}
/>
{stats.customerRebateCost > 0 && (
@@ -738,7 +701,6 @@ export const FinanceOverview: React.FC = () => {
icon={Percent}
title={t('finance.kpi.customerRebate')}
value={`¥${formatMoney(stats.customerRebateCost)}`}
hint=""
ariaLabel={t('finance.kpi.openCosts')}
/>
)}
@@ -747,14 +709,6 @@ export const FinanceOverview: React.FC = () => {
icon={PieChart}
title={t('finance.kpi.netProfit')}
value={`¥${formatMoney(stats.netProfit)}`}
hint={
stats.weekRevenue > 0
? t('finance.kpi.netProfitHint', {
pct: stats.netProfitMarginPct.toFixed(1),
formula: stats.netProfitFormula,
})
: t('finance.kpi.netProfitEmpty')
}
ariaLabel={t('finance.kpi.openNetProfit')}
/>
</div>
@@ -773,7 +727,6 @@ export const FinanceOverview: React.FC = () => {
</div>
<div>
<p className="app-foreground font-medium">{mod.label}</p>
<p className="app-foreground-muted mt-1 text-xs">{mod.description}</p>
</div>
</div>
</Link>
@@ -788,13 +741,6 @@ export const FinanceOverview: React.FC = () => {
<div className="flex items-center justify-between gap-3 mb-4">
<div>
<h3 className="app-foreground font-medium">{t('finance.structure.title')}</h3>
<p className="app-foreground-muted text-xs mt-1">
{t('finance.structure.hint', { dateField: dateFieldShortLabel, range: rangeLabel })}
{stats.periodAllCost > 0
? t('finance.structure.total', { amount: formatMoney(stats.periodAllCost) })
: ''}
{t('finance.structure.renameHint')}
</p>
</div>
<Link
to={costsNavigateUrl()}
@@ -1074,12 +1074,6 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
);
const cycleCode = React.useMemo(() => dateRangeToCycleCode(dateFrom, dateTo), [dateFrom, dateTo]);
const rangeLabel = React.useMemo(() => `${dateFrom} ~ ${dateTo}`, [dateFrom, dateTo]);
const dateFieldShortLabel =
dateField === 'created_at'
? t('finance.cost.date.order')
: dateField === 'inbound'
? t('finance.cost.date.inbound')
: t('finance.cost.date.delivery');
// 从财务概览等带 date_from/date_to/date_field 跳入时,仅随 URL 同步(避免与本地改区间竞态)
React.useEffect(() => {
@@ -2467,9 +2461,6 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
maximumFractionDigits: 2,
})}
</p>
<p className="app-foreground-muted text-xs mt-1">
{t('finance.cost.kpi.totalCostHint', { dateField: dateFieldShortLabel, range: rangeLabel, count: costDetails.length })}
</p>
</StatusSummaryCard>
<StatusSummaryCard
onActivate={openSkuTab}
@@ -2486,12 +2477,6 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
maximumFractionDigits: 2,
})}
</p>
<p className="app-foreground-muted text-xs mt-1">
{structureTotal > 0 && overviewLedgerPurchase > 0
? t('finance.cost.kpi.purchaseShare', { pct: ((overviewLedgerPurchase / structureTotal) * 100).toFixed(1) })
: ''}
{t('finance.cost.kpi.purchaseHint')}
</p>
</StatusSummaryCard>
<StatusSummaryCard
onActivate={openIndirectDetail}
@@ -2508,12 +2493,6 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
: safeAmount(aggregation?.indirect_fixed, 0)
).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
</p>
<p className="app-foreground-muted text-xs mt-1">
{structureTotal > 0 && fixedCostStructureAmount > 0
? t('finance.cost.kpi.purchaseShare', { pct: ((fixedCostStructureAmount / structureTotal) * 100).toFixed(1) })
: ''}
{t('finance.cost.kpi.fixedHint')}
</p>
</StatusSummaryCard>
{aggregation ? (
<StatusSummaryCard
@@ -2527,7 +2506,6 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
<p className="text-xl font-bold text-red-600 mt-1">
{aggregation.negative_margin_orders}
</p>
<p className="app-foreground-muted text-xs mt-1">{t('finance.cost.kpi.negMarginHint')}</p>
</StatusSummaryCard>
) : null}
</div>
@@ -2539,9 +2517,6 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
<PieChart className="app-foreground-muted w-5 h-5" />
{t('finance.cost.structure.title')}
</h3>
<p className="app-foreground-muted text-xs mb-3">
{t('finance.cost.structure.hint')}
</p>
{costStructureEntries.length > 0 ? (
<div className="space-y-3">
{costStructureEntries.map((entry) => {
@@ -2618,14 +2593,6 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
<BarChart3 className="app-foreground-muted w-5 h-5" />
{t('finance.cost.rank.title')}
</h3>
<p className="app-foreground-muted text-xs mt-2">
{t('finance.cost.rank.hint')}
{skuRankExpanded
? t('finance.cost.rank.expanded', { count: skuCostDetails.length })
: t('finance.cost.rank.collapsed', {
dir: skuRankSortDir === 'desc' ? t('finance.cost.rank.dirHigh') : t('finance.cost.rank.dirLow'),
})}
</p>
</div>
<div className="flex items-center gap-2 shrink-0">
<button
@@ -2872,12 +2839,10 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
<p className="app-foreground text-2xl font-bold mt-2">
¥{(freeCostSummary?.freeTotal || 0).toLocaleString()}
</p>
<p className="app-foreground-muted text-xs mt-1">{t('finance.cost.free.sumHint')}</p>
</div>
<div className="app-surface rounded-lg border p-5">
<p className="app-foreground-muted text-sm">{t('finance.cost.free.countTitle')}</p>
<p className="app-foreground text-2xl font-bold mt-2">{freeCostStatusCounts.posted}</p>
<p className="app-foreground-muted text-xs mt-1">{t('finance.cost.free.countHint')}</p>
</div>
{/* 付款拆分(同一时间范围/筛选口径,来自后端 payment_amounts):只是把已入账拆成已付款/未付款笔数 */}
<div className="app-surface rounded-lg border p-5">
@@ -2927,7 +2892,6 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
</div>
<div className="px-4 py-3 border-b flex flex-wrap items-center justify-between gap-2">
<h3 className="app-foreground font-medium">{freeCostStatusTabTitle(freeCostStatusFilter, t)}</h3>
<p className="app-foreground-muted text-xs">{t('finance.cost.free.byEntryDay')}</p>
</div>
<table className="min-w-full text-sm">
<thead className="app-table-head">
@@ -3422,9 +3386,6 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
>
{marginSummary.aggregation.gross_margin_pct.toFixed(1)}%
</p>
<p className="app-foreground-muted text-xs mt-1">
{t('finance.cost.kpi.negMarginCount', { count: marginSummary.aggregation.negative_margin_orders })}
</p>
</StatusSummaryCard>
</div>
@@ -3560,9 +3521,6 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
{dim.label}
</button>
))}
<p className="app-foreground-muted text-xs w-full sm:w-auto sm:ml-2">
{t('finance.cost.margin.detailHint')}
</p>
</div>
<div className="app-surface rounded-lg border overflow-hidden">
@@ -4022,9 +3980,6 @@ export const CostAccountingPanel: React.FC<CostAccountingPanelProps> = ({
{activeTab === 'sku' && (
<div className="space-y-4">
<div className="app-surface rounded-lg border px-4 py-3 space-y-2">
<p className="app-foreground-muted text-xs">
{t('finance.cost.sku.intro')}
</p>
<div className="flex flex-wrap items-end gap-3">
<div className="min-w-[14rem] flex-1 max-w-sm">
<label className="app-foreground-muted mb-1 block text-xs">{t('finance.cost.sku.category')}</label>
@@ -99,9 +99,6 @@ export const CostRootCausePanel: React.FC<CostRootCausePanelProps> = ({
<div className="flex flex-wrap items-center justify-between gap-3">
<div>
<h3 className="app-foreground font-medium">{t('finance.cost.root.title')}</h3>
<p className="app-foreground-muted text-xs mt-1">
{t('finance.cost.root.subtitle')}
</p>
</div>
<button
type="button"
@@ -121,12 +118,6 @@ export const CostRootCausePanel: React.FC<CostRootCausePanelProps> = ({
<p className="text-sm text-amber-700">{error}</p>
)}
{!rootCause && !rootCauseLoading && !error && !autoAnalyze && (
<p className="app-foreground-muted text-sm">
{t('finance.cost.root.idleHint')}
</p>
)}
{rootCause &&
(() => {
const insight = (rootCause.ai_insight || {}) as Record<string, unknown>;