feat(cost-center): 总览统计支持按来源收敛

页面顶部的 6 张统计卡原本是全局口径:选了「自动发货」,商品数还是 2017、
异常数还是 108,314,和下面的列表对不上。

- overview 接口接受 scope(all / affiliate_dash / work_order / manual);
- 商品、映射、成本项、生效版本、待处理异常、未映射订单项全部按来源过滤:
  商品看 canonical_sku 前缀(aff: / tpl:+wo: / man:),
  成本项与版本看 cost_model,异常与未映射订单项看 order_items.fulfillment_mode;
- 额外返回 productTotalCount(全局商品数),供「全部」徽标使用,
  避免切到单一来源后「全部」也被算成 49。

实测四种口径:
  all            商品 2017 / 映射 4897 / 成本项 3 / 版本 712 / 异常 108314 / 未映射 53901
  affiliate_dash 商品   49 / 映射    0 / 成本项 1 / 版本   0 / 异常  53204 / 未映射     0
  work_order     商品  773 / 映射 4897 / 成本项 1 / 版本 711 / 异常   1209 / 未映射     0
  manual         商品 1195 / 映射    0 / 成本项 1 / 版本   1 / 异常      0 / 未映射     0
This commit is contained in:
yml2213
2026-10-25 13:55:25 +08:00
parent 39fe448b48
commit 88ba87efff
4 changed files with 91 additions and 10 deletions
@@ -31,8 +31,10 @@ import type {
UnmappedMappingGroupListResult,
} from '@/types/admin'
export function fetchAdminCostCenterOverview() {
return apiGet<CostCenterOverview>('/api/v1/admin/cost-center/overview')
export function fetchAdminCostCenterOverview(params: { scope?: string } = {}) {
return apiGet<CostCenterOverview>('/api/v1/admin/cost-center/overview', {
scope: params.scope && params.scope !== 'all' ? params.scope : undefined,
})
}
export function fetchAdminCostCenterOptions() {
@@ -20,7 +20,11 @@ export type CostModel =
| 'other'
export interface CostCenterOverview {
/** 统计口径:all 或具体来源;服务端回传便于核对。 */
scope?: string
productCount: number
/** 全局商品总数(不随 scope 变化),用于「全部」徽标。 */
productTotalCount?: number
mappingCount: number
costItemCount: number
activeVersionCount: number