diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/data.ts b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/data.ts deleted file mode 100644 index abcd1a88..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/data.ts +++ /dev/null @@ -1,802 +0,0 @@ -/** 电商运营工作台 — 演示数据(与 temp/pdd_dashboard 原型一致,后续可换接口) */ - -export type TrendPoint = { - date: string; - gmv: number; - profit: number; - refund: number; -}; - -export const GLOBAL_SUMMARY = { - periodLabel: '近30天', - mom: 18.3, - yoy: 42.7, -}; - -/** 电商平台筛选(演示,对接接口后可替换) */ -export const PLATFORM_OPTIONS = [ - { label: '全平台', value: 'all' }, - { label: '拼多多', value: 'pdd' }, - { label: '淘宝', value: 'taobao' }, - { label: '京东', value: 'jd' }, - { label: '抖音电商', value: 'douyin' }, -] as const; - -export const FINANCE_KPIS = [ - { - label: '总GMV', - value: '292.0', - unit: '万', - changePct: 18.3, - up: true, - sub: '全部订单状态商家实收合计', - }, - { - label: '实际销售额', - value: '286.4', - unit: '万', - changePct: 16.2, - up: true, - sub: '计入销售额状态口径 · 退款约14.6万', - }, - { - label: '毛利润', - value: '68.2', - unit: '万', - changePct: 11.5, - up: true, - sub: '毛利率25.1%', - }, - { - label: '净利润', - value: '38.9', - unit: '万', - changePct: 8.7, - up: true, - sub: '净利率14.3%', - }, - { - label: '订单量', - value: '18,432', - unit: '单', - changePct: 22.4, - up: true, - sub: '日均614单', - }, - { - label: '客单价', - value: '155.4', - unit: '元', - changePct: 3.2, - up: false, - sub: '类目均价142元', - }, - { - label: '退款率', - value: '5.1', - unit: '%', - changePct: 0.8, - up: false, - sub: '类目基准7.2%', - }, - { - label: '广告ROI', - value: '3.68', - unit: ':1', - changePct: 0.31, - up: true, - sub: '广告花费73.8万', - }, -] as const; - -export const GMV_TREND: TrendPoint[] = [ - { date: '3/1', gmv: 8.2, profit: 1.05, refund: 0.28 }, - { date: '3/2', gmv: 7.9, profit: 0.98, refund: 0.31 }, - { date: '3/3', gmv: 9.1, profit: 1.18, refund: 0.26 }, - { date: '3/4', gmv: 8.5, profit: 1.02, refund: 0.29 }, - { date: '3/5', gmv: 10.2, profit: 1.35, refund: 0.33 }, - { date: '3/6', gmv: 9.4, profit: 1.22, refund: 0.27 }, - { date: '3/7', gmv: 8.8, profit: 1.08, refund: 0.3 }, - { date: '3/8', gmv: 11, profit: 1.42, refund: 0.35 }, - { date: '3/9', gmv: 9.6, profit: 1.25, refund: 0.28 }, - { date: '3/10', gmv: 10.5, profit: 1.38, refund: 0.32 }, -]; - -export const COST_STRUCTURE = [ - { name: '净利润', value: 68.2, pct: 25.1 }, - { name: '商品成本', value: 50.4, pct: 18.5 }, - { name: '广告花费', value: 73.8, pct: 27.1 }, - { name: '平台佣金', value: 28.6, pct: 10.5 }, - { name: '物流费用', value: 18.2, pct: 6.7 }, - { name: '退款损失', value: 14.6, pct: 5.4 }, - { name: '其他费用', value: 18, pct: 6.6 }, -] as const; - -/** 与 COST_STRUCTURE 顺序一一对应;配色对齐全店概览表(盈利翠绿 / 规模蓝 / 成本橙红系 / 退款灰) */ -export const COST_STRUCTURE_PIE_COLORS = [ - '#059669', - '#2563eb', - '#e11d48', - '#ea580c', - '#d97706', - '#94a3b8', - '#0d9488', -] as const; - -export const STORES = [ - { - name: '优品生活旗舰店', - star: 4.87, - color: '#6366f1', - gmv: 286.4, - orders: 18_432, - aov: 155.4, - grossRate: 25.1, - netRate: 14.3, - roi: 3.68, - refund: 5.1, - growth: 18.3, - products: [ - '316不锈钢保温杯-女款', - '大容量保温杯-男款', - '情侣对杯礼盒', - '儿童保温杯卡通款', - '保温壶2.5L', - '玻璃内胆杯', - ], - }, - { - name: '时尚保温杯专营店', - star: 4.68, - color: '#f59e0b', - gmv: 182.6, - orders: 11_240, - aov: 162.4, - grossRate: 22.8, - netRate: 11.6, - roi: 3.12, - refund: 6.8, - growth: 12.4, - products: [ - '时尚系列保温杯', - '莫兰迪色系杯', - '网红ins风水杯', - '韩系少女杯', - '极简设计师款', - ], - }, - { - name: '户外运动水具店', - star: 4.81, - color: '#10b981', - gmv: 124.8, - orders: 7680, - aov: 162.5, - grossRate: 28.4, - netRate: 16.2, - roi: 4.21, - refund: 3.9, - growth: -3.2, - products: [ - '运动健身水壶', - '户外登山杯', - '骑行专用杯', - '越野跑补水包', - '户外折叠杯', - ], - }, - { - name: '企业定制旗舰店', - star: 4.92, - color: '#3b82f6', - gmv: 68.4, - orders: 2840, - aov: 240.8, - grossRate: 31.6, - netRate: 19.4, - roi: 5.14, - refund: 2.1, - growth: 24.1, - products: [ - '企业LOGO定制杯', - '礼品套装定制', - '大批量采购款', - '高端礼盒定制', - '节日专属定制', - ], - }, -] as const; - -export const TRAFFIC_KPIS = [ - { - label: '总曝光量', - value: '1,284', - unit: '万', - changePct: 32.1, - up: true, - sub: '日均42.8万', - }, - { - label: '点击量', - value: '98.6', - unit: '万', - changePct: 28.4, - up: true, - sub: '点击率7.68%', - }, - { - label: '加购数', - value: '24.7', - unit: '万', - changePct: 19.2, - up: true, - sub: '加购转化25.1%', - }, - { - label: '成交转化率', - value: '1.87', - unit: '%', - changePct: 0.23, - up: true, - sub: '类目均值1.42%', - }, -] as const; - -export type TrafficFunnelRow = { label: string; rate?: string; value: string }; - -export const TRAFFIC_FUNNEL: TrafficFunnelRow[] = [ - { label: '曝光', value: '1,284万' }, - { label: '点击', value: '98.6万', rate: '点击率7.68%' }, - { label: '加购', value: '24.7万', rate: '加购率25.1%' }, - { label: '下单', value: '2.84万', rate: '下单率11.5%' }, - { label: '付款', value: '1.84万', rate: '支付率64.8%' }, -]; - -export const TRAFFIC_SOURCES = [ - { name: '多多搜索(自然)', pct: 32.4 }, - { name: '多多搜索(广告)', pct: 24.8 }, - { name: '多多场景推荐', pct: 16.2 }, - { name: '活动会场', pct: 12.6 }, - { name: '直播带货', pct: 8.4 }, - { name: '外部引流', pct: 5.6 }, -] as const; - -export const ADS_KPIS = [ - { - label: '广告总花费', - value: '73.8', - unit: '万', - changePct: 12.4, - up: true, - sub: '占GMV 25.8%', - }, - { - label: '广告GMV', - value: '271.6', - unit: '万', - changePct: 21.3, - up: true, - sub: 'ROI 3.68', - }, - { - label: '广告点击量', - value: '62.4', - unit: '万', - changePct: 18.7, - up: true, - sub: '均价¥1.18/次', - }, - { - label: '广告转化率', - value: '2.94', - unit: '%', - changePct: 0.42, - up: true, - sub: '自然流1.43%', - }, -] as const; - -export const AD_KEYWORDS = [ - { - keyword: '保温杯女款大容量', - impression: 186_420, - click: 14_230, - ctr: '7.63%', - cost: 16_804, - cpc: 1.18, - orders: 486, - gmv: 75_330, - roi: 4.48, - status: '优质', - statusType: 'success' as const, - }, - { - keyword: '不锈钢保温杯', - impression: 142_680, - click: 10_840, - ctr: '7.60%', - cost: 12_392, - cpc: 1.14, - orders: 352, - gmv: 52_248, - roi: 4.22, - status: '优质', - statusType: 'success' as const, - }, - { - keyword: '316不锈钢杯', - impression: 98_320, - click: 6920, - ctr: '7.04%', - cost: 9246, - cpc: 1.34, - orders: 218, - gmv: 32_428, - roi: 3.51, - status: '良好', - statusType: 'processing' as const, - }, - { - keyword: '保温杯男生', - impression: 74_200, - click: 4380, - ctr: '5.90%', - cost: 6132, - cpc: 1.4, - orders: 124, - gmv: 17_236, - roi: 2.81, - status: '观察', - statusType: 'default' as const, - }, - { - keyword: '学生杯子保温', - impression: 68_400, - click: 3980, - ctr: '5.82%', - cost: 5970, - cpc: 1.5, - orders: 98, - gmv: 12_740, - roi: 2.13, - status: '暂停', - statusType: 'error' as const, - }, - { - keyword: '礼盒保温杯套装', - impression: 52_100, - click: 2680, - ctr: '5.14%', - cost: 4824, - cpc: 1.8, - orders: 88, - gmv: 19_272, - roi: 3.99, - status: '良好', - statusType: 'processing' as const, - }, -]; - -export const PRODUCT_RANK = [ - { - rank: 1, - name: '316不锈钢保温杯-女款粉色500ML', - sku: 6, - price: 128, - sales: 2840, - gmv: 36.4, - pct: 12.7, - margin: 28.4, - refund: 3.2, - cvr: 2.84, - trendUp: true, - trendPct: 12.4, - }, - { - rank: 2, - name: '大容量保温杯男款军绿1000ML', - sku: 4, - price: 148, - sales: 2180, - gmv: 32.2, - pct: 11.2, - margin: 26.8, - refund: 4.1, - cvr: 2.54, - trendUp: true, - trendPct: 8.2, - }, - { - rank: 3, - name: '情侣对杯礼盒装经典款', - sku: 3, - price: 268, - sales: 1020, - gmv: 27.3, - pct: 9.5, - margin: 31.2, - refund: 5.8, - cvr: 1.86, - trendUp: false, - trendPct: 2.1, - }, - { - rank: 4, - name: '儿童保温杯卡通图案380ML', - sku: 8, - price: 68, - sales: 3640, - gmv: 24.7, - pct: 8.6, - margin: 22.4, - refund: 4.8, - cvr: 3.12, - trendUp: true, - trendPct: 15.6, - }, - { - rank: 5, - name: '316保温壶2.5L大容量家用', - sku: 3, - price: 198, - sales: 1120, - gmv: 22.2, - pct: 7.7, - margin: 29.6, - refund: 3.9, - cvr: 1.68, - trendUp: true, - trendPct: 5.3, - }, - { - rank: 6, - name: '玻璃内胆保温杯480ML', - sku: 5, - price: 158, - sales: 1280, - gmv: 20.2, - pct: 7, - margin: 24.2, - refund: 6.2, - cvr: 2.08, - trendUp: false, - trendPct: 1.8, - }, -]; - -/** 演示多维行:原常量为「万」,转为与接口一致的元(两位小数) */ -function demoWanToYuan(wan: number): number { - return Number((wan * 10_000).toFixed(2)); -} - -/** 多维分析 / 销售额榜:平台·店铺·品类·商品 统一行结构(演示数据,金额字段为元) */ -export type WorkbenchMultiRow = { - grossMarginPct: number; - grossProfitYuan: number; - key: string; - name: string; - netMarginPct: number; - netProfitYuan: number; - refundYuan: number; - salesYuan: number; -}; - -function storeToMultiRow(s: (typeof STORES)[number]): WorkbenchMultiRow { - const gmvWan = s.gmv; - return { - key: s.name, - name: s.name, - salesYuan: demoWanToYuan(gmvWan), - grossProfitYuan: demoWanToYuan((gmvWan * s.grossRate) / 100), - netProfitYuan: demoWanToYuan((gmvWan * s.netRate) / 100), - refundYuan: demoWanToYuan((gmvWan * s.refund) / 100), - grossMarginPct: s.grossRate, - netMarginPct: s.netRate, - }; -} - -export const MULTI_ANALYSIS_SHOP: WorkbenchMultiRow[] = STORES.map((s) => - storeToMultiRow(s), -); - -export const MULTI_ANALYSIS_PLATFORM: WorkbenchMultiRow[] = [ - { - key: 'pdd', - name: '拼多多', - salesYuan: demoWanToYuan(128.4), - grossProfitYuan: demoWanToYuan(32.1), - netProfitYuan: demoWanToYuan(18.6), - refundYuan: demoWanToYuan(6.2), - grossMarginPct: 25, - netMarginPct: 14.5, - }, - { - key: 'taobao', - name: '淘宝', - salesYuan: demoWanToYuan(86.2), - grossProfitYuan: demoWanToYuan(19.8), - netProfitYuan: demoWanToYuan(10.4), - refundYuan: demoWanToYuan(5.8), - grossMarginPct: 23, - netMarginPct: 12.1, - }, - { - key: 'jd', - name: '京东', - salesYuan: demoWanToYuan(52.6), - grossProfitYuan: demoWanToYuan(11.4), - netProfitYuan: demoWanToYuan(5.9), - refundYuan: demoWanToYuan(2.4), - grossMarginPct: 21.7, - netMarginPct: 11.2, - }, - { - key: 'douyin', - name: '抖音电商', - salesYuan: demoWanToYuan(41.2), - grossProfitYuan: demoWanToYuan(9.6), - netProfitYuan: demoWanToYuan(4.8), - refundYuan: demoWanToYuan(3), - grossMarginPct: 23.3, - netMarginPct: 11.7, - }, -]; - -export const MULTI_ANALYSIS_CATEGORY: WorkbenchMultiRow[] = [ - { - key: 'c1', - name: '不锈钢保温杯', - salesYuan: demoWanToYuan(142), - grossProfitYuan: demoWanToYuan(38.2), - netProfitYuan: demoWanToYuan(21.4), - refundYuan: demoWanToYuan(8.1), - grossMarginPct: 26.9, - netMarginPct: 15.1, - }, - { - key: 'c2', - name: '礼盒套装', - salesYuan: demoWanToYuan(68), - grossProfitYuan: demoWanToYuan(17.8), - netProfitYuan: demoWanToYuan(9.9), - refundYuan: demoWanToYuan(3.9), - grossMarginPct: 26.2, - netMarginPct: 14.6, - }, - { - key: 'c3', - name: '儿童水杯', - salesYuan: demoWanToYuan(42), - grossProfitYuan: demoWanToYuan(10.5), - netProfitYuan: demoWanToYuan(5.8), - refundYuan: demoWanToYuan(2.6), - grossMarginPct: 25, - netMarginPct: 13.8, - }, - { - key: 'c4', - name: '运动水壶', - salesYuan: demoWanToYuan(28), - grossProfitYuan: demoWanToYuan(7.8), - netProfitYuan: demoWanToYuan(4.2), - refundYuan: demoWanToYuan(1.5), - grossMarginPct: 27.9, - netMarginPct: 15, - }, - { - key: 'c5', - name: '定制企业版', - salesYuan: demoWanToYuan(16), - grossProfitYuan: demoWanToYuan(4.9), - netProfitYuan: demoWanToYuan(2.7), - refundYuan: demoWanToYuan(0.6), - grossMarginPct: 30.6, - netMarginPct: 16.9, - }, -]; - -export const MULTI_ANALYSIS_PRODUCT: WorkbenchMultiRow[] = PRODUCT_RANK.map( - (p) => { - const gmvWan = p.gmv; - const netMarginPct = Number((p.margin * 0.52).toFixed(1)); - return { - key: `p-${p.rank}`, - name: p.name, - salesYuan: demoWanToYuan(gmvWan), - grossProfitYuan: demoWanToYuan((gmvWan * p.margin) / 100), - netProfitYuan: demoWanToYuan((gmvWan * netMarginPct) / 100), - refundYuan: demoWanToYuan((gmvWan * p.refund) / 100), - grossMarginPct: p.margin, - netMarginPct, - }; - }, -); - -/** 多维分析 / 销售额榜:维度 key(与卡片顺序一致) */ -export type WorkbenchDimKey = 'category' | 'platform' | 'product' | 'shop'; - -export const WORKBENCH_MULTI_BY_DIM: Record< - WorkbenchDimKey, - WorkbenchMultiRow[] -> = { - category: MULTI_ANALYSIS_CATEGORY, - platform: MULTI_ANALYSIS_PLATFORM, - product: MULTI_ANALYSIS_PRODUCT, - shop: MULTI_ANALYSIS_SHOP, -}; - -export const PROMO_TIMELINE = [ - { - date: '01/01', - name: '元旦跨年狂欢节', - meta: '预热3天·主推保温杯礼盒', - gmv: '¥38.2万', - target: '目标¥35万·完成率109%', - status: '已完成', - tone: 'success' as const, - }, - { - date: '02/14', - name: '情人节专属活动', - meta: '预热5天·情侣对杯套装', - gmv: '¥52.6万', - target: '目标¥45万·完成率117%', - status: '已完成', - tone: 'success' as const, - }, - { - date: '03/08', - name: '女王节女生节', - meta: '预热7天·主推女款颜值系列', - gmv: '¥74.3万', - target: '目标¥60万·完成率124%', - status: '已完成', - tone: 'success' as const, - }, - { - date: '03/28', - name: '春季焕新大促', - meta: '预热中·全品类联动', - gmv: '进行中…', - target: '目标¥80万', - status: '进行中', - tone: 'processing' as const, - }, - { - date: '05/20', - name: '520情人节', - meta: '备货中', - gmv: '—', - target: '目标¥90万', - status: '筹备中', - tone: 'warning' as const, - }, - { - date: '06/18', - name: '618年中大促', - meta: '策划阶段', - gmv: '—', - target: '目标¥280万', - status: '筹备中', - tone: 'warning' as const, - }, -]; - -export const CATEGORY_GMV_SHARE = [ - { name: '不锈钢保温杯', value: 142 }, - { name: '礼盒套装', value: 68 }, - { name: '儿童水杯', value: 42 }, - { name: '运动水壶', value: 28 }, - { name: '定制企业版', value: 16 }, -] as const; - -export const PRODUCT_TIME_SEGMENTS = [ - { - product: '316不锈钢保温杯-女款', - w1: 4.2, - w2: 4.8, - w3: 5.1, - w4: 4.9, - total: 19, - up: true, - }, - { - product: '大容量保温杯-男款', - w1: 3.8, - w2: 3.6, - w3: 4, - w4: 3.9, - total: 15.3, - up: false, - }, - { - product: '情侣对杯礼盒', - w1: 2.9, - w2: 3.4, - w3: 3.8, - w4: 3.2, - total: 13.3, - up: true, - }, - { - product: '儿童保温杯卡通款', - w1: 3.2, - w2: 3.1, - w3: 3.5, - w4: 3.6, - total: 13.4, - up: true, - }, -] as const; - -export const PROMO_TABLE = [ - { - name: '元旦跨年狂欢', - period: '01/01-01/03', - targetGmv: '35万', - actualGmv: '38.2万', - rate: '109%', - adCost: '9.2万', - roi: '4.15', - gross: '24.8%', - refund: '4.3%', - newUser: '62%', - }, - { - name: '情人节专属', - period: '02/14-02/15', - targetGmv: '45万', - actualGmv: '52.6万', - rate: '117%', - adCost: '11.8万', - roi: '4.46', - gross: '26.2%', - refund: '5.1%', - newUser: '58%', - }, - { - name: '女王节女生节', - period: '03/08-03/10', - targetGmv: '60万', - actualGmv: '74.3万', - rate: '124%', - adCost: '16.4万', - roi: '4.53', - gross: '27.1%', - refund: '4.8%', - newUser: '65%', - }, -]; - -export function storeCompareRows() { - const rows = STORES.map((s) => ({ - key: s.name, - name: s.name, - gmv: s.gmv, - orders: s.orders, - aov: s.aov, - grossRate: s.grossRate, - netRate: s.netRate, - roi: s.roi, - refund: s.refund, - growth: s.growth, - isAvg: false, - })); - const n = STORES.length; - const avg = { - key: 'avg', - name: '全店平均', - gmv: Number((STORES.reduce((a, s) => a + s.gmv, 0) / n).toFixed(1)), - orders: Math.round(STORES.reduce((a, s) => a + s.orders, 0) / n), - aov: Number((STORES.reduce((a, s) => a + s.aov, 0) / n).toFixed(1)), - grossRate: Number( - (STORES.reduce((a, s) => a + s.grossRate, 0) / n).toFixed(1), - ), - netRate: Number((STORES.reduce((a, s) => a + s.netRate, 0) / n).toFixed(1)), - roi: Number((STORES.reduce((a, s) => a + s.roi, 0) / n).toFixed(2)), - refund: Number((STORES.reduce((a, s) => a + s.refund, 0) / n).toFixed(1)), - growth: Number((STORES.reduce((a, s) => a + s.growth, 0) / n).toFixed(1)), - isAvg: true, - }; - return [...rows, avg]; -} diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/index.vue index c5d98d29..afae7835 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/index.vue @@ -17,10 +17,10 @@ import type { WorkbenchDTO, WorkbenchVO } from '#/api/ecommerce/workbench/types' import { $t } from '#/locales'; import { normalizeOverviewRangePickerChange } from '#/utils/overview-date-range'; -import WorkbenchFinanceTab from './tabs/finance/WorkbenchFinanceTab.vue'; -import WorkbenchMultiTab from './tabs/multi/WorkbenchMultiTab.vue'; -import WorkbenchPeriodCompareTab from './tabs/compare/WorkbenchPeriodCompareTab.vue'; -import WorkbenchSalesRankTab from './tabs/sales-rank/WorkbenchSalesRankTab.vue'; +import WorkbenchFinanceTab from './tabs/finance/index.vue'; +import WorkbenchMultiTab from './tabs/multi/index.vue'; +import WorkbenchPeriodCompareTab from './tabs/compare/index.vue'; +import WorkbenchSalesRankTab from './tabs/sales-rank/index.vue'; defineOptions({ name: 'PddWorkbench' }); @@ -247,6 +247,10 @@ async function loadShopAndPlatformMeta() { const activeTab = ref('finance'); +function handleShopNavigate(shopId: number) { + router.push(`/ecom/shop/overview/${shopId}`); +} + const financeTabRef = ref | null>( null, ); @@ -514,6 +518,7 @@ onUnmounted(() => { :finance="financePanel" :multi-analysis="multiPanel" :summary-tables="summaryTablesPanel" + @navigate="handleShopNavigate" /> diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/overview-mock.ts b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/overview-mock.ts deleted file mode 100644 index ff4e9e2e..00000000 --- a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/overview-mock.ts +++ /dev/null @@ -1,324 +0,0 @@ -/** - * 工作台「全店概览」同款表格的演示数据(单位与 VO 一致:元、单量等) - */ -import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview'; - -import { PRODUCT_RANK, STORES } from './data'; - -const TAX = 0.04; - -function buildShopRow( - shopId: number, - shopName: string, - /** 演示用「万」为单位的销售额,函数内转为元 */ - salesWan: number, - orderCount: number, - refundPct: number, - roi: number, -): CompanyOverviewVO.ShopSummary { - const salesAmount = Math.round(salesWan * 10_000); - const averageOrderValue = salesAmount / Math.max(1, orderCount); - const targetOrderCount = Math.max(1, Math.round(orderCount / 1.11)); - const orderCountAchievementRate = (orderCount / targetOrderCount) * 100; - const targetAmount = salesAmount / 1.13; - const salesAmountAchievementRate = (salesAmount / targetAmount) * 100; - const productCost = salesAmount * 0.354; - const shippingCost = salesAmount * 0.043; - const otherCost = salesAmount * 0.027; - const totalCost = productCost + shippingCost + otherCost; - const refundAmount = salesAmount * (refundPct / 100); - const totalPromotionFee = salesAmount * 0.252; - const brushFee = salesAmount * 0.006; - const feeRatio = (totalPromotionFee / salesAmount) * 100; - const totalProfitBeforeTax = - salesAmount - totalCost - refundAmount - totalPromotionFee - brushFee; - const salesTaxAmount = salesAmount * TAX; - const profitAfterTax = totalProfitBeforeTax - salesTaxAmount; - return { - shopId, - shopName, - targetOrderCount, - orderCountAchievementRate, - targetAmount, - salesAmountAchievementRate, - salesAmount, - orderCount, - averageOrderValue, - productCost, - shippingCost, - otherCost, - totalCost, - refundAmount, - totalPromotionFee, - brushFee, - feeRatio, - totalProfitBeforeTax, - salesTaxAmount, - roi, - profitAfterTax, - }; -} - -function aggregateShopTotal( - shops: CompanyOverviewVO.ShopSummary[], -): CompanyOverviewVO.ShopSummary { - const sum = (k: keyof CompanyOverviewVO.ShopSummary) => - shops.reduce((a, x) => a + (Number(x[k]) || 0), 0); - const salesAmount = sum('salesAmount'); - const orderCount = sum('orderCount') || 1; - const targetOrderCount = sum('targetOrderCount') || 1; - const targetAmount = sum('targetAmount') || 1; - const totalPromotionFee = sum('totalPromotionFee'); - const averageOrderValue = salesAmount / orderCount; - const orderCountAchievementRate = (orderCount / targetOrderCount) * 100; - const salesAmountAchievementRate = (salesAmount / targetAmount) * 100; - const feeRatio = salesAmount ? (totalPromotionFee / salesAmount) * 100 : 0; - const totalProfitBeforeTax = sum('totalProfitBeforeTax'); - const salesTaxAmount = sum('salesTaxAmount'); - const profitAfterTax = sum('profitAfterTax'); - const roi = totalPromotionFee ? salesAmount / totalPromotionFee : 0; - return { - shopId: 0, - shopName: '合计', - targetOrderCount: sum('targetOrderCount'), - orderCountAchievementRate, - targetAmount: sum('targetAmount'), - salesAmountAchievementRate, - salesAmount, - orderCount, - averageOrderValue, - productCost: sum('productCost'), - shippingCost: sum('shippingCost'), - otherCost: sum('otherCost'), - totalCost: sum('totalCost'), - refundAmount: sum('refundAmount'), - totalPromotionFee, - brushFee: sum('brushFee'), - feeRatio, - totalProfitBeforeTax, - salesTaxAmount, - roi, - profitAfterTax, - }; -} - -function buildCategoryRow( - categoryId: number, - categoryName: string, - salesAmount: number, - orderCount: number, - refundPct: number, - roi: number, -): CompanyOverviewVO.CategorySummary { - const averageOrderValue = salesAmount / Math.max(1, orderCount); - const productCost = salesAmount * 0.352; - const shippingCost = salesAmount * 0.044; - const otherCost = salesAmount * 0.026; - const totalCost = productCost + shippingCost + otherCost; - const refundAmount = salesAmount * (refundPct / 100); - const totalPromotionFee = salesAmount * 0.255; - const brushFee = salesAmount * 0.005; - const feeRatio = (totalPromotionFee / salesAmount) * 100; - const totalProfitBeforeTax = - salesAmount - totalCost - refundAmount - totalPromotionFee - brushFee; - const salesTaxAmount = salesAmount * TAX; - const profitAfterTax = totalProfitBeforeTax - salesTaxAmount; - return { - categoryId, - categoryName, - salesAmount, - orderCount, - averageOrderValue, - productCost, - shippingCost, - otherCost, - totalCost, - refundAmount, - totalPromotionFee, - brushFee, - feeRatio, - totalProfitBeforeTax, - salesTaxAmount, - roi, - profitAfterTax, - }; -} - -function aggregateCategoryTotal( - rows: CompanyOverviewVO.CategorySummary[], -): CompanyOverviewVO.CategorySummary { - const sum = (k: keyof CompanyOverviewVO.CategorySummary) => - rows.reduce((a, x) => a + (Number(x[k]) || 0), 0); - const salesAmount = sum('salesAmount'); - const orderCount = sum('orderCount') || 1; - const totalPromotionFee = sum('totalPromotionFee'); - const averageOrderValue = salesAmount / orderCount; - const feeRatio = salesAmount ? (totalPromotionFee / salesAmount) * 100 : 0; - const roi = totalPromotionFee ? salesAmount / totalPromotionFee : 0; - return { - categoryName: '合计', - salesAmount, - orderCount, - averageOrderValue, - productCost: sum('productCost'), - shippingCost: sum('shippingCost'), - otherCost: sum('otherCost'), - totalCost: sum('totalCost'), - refundAmount: sum('refundAmount'), - totalPromotionFee, - brushFee: sum('brushFee'), - feeRatio, - totalProfitBeforeTax: sum('totalProfitBeforeTax'), - salesTaxAmount: sum('salesTaxAmount'), - roi, - profitAfterTax: sum('profitAfterTax'), - }; -} - -function buildPlatformRow( - platformId: number, - platformName: string, - salesAmount: number, - orderCount: number, - orderAchPct: number, - salesAchPct: number, -): CompanyOverviewVO.PlatformSummary { - const averageOrderValue = salesAmount / Math.max(1, orderCount); - const targetOrderCount = orderCount / (orderAchPct / 100); - const orderCountAchievementRate = orderAchPct; - const targetAmount = salesAmount / (salesAchPct / 100); - const salesAmountAchievementRate = salesAchPct; - const productCost = salesAmount * 0.356; - const shippingCost = salesAmount * 0.041; - const otherCost = salesAmount * 0.029; - const totalCost = productCost + shippingCost + otherCost; - const refundAmount = salesAmount * 0.048; - const totalPromotionFee = salesAmount * 0.251; - const brushFee = salesAmount * 0.007; - const feeRatio = (totalPromotionFee / salesAmount) * 100; - const totalProfitBeforeTax = - salesAmount - totalCost - refundAmount - totalPromotionFee - brushFee; - const salesTaxAmount = salesAmount * TAX; - const profitAfterTax = totalProfitBeforeTax - salesTaxAmount; - const roi = totalPromotionFee ? salesAmount / totalPromotionFee : 0; - return { - platformId, - platformName, - targetOrderCount, - orderCountAchievementRate, - targetAmount, - salesAmountAchievementRate, - salesAmount, - orderCount, - averageOrderValue, - productCost, - shippingCost, - otherCost, - totalCost, - refundAmount, - totalPromotionFee, - brushFee, - feeRatio, - totalProfitBeforeTax, - salesTaxAmount, - roi, - profitAfterTax, - }; -} - -function aggregatePlatformTotal( - rows: CompanyOverviewVO.PlatformSummary[], -): CompanyOverviewVO.PlatformSummary { - const sum = (k: keyof CompanyOverviewVO.PlatformSummary) => - rows.reduce((a, x) => a + (Number(x[k]) || 0), 0); - const salesAmount = sum('salesAmount'); - const orderCount = sum('orderCount') || 1; - const targetOrderCount = sum('targetOrderCount') || 1; - const targetAmount = sum('targetAmount') || 1; - const totalPromotionFee = sum('totalPromotionFee'); - const averageOrderValue = salesAmount / orderCount; - const orderCountAchievementRate = (orderCount / targetOrderCount) * 100; - const salesAmountAchievementRate = (salesAmount / targetAmount) * 100; - const feeRatio = salesAmount ? (totalPromotionFee / salesAmount) * 100 : 0; - const roi = totalPromotionFee ? salesAmount / totalPromotionFee : 0; - return { - platformId: 0, - platformName: '合计', - targetOrderCount: sum('targetOrderCount'), - orderCountAchievementRate, - targetAmount: sum('targetAmount'), - salesAmountAchievementRate, - salesAmount, - orderCount, - averageOrderValue, - productCost: sum('productCost'), - shippingCost: sum('shippingCost'), - otherCost: sum('otherCost'), - totalCost: sum('totalCost'), - refundAmount: sum('refundAmount'), - totalPromotionFee, - brushFee: sum('brushFee'), - feeRatio, - totalProfitBeforeTax: sum('totalProfitBeforeTax'), - salesTaxAmount: sum('salesTaxAmount'), - roi, - profitAfterTax: sum('profitAfterTax'), - }; -} - -export function getWorkbenchShopOverview(): CompanyOverviewVO.ShopOverview { - const shops = STORES.map((s, i) => - buildShopRow(i + 1, s.name, s.gmv, s.orders, s.refund, s.roi), - ); - return { - shops, - total: aggregateShopTotal(shops), - }; -} - -export function getWorkbenchPlatformOverview(): CompanyOverviewVO.PlatformOverview { - const platforms: CompanyOverviewVO.PlatformSummary[] = [ - buildPlatformRow(1, '拼多多', 1_182_000, 7620, 106.4, 106.4), - buildPlatformRow(2, '抖音电商', 864_000, 5280, 98.2, 98.2), - buildPlatformRow(3, '淘宝', 526_000, 3120, 112.0, 112.0), - buildPlatformRow(4, '京东', 292_000, 1452, 91.6, 91.6), - ]; - return { - platforms, - total: aggregatePlatformTotal(platforms), - }; -} - -export function getWorkbenchCategoryOverview(): CompanyOverviewVO.CategoryOverview { - const categories: CompanyOverviewVO.CategorySummary[] = [ - buildCategoryRow(1, '不锈钢保温杯', 1_420_000, 9280, 4.8, 3.62), - buildCategoryRow(2, '礼盒套装', 680_000, 2860, 5.2, 3.45), - buildCategoryRow(3, '儿童水杯', 420_000, 5120, 5.0, 3.58), - buildCategoryRow(4, '运动水壶', 280_000, 1680, 4.2, 3.71), - buildCategoryRow(5, '定制企业版', 160_000, 420, 2.5, 3.88), - ]; - return { - categories, - total: aggregateCategoryTotal(categories), - }; -} - -/** 商品维度:复用品类 VO 结构,名称写入 categoryName */ -export function getWorkbenchProductAsCategoryOverview(): CompanyOverviewVO.CategoryOverview { - const categories: CompanyOverviewVO.CategorySummary[] = PRODUCT_RANK.map((p) => { - const salesAmount = Math.round(p.gmv * 10_000); - const orderCount = Math.max(1, Math.round(p.sales * 0.38)); - return buildCategoryRow( - p.rank, - p.name, - salesAmount, - orderCount, - p.refund, - 3.12 + p.rank * 0.07, - ); - }); - return { - categories, - total: aggregateCategoryTotal(categories), - }; -} diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/compare/WorkbenchPeriodCompareTab.vue b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/compare/index.vue similarity index 100% rename from ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/compare/WorkbenchPeriodCompareTab.vue rename to ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/compare/index.vue diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchCategoryComparisonTable.vue b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/CategoryComparisonTable.vue similarity index 100% rename from ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchCategoryComparisonTable.vue rename to ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/CategoryComparisonTable.vue diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchFinanceCostPieChart.vue b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/FinanceCostPieChart.vue similarity index 75% rename from ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchFinanceCostPieChart.vue rename to ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/FinanceCostPieChart.vue index fbb85b9c..8100c993 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchFinanceCostPieChart.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/FinanceCostPieChart.vue @@ -2,11 +2,10 @@ import type { EchartsUIType } from '@vben/plugins/echarts'; import type { WorkbenchVO } from '#/api/ecommerce/workbench/types'; -import { computed, nextTick, onMounted, ref, watch } from 'vue'; +import { nextTick, onMounted, ref, watch } from 'vue'; import { EchartsUI, useEcharts } from '@vben/plugins/echarts'; -import { COST_STRUCTURE_PIE_COLORS } from '../../../data'; import { formatWanShort, formatYuanDetail } from '../../../workbench-money'; defineOptions({ name: 'WorkbenchFinanceCostPieChart' }); @@ -16,22 +15,18 @@ const props = defineProps<{ }>(); const SLICE_COLOR_BY_NAME: Record = { - 商品成本: COST_STRUCTURE_PIE_COLORS[1] ?? '#f97316', - 物流费用: COST_STRUCTURE_PIE_COLORS[4] ?? '#fb923c', - 其他成本: COST_STRUCTURE_PIE_COLORS[5] ?? '#fdba74', - 推广费: COST_STRUCTURE_PIE_COLORS[2] ?? '#ea580c', - 刷单费: COST_STRUCTURE_PIE_COLORS[3] ?? '#f43f5e', - 税费: COST_STRUCTURE_PIE_COLORS[5] ?? '#94a3b8', - 净利润: COST_STRUCTURE_PIE_COLORS[0] ?? '#059669', + 商品成本: '#2563eb', + 物流费用: '#d97706', + 其他成本: '#94a3b8', + 推广费: '#e11d48', + 刷单费: '#ea580c', + 税费: '#94a3b8', + 净利润: '#059669', }; const chartOverviewShell = 'overflow-hidden rounded-2xl border border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-white/90 dark:bg-[hsl(222.34deg_10.43%_12.27%)] shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]'; -const costTotalYuan = computed(() => - props.costStructure.reduce((a, x) => a + (Number(x.value) || 0), 0), -); - const costPieChartRef = ref(); const { renderEcharts: renderCostPieChart } = useEcharts(costPieChartRef); @@ -86,14 +81,11 @@ function drawCostPie() { length2: 8, lineStyle: { color: isDark ? 'hsl(240deg 3.7% 35%)' : '#cbd5e1' }, }, - data: props.costStructure.map((row, i) => ({ + data: props.costStructure.map((row) => ({ name: row.name, value: row.value ?? 0, itemStyle: { - color: - SLICE_COLOR_BY_NAME[row.name] ?? - COST_STRUCTURE_PIE_COLORS[i] ?? - '#6366f1', + color: SLICE_COLOR_BY_NAME[row.name] ?? '#6366f1', }, })), }, @@ -131,12 +123,6 @@ defineExpose({ redraw }); > 成本结构(占销售额 %) -

- 合计约 {{ formatWanShort(costTotalYuan) }} · - 接口金额为元;图表按占比展示,悬停可见精确元与占销售额比例 -

diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchFinanceKpiGrid.vue b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/FinanceKpiGrid.vue similarity index 100% rename from ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchFinanceKpiGrid.vue rename to ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/FinanceKpiGrid.vue diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchFinanceTrendChart.vue b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/FinanceTrendChart.vue similarity index 82% rename from ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchFinanceTrendChart.vue rename to ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/FinanceTrendChart.vue index 7e4271cb..4cbeb69f 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchFinanceTrendChart.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/FinanceTrendChart.vue @@ -75,27 +75,12 @@ function drawFinanceTrend() { series: [ { name: '实际销售额(万)', - type: 'bar', + type: 'line', + smooth: true, + symbolSize: 6, data: props.trend.map((d) => yuanToWanNum(Number(d.salesYuan ?? 0))), - barMaxWidth: 14, - itemStyle: { - color: { - type: 'linear', - x: 0, - y: 0, - x2: 0, - y2: 1, - colorStops: [ - { offset: 0, color: isDark ? '#60a5fa' : '#1d4ed8' }, - { - offset: 1, - color: isDark - ? 'rgba(37, 99, 235, 0.35)' - : 'rgba(37, 99, 235, 0.22)', - }, - ], - }, - }, + lineStyle: { width: 2.5, color: isDark ? '#60a5fa' : '#1d4ed8' }, + itemStyle: { color: isDark ? '#60a5fa' : '#1d4ed8' }, }, { name: '毛利(万)', @@ -117,14 +102,12 @@ function drawFinanceTrend() { }, { name: '退款(万)', - type: 'bar', + type: 'line', + smooth: true, + symbolSize: 6, data: props.trend.map((d) => yuanToWanNum(Number(d.refundYuan ?? 0))), - barMaxWidth: 8, - itemStyle: { - color: isDark - ? 'rgba(251, 113, 133, 0.75)' - : 'rgba(244, 63, 94, 0.55)', - }, + lineStyle: { width: 2.5, color: isDark ? '#fb7185' : '#e11d48' }, + itemStyle: { color: isDark ? '#fb7185' : '#e11d48' }, }, ], }); @@ -160,11 +143,6 @@ defineExpose({ redraw }); > 实际销售额、毛利与净利趋势 -

- 柱=实际销售额 / 退款;绿线=日毛利(销售额−成本−退款),紫线=日净利(毛利按日分摊推广、刷单与税额);与 KPI 及多维分析口径一致 -

diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchOverviewTables.vue b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/OverviewTables.vue similarity index 91% rename from ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchOverviewTables.vue rename to ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/OverviewTables.vue index 0db72be7..6457410f 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/WorkbenchOverviewTables.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/tabs/finance/components/OverviewTables.vue @@ -8,9 +8,9 @@ import { message, Segmented } from 'ant-design-vue'; import { exportByPost } from '#/utils/export'; -import WorkbenchCategoryComparisonTable from './WorkbenchCategoryComparisonTable.vue'; -import WorkbenchPlatformSummaryCard from './WorkbenchPlatformSummaryCard.vue'; -import WorkbenchShopComparisonTable from './WorkbenchShopComparisonTable.vue'; +import CategoryComparisonTable from './CategoryComparisonTable.vue'; +import PlatformSummaryCard from './PlatformSummaryCard.vue'; +import ShopComparisonTable from './ShopComparisonTable.vue'; defineOptions({ name: 'WorkbenchOverviewTables' }); @@ -29,6 +29,9 @@ const props = withDefaults( exportContext: null, }, ); +const emit = defineEmits<{ + (e: 'navigate', shopId: number): void; +}>(); const activeMode = ref<'category' | 'platform' | 'product' | 'shop'>('shop'); const shopExportMode = ref(false); @@ -171,11 +174,6 @@ async function handleProductExport() {