refactor(cost-center): 精简成本中心,人工成本以 SKU 配置为唯一真源
- 删除「成本项目」「成本版本」「成本预览」三个 Tab:成本项只有 3 条系统内置,版本金额只是快照挂载点 - 新增只读「发单价格」面板,仅在接单平台来源显示,改价仍走接单模板后同步 - 成本预览改为弹窗,从成本异常行和订单详情「查成本」进入;人工单显示 SKU 配置成本并禁止生成快照 - 成本异常新增按原因聚合摘要接口,列表支持 reason/since 筛选,默认只看近 24 小时 - 迁移 111:把 sys_manual_service 的历史 ¥88 全局版本清零;预估同步与成本缺失判定排除 manual_actual
This commit is contained in:
@@ -17,11 +17,9 @@ import { hasAdminPermission } from '@/utils/admin-auth'
|
||||
import { AffiliateSkuPanel } from './AffiliateSkuPanel'
|
||||
import { ChannelMappingPanel } from './ChannelMappingPanel'
|
||||
import { CostExceptionPanel } from './CostExceptionPanel'
|
||||
import { CostItemPanel } from './CostItemPanel'
|
||||
import { CostPreviewPanel } from './CostPreviewPanel'
|
||||
import { CostVersionPanel } from './CostVersionPanel'
|
||||
import { ManualSkuConfigPanel } from './ManualSkuConfigPanel'
|
||||
import { ProductCatalogPanel } from './ProductCatalogPanel'
|
||||
import { WorkOrderPricePanel } from './WorkOrderPricePanel'
|
||||
import { CostCenterContext } from './CostCenterContext'
|
||||
import type { CostScope } from './shared'
|
||||
|
||||
@@ -58,12 +56,10 @@ const SCOPE_TAG_COLORS: Record<CostScope, string> = {
|
||||
function tabKeysForScope(scope: CostScope) {
|
||||
return [
|
||||
...(scope === 'all' || scope === 'work_order' ? ['products', 'mappings'] : []),
|
||||
...(scope === 'affiliate_dash' ? ['affiliate-skus'] : []),
|
||||
...(scope === 'all' || scope === 'affiliate_dash' ? ['affiliate-skus'] : []),
|
||||
...(scope === 'all' || scope === 'manual' ? ['manual-skus'] : []),
|
||||
'cost-items',
|
||||
'cost-versions',
|
||||
...(scope === 'all' || scope === 'work_order' ? ['prices'] : []),
|
||||
'exceptions',
|
||||
'preview',
|
||||
]
|
||||
}
|
||||
|
||||
@@ -93,7 +89,7 @@ export default function CostCenterShell() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!visibleTabKeys.includes(activeTab)) {
|
||||
setActiveTab(visibleTabKeys[0] ?? 'cost-items')
|
||||
setActiveTab(visibleTabKeys[0] ?? 'exceptions')
|
||||
}
|
||||
}, [activeTab, setActiveTab, visibleTabKeys])
|
||||
|
||||
@@ -102,9 +98,9 @@ export default function CostCenterShell() {
|
||||
void queryClient.invalidateQueries({ queryKey: ['admin-cost-center-options'] })
|
||||
void queryClient.invalidateQueries({ queryKey: ['admin-cost-center-products'] })
|
||||
void queryClient.invalidateQueries({ queryKey: ['admin-cost-center-mappings'] })
|
||||
void queryClient.invalidateQueries({ queryKey: ['admin-cost-center-cost-items'] })
|
||||
void queryClient.invalidateQueries({ queryKey: ['admin-cost-center-cost-versions'] })
|
||||
void queryClient.invalidateQueries({ queryKey: ['admin-cost-center-exceptions'] })
|
||||
void queryClient.invalidateQueries({ queryKey: ['admin-cost-center-exceptions-summary'] })
|
||||
}
|
||||
|
||||
const scopeLabel =
|
||||
@@ -139,7 +135,7 @@ export default function CostCenterShell() {
|
||||
<section className="page-stack">
|
||||
<PageHeader
|
||||
title="商品与成本中心"
|
||||
description="先按来源(自动发货 / 接单平台 / 人工)分区,再把商品 SKU 归一、成本金额收口到版本;历史成本靠快照固化。"
|
||||
description="商品 SKU 先归一;成本在各来源自己的配置里维护(人工 SKU 消耗积分 / 自动发货采购价 / 接单模板发单金额),历史成本靠快照固化。"
|
||||
extra={
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
@@ -155,8 +151,8 @@ export default function CostCenterShell() {
|
||||
{[
|
||||
['标准商品', overview?.productCount || 0],
|
||||
['渠道映射', overview?.mappingCount || 0],
|
||||
['成本项目', overview?.costItemCount || 0],
|
||||
['生效版本', overview?.activeVersionCount || 0],
|
||||
['系统成本项', overview?.costItemCount || 0],
|
||||
['生效发单价格', overview?.activeVersionCount || 0],
|
||||
['待处理异常', overview?.openExceptionCount || 0],
|
||||
['未映射订单项', overview?.unmappedOrderItemCount || 0],
|
||||
].map(([label, value]) => (
|
||||
@@ -179,7 +175,7 @@ export default function CostCenterShell() {
|
||||
? 'products'
|
||||
: next === 'affiliate_dash'
|
||||
? 'affiliate-skus'
|
||||
: 'cost-items',
|
||||
: 'manual-skus',
|
||||
)
|
||||
}}
|
||||
items={SCOPES.map((item) => {
|
||||
@@ -187,16 +183,12 @@ export default function CostCenterShell() {
|
||||
item.key === 'all'
|
||||
? overview?.productCount
|
||||
: overview?.productSourceCounts?.[item.key]
|
||||
const costItemCount = item.key === 'all' ? overview?.costItemCount : undefined
|
||||
return {
|
||||
key: item.key,
|
||||
label: (
|
||||
<span className="cost-center-scope-tab">
|
||||
<span>{item.label}</span>
|
||||
<Tag color={SCOPE_TAG_COLORS[item.key]}>
|
||||
{Number(productCount || 0)} 商品
|
||||
{costItemCount === undefined ? '' : ` / ${Number(costItemCount)} 成本项`}
|
||||
</Tag>
|
||||
<Tag color={SCOPE_TAG_COLORS[item.key]}>{Number(productCount || 0)} 商品</Tag>
|
||||
</span>
|
||||
),
|
||||
children: <Typography.Text type="secondary">{item.hint}</Typography.Text>,
|
||||
@@ -210,7 +202,7 @@ export default function CostCenterShell() {
|
||||
type="info"
|
||||
showIcon
|
||||
message="当前账号为只读权限"
|
||||
description="可以查看商品、映射、成本版本和异常;新增/修改需要 finance.config 权限。"
|
||||
description="可以查看商品、映射、发单价格和成本异常;新增/修改需要 finance.config 权限。"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -239,25 +231,24 @@ export default function CostCenterShell() {
|
||||
children: <ManualSkuConfigPanel />,
|
||||
},
|
||||
{
|
||||
key: 'cost-items',
|
||||
label: '成本项目',
|
||||
children: <CostItemPanel />,
|
||||
},
|
||||
{
|
||||
key: 'cost-versions',
|
||||
label: '成本版本',
|
||||
children: <CostVersionPanel />,
|
||||
key: 'prices',
|
||||
label: '发单价格',
|
||||
children: <WorkOrderPricePanel />,
|
||||
},
|
||||
{
|
||||
key: 'exceptions',
|
||||
label: '成本异常',
|
||||
label: (
|
||||
<span>
|
||||
成本异常
|
||||
{Number(overview?.openExceptionCount || 0) > 0 ? (
|
||||
<Tag color="red" style={{ marginInlineStart: 6 }}>
|
||||
{Number(overview?.openExceptionCount || 0)}
|
||||
</Tag>
|
||||
) : null}
|
||||
</span>
|
||||
),
|
||||
children: <CostExceptionPanel />,
|
||||
},
|
||||
{
|
||||
key: 'preview',
|
||||
label: '成本预览',
|
||||
children: <CostPreviewPanel />,
|
||||
},
|
||||
].filter((item) => visibleTabKeys.includes(item.key))}
|
||||
/>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user