feat: 优化工作台静态页面设计

This commit is contained in:
小蟑螂
2026-05-12 23:22:14 +08:00
parent f5d7fbe2b0
commit 3d87b7f706
7 changed files with 670 additions and 329 deletions
@@ -19,6 +19,10 @@ interface Props {
taxRate: number;
categoryExportMode?: boolean;
selectedExportCategoryIds?: number[];
headingTitle?: string;
headingSubtitle?: string;
/** 首列维度名称,如「品类」「商品」 */
firstColumnLabel?: string;
}
interface Emits {
@@ -30,6 +34,9 @@ interface Emits {
const props = withDefaults(defineProps<Props>(), {
categoryExportMode: false,
selectedExportCategoryIds: () => [],
headingTitle: '各品类多维度经营明细汇总',
headingSubtitle: '包含:规模、成本及最终损益所有维度',
firstColumnLabel: '品类',
});
const emit = defineEmits<Emits>();
@@ -62,10 +69,10 @@ const cellRoi = (v: number | null | undefined) =>
>
<div>
<h3 class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
各品类多维度经营明细汇总
{{ props.headingTitle }}
</h3>
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
包含:规模、成本及最终损益所有维度
{{ props.headingSubtitle }}
</p>
</div>
<div class="flex items-center gap-3">
@@ -131,7 +138,7 @@ const cellRoi = (v: number | null | undefined) =>
rowspan="2"
class="sticky-col border-b p-6 text-base font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)] border-r-2 border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] shadow-sm dark:shadow-none"
>
品类
{{ props.firstColumnLabel }}
</th>
<th
colspan="3"
@@ -18,6 +18,8 @@ interface Props {
platformSummary?: CompanyOverviewVO.PlatformOverview;
platformExportMode?: boolean;
selectedExportPlatformIds?: number[];
headingTitle?: string;
headingSubtitle?: string;
}
interface Emits {
@@ -29,6 +31,8 @@ interface Emits {
const props = withDefaults(defineProps<Props>(), {
platformExportMode: false,
selectedExportPlatformIds: () => [],
headingTitle: '各平台多维度经营明细汇总',
headingSubtitle: '目标达成 · 规模 · 成本费用 · 盈利分析,四大维度完整汇总',
});
const emit = defineEmits<Emits>();
@@ -112,10 +116,10 @@ const sortedData = computed(() => {
>
<div>
<h3 class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
各平台多维度经营明细汇总
{{ props.headingTitle }}
</h3>
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
目标达成 · 规模 · 成本费用 · 盈利分析,四大维度完整汇总
{{ props.headingSubtitle }}
</p>
</div>
<div class="flex items-center gap-3">
@@ -22,6 +22,10 @@ interface Props {
taxRate: number;
shopExportMode: boolean;
selectedExportShopIds: number[];
/** 覆盖默认表头主标题(如工作台演示) */
headingTitle?: string;
/** 覆盖默认表头副标题 */
headingSubtitle?: string;
}
interface Emits {
@@ -31,7 +35,10 @@ interface Emits {
(e: 'navigate', shopId: number): void;
}
const props = defineProps<Props>();
const props = withDefaults(defineProps<Props>(), {
headingTitle: '各店铺多维度经营明细汇总',
headingSubtitle: '包含:目标达成、规模、成本及最终损益所有维度',
});
const emit = defineEmits<Emits>();
const allShopsSelected = computed(() => {
@@ -65,10 +72,10 @@ const cellRoi = (v: number | null | undefined) =>
>
<div>
<h3 class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
各店铺多维度经营明细汇总
{{ props.headingTitle }}
</h3>
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
包含:目标达成、规模、成本及最终损益所有维度
{{ props.headingSubtitle }}
</p>
</div>
<div class="flex items-center gap-3">
@@ -0,0 +1,167 @@
<script lang="ts" setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { message, Segmented } from 'ant-design-vue';
import CategoryComparisonTable from '../store-overview/components/CategoryComparisonTable.vue';
import PlatformSummaryCard from '../store-overview/components/PlatformSummaryCard.vue';
import ShopComparisonTable from '../store-overview/components/ShopComparisonTable.vue';
import {
getWorkbenchCategoryOverview,
getWorkbenchPlatformOverview,
getWorkbenchProductAsCategoryOverview,
getWorkbenchShopOverview,
} from './overview-mock';
defineOptions({ name: 'WorkbenchOverviewTables' });
const taxRate = ref(0.04);
const activeMode = ref<'shop' | 'platform' | 'category' | 'product'>('shop');
const shopOverview = getWorkbenchShopOverview();
const platformOverview = getWorkbenchPlatformOverview();
const categoryOverview = getWorkbenchCategoryOverview();
const productOverview = getWorkbenchProductAsCategoryOverview();
const shopExportMode = ref(false);
const selectedExportShopIds = ref<number[]>([]);
const platformExportMode = ref(false);
const selectedExportPlatformIds = ref<number[]>([]);
const categoryExportMode = ref(false);
const selectedExportCategoryIds = ref<number[]>([]);
const productExportMode = ref(false);
const selectedExportProductIds = ref<number[]>([]);
const router = useRouter();
const modeOptions = [
{ label: '店铺汇总', value: 'shop' },
{ label: '平台汇总', value: 'platform' },
{ label: '品类汇总', value: 'category' },
{ label: '商品汇总', value: 'product' },
];
function demoExportHint() {
message.warning('工作台为静态演示,导出请使用「全店概览」页面');
}
function navigateToShopOverview(shopId: number) {
router.push({
path: `/ecom/shop/overview/${shopId}`,
});
}
</script>
<template>
<div class="space-y-4">
<p class="text-xs font-bold text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
下列表格与「全店概览」使用相同组件与列结构(演示数据,可替换为接口返回的 VO)。
</p>
<div class="flex justify-end">
<Segmented
v-model:value="activeMode"
:options="modeOptions"
class="workbench-overview-segmented"
/>
</div>
<ShopComparisonTable
v-if="activeMode === 'shop'"
heading-title="各店铺多维度经营明细汇总(演示)"
heading-subtitle="与「全店概览」同款表格;对接接口后可替换为实时数据"
:shop-summary="shopOverview"
:tax-rate="taxRate"
:shop-export-mode="shopExportMode"
:selected-export-shop-ids="selectedExportShopIds"
@update:selected-export-shop-ids="selectedExportShopIds = $event"
@toggle-shop-export-mode="shopExportMode = $event"
@export="demoExportHint"
@navigate="navigateToShopOverview"
/>
<PlatformSummaryCard
v-if="activeMode === 'platform'"
heading-title="各平台多维度经营明细汇总(演示)"
heading-subtitle="与「全店概览」同款表格;对接接口后可替换为实时数据"
:platform-summary="platformOverview"
:tax-rate="taxRate"
:platform-export-mode="platformExportMode"
:selected-export-platform-ids="selectedExportPlatformIds"
@update:selected-export-platform-ids="selectedExportPlatformIds = $event"
@toggle-platform-export-mode="platformExportMode = $event"
@export="demoExportHint"
/>
<CategoryComparisonTable
v-if="activeMode === 'category'"
heading-title="各品类多维度经营明细汇总(演示)"
heading-subtitle="与「全店概览」同款表格;对接接口后可替换为实时数据"
:category-summary="categoryOverview"
:tax-rate="taxRate"
:category-export-mode="categoryExportMode"
:selected-export-category-ids="selectedExportCategoryIds"
@update:selected-export-category-ids="selectedExportCategoryIds = $event"
@toggle-category-export-mode="categoryExportMode = $event"
@export="demoExportHint"
/>
<CategoryComparisonTable
v-if="activeMode === 'product'"
heading-title="各商品多维度经营明细汇总(演示)"
heading-subtitle="列结构与品类表一致,首列为商品名称;对接接口后可替换为实时数据"
first-column-label="商品"
:category-summary="productOverview"
:tax-rate="taxRate"
:category-export-mode="productExportMode"
:selected-export-category-ids="selectedExportProductIds"
@update:selected-export-category-ids="selectedExportProductIds = $event"
@toggle-category-export-mode="productExportMode = $event"
@export="demoExportHint"
/>
</div>
</template>
<style scoped>
:deep(.ant-segmented-thumb) {
border-radius: 999px !important;
}
:deep(.workbench-overview-segmented) {
background: rgb(148 163 184 / 16%);
border-radius: 999px;
padding: 4px;
}
:deep(.workbench-overview-segmented .ant-segmented-item) {
border-radius: 999px;
}
:deep(.workbench-overview-segmented .ant-segmented-item-label) {
font-weight: 700;
padding: 6px 16px;
border-radius: 999px;
}
:deep(.workbench-overview-segmented .ant-segmented-item-selected) {
background: white;
color: #1d4ed8;
box-shadow: 0 1px 3px rgb(0 0 0 / 10%);
}
:global(html.dark) :deep(.workbench-overview-segmented) {
background: hsl(240deg 3.7% 22% / 70%);
}
:global(html.dark) :deep(.workbench-overview-segmented .ant-segmented-item) {
border-radius: 999px;
color: hsl(240deg 5% 64.9%);
}
:global(html.dark) :deep(.workbench-overview-segmented .ant-segmented-item-selected) {
background: hsl(220deg 13% 18%);
color: #60a5fa;
box-shadow: 0 1px 3px hsl(0 0 0% / 30%);
}
</style>
@@ -107,88 +107,17 @@ export const COST_STRUCTURE = [
{ name: '其他费用', value: 18.0, pct: 6.6 },
] as const;
/** 与 COST_STRUCTURE 顺序一一对应,用于成本结构饼图 */
/** 与 COST_STRUCTURE 顺序一一对应;配色对齐全店概览表(盈利翠绿 / 规模蓝 / 成本橙红系 / 退款灰) */
export const COST_STRUCTURE_PIE_COLORS = [
'#22c55e',
'#3b82f6',
'#ef4444',
'#f59e0b',
'#a855f7',
'#059669',
'#2563eb',
'#e11d48',
'#ea580c',
'#d97706',
'#94a3b8',
'#14b8a6',
'#0d9488',
] as const;
/** 商品销量 TOP5(演示):件数、GMV、环比 */
export type ProductSalesTopItem = {
rank: number;
name: string;
sales: number;
gmvWan: number;
momPct: number;
barColor: string;
};
export const PRODUCT_SALES_TOP5: ProductSalesTopItem[] = [
{
rank: 1,
name: '316不锈钢保温杯-女款 500ml',
sales: 42_860,
gmvWan: 42.6,
momPct: 18.2,
barColor: '#f59e0b',
},
{
rank: 2,
name: '大容量运动水壶 1.2L 吸管款',
sales: 31_240,
gmvWan: 28.9,
momPct: 9.6,
barColor: '#6366f1',
},
{
rank: 3,
name: '玻璃内胆保温壶 2.5L 家用',
sales: 24_180,
gmvWan: 36.2,
momPct: -2.1,
barColor: '#10b981',
},
{
rank: 4,
name: '儿童保温杯卡通款 350ml',
sales: 19_650,
gmvWan: 15.4,
momPct: 6.8,
barColor: '#a855f7',
},
{
rank: 5,
name: '情侣对杯礼盒 限定包装',
sales: 15_920,
gmvWan: 22.7,
momPct: 14.0,
barColor: '#ec4899',
},
];
/** 平台销量 TOP5(演示):万件 + 占比 */
export type PlatformSalesTopItem = {
rank: number;
label: string;
short: string;
salesWan: number;
sharePct: number;
color: string;
};
export const PLATFORM_SALES_TOP5: PlatformSalesTopItem[] = [
{ rank: 1, label: '拼多多', short: 'PDD', salesWan: 58.2, sharePct: 38.6, color: '#e02e24' },
{ rank: 2, label: '抖音电商', short: '抖店', salesWan: 36.4, sharePct: 24.1, color: '#fe2c55' },
{ rank: 3, label: '淘宝', short: 'TB', salesWan: 28.7, sharePct: 19.0, color: '#ff5000' },
{ rank: 4, label: '京东', short: 'JD', salesWan: 21.3, sharePct: 14.1, color: '#e3393c' },
{ rank: 5, label: '快手小店', short: 'KS', salesWan: 6.2, sharePct: 4.1, color: '#ff6600' },
];
export const STORES = [
{
name: '优品生活旗舰店',
@@ -27,9 +27,7 @@ import {
GLOBAL_SUMMARY,
GMV_TREND,
PLATFORM_OPTIONS,
PLATFORM_SALES_TOP5,
PRODUCT_RANK,
PRODUCT_SALES_TOP5,
PRODUCT_TIME_SEGMENTS,
PROMO_TABLE,
PROMO_TIMELINE,
@@ -39,6 +37,7 @@ import {
TRAFFIC_SOURCES,
storeCompareRows,
} from './data';
import WorkbenchOverviewTables from './WorkbenchOverviewTables.vue';
defineOptions({ name: 'PddWorkbench' });
@@ -86,27 +85,6 @@ const costTotal = computed(() =>
COST_STRUCTURE.reduce((a, x) => a + x.value, 0),
);
const productSalesTopMax = computed(() =>
Math.max(...PRODUCT_SALES_TOP5.map((x) => x.sales), 1),
);
const platformSalesTopMax = computed(() =>
Math.max(...PLATFORM_SALES_TOP5.map((x) => x.salesWan), 0.01),
);
const rankMedalClass = (rank: number) => {
if (rank === 1) {
return 'bg-gradient-to-br from-amber-400 to-orange-600 text-white shadow-md shadow-amber-500/30';
}
if (rank === 2) {
return 'bg-gradient-to-br from-slate-300 to-slate-500 text-slate-900 dark:from-slate-500 dark:to-slate-700 dark:text-white';
}
if (rank === 3) {
return 'bg-gradient-to-br from-amber-700 to-orange-900 text-amber-100';
}
return 'bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-300';
};
const keywordColumnsSimple = [
{ title: '关键词', dataIndex: 'keyword', key: 'keyword', ellipsis: true },
{ title: '曝光量', dataIndex: 'impression', key: 'impression' },
@@ -183,10 +161,10 @@ const drawFinanceTrend = () => {
},
legend: {
top: 0,
textStyle: { color: axisLabel },
textStyle: { color: axisLabel, fontWeight: 700 },
data: ['GMV(万)', '净利润(万)', '退款(万)'],
},
grid: { left: '3%', right: '3%', bottom: '3%', top: 48, containLabel: true },
grid: { left: '3%', right: '3%', bottom: '3%', top: 52, containLabel: true },
xAxis: {
type: 'category',
data: GMV_TREND.map((d) => d.date),
@@ -212,8 +190,8 @@ const drawFinanceTrend = () => {
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: '#6366f1' },
{ offset: 1, color: 'rgba(99, 102, 241, 0.25)' },
{ offset: 0, color: isDark ? '#60a5fa' : '#1d4ed8' },
{ offset: 1, color: isDark ? 'rgba(37, 99, 235, 0.35)' : 'rgba(37, 99, 235, 0.22)' },
],
},
},
@@ -224,15 +202,15 @@ const drawFinanceTrend = () => {
smooth: true,
symbolSize: 6,
data: GMV_TREND.map((d) => d.profit),
lineStyle: { width: 2.5, color: '#10b981' },
itemStyle: { color: '#10b981' },
lineStyle: { width: 2.5, color: isDark ? '#34d399' : '#059669' },
itemStyle: { color: isDark ? '#34d399' : '#059669' },
},
{
name: '退款(万)',
type: 'bar',
data: GMV_TREND.map((d) => d.refund),
barMaxWidth: 8,
itemStyle: { color: 'rgba(148, 163, 184, 0.55)' },
itemStyle: { color: isDark ? 'rgba(251, 113, 133, 0.75)' : 'rgba(244, 63, 94, 0.55)' },
},
],
});
@@ -345,6 +323,10 @@ const kpiCardClass =
const panelCardClass =
'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%)] p-6 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]';
/** 与全店概览汇总表同款外框(无内边距,由头/体分区) */
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]';
</script>
<template>
@@ -370,92 +352,110 @@ const panelCardClass =
<template #extra>
<div
class="flex w-full max-w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-3"
class="flex w-full max-w-full flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center sm:gap-3"
>
<!-- 平台 / 店铺:与时间快捷按钮同款外框 + 内浅色槽 -->
<div
class="flex w-full min-w-0 flex-col gap-2 rounded-2xl border border-slate-200 bg-slate-200/50 px-2 py-2 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)] sm:w-auto sm:flex-row sm:items-center sm:gap-3"
class="flex w-full min-w-0 flex-1 rounded-2xl border border-slate-200 bg-slate-200/50 p-1.5 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)] sm:min-w-0 sm:max-w-xl lg:max-w-2xl"
>
<div class="flex min-w-0 flex-1 items-center gap-2 sm:max-w-[220px]">
<span class="shrink-0 text-xs font-bold text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
电商平台
</span>
<Select
v-model:value="selectedPlatform"
size="small"
:options="platformSelectOptions"
placeholder="选择平台"
class="workbench-header-select min-w-0 flex-1"
/>
</div>
<div class="flex min-w-0 flex-1 items-center gap-2 sm:max-w-[280px]">
<span class="shrink-0 text-xs font-bold text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
店铺
</span>
<Select
v-model:value="selectedStoreIndex"
size="small"
:options="storeSelectOptions"
placeholder="选择店铺"
class="workbench-header-select min-w-0 flex-1"
/>
<div
class="flex min-w-0 flex-col gap-2 rounded-xl bg-white/30 p-1 dark:bg-[hsl(240deg_3.7%_22%/30%)] sm:flex-row sm:items-center sm:gap-0 sm:divide-x sm:divide-slate-300/50 dark:sm:divide-[hsl(240deg_3.7%_35%)]"
>
<div
class="flex min-w-0 flex-1 items-center gap-2 px-2 py-0.5 sm:py-0"
>
<span
class="w-9 shrink-0 text-right text-xs font-bold text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
>平台</span>
<Select
v-model:value="selectedPlatform"
size="small"
:options="platformSelectOptions"
placeholder="选择平台"
class="workbench-header-select min-w-0 flex-1"
/>
</div>
<div
class="flex min-w-0 flex-1 items-center gap-2 border-t border-slate-200/80 px-2 pt-2 dark:border-[hsl(240deg_3.7%_22%)] sm:border-t-0 sm:pt-0 sm:py-0"
>
<span
class="w-9 shrink-0 text-right text-xs font-bold text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
>店铺</span>
<Select
v-model:value="selectedStoreIndex"
size="small"
:options="storeSelectOptions"
placeholder="选择店铺"
class="workbench-header-select min-w-0 flex-1"
/>
</div>
</div>
</div>
<div
class="flex w-full flex-wrap items-center gap-1 rounded-2xl border border-slate-200 bg-slate-200/50 p-1.5 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)] sm:w-auto"
class="flex w-full flex-wrap items-center gap-1 rounded-2xl border border-slate-200 bg-slate-200/50 p-1.5 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)] sm:w-auto sm:shrink-0"
>
<Button
type="text"
size="small"
class="!h-auto !min-w-0 !rounded-xl !border-none !px-3 !py-2 !text-sm !font-bold !shadow-none sm:!px-4"
:class="periodBtnClass('today')"
@click="activePeriod = 'today'"
<div
class="flex w-full flex-wrap items-center gap-1 rounded-xl bg-white/30 p-1 dark:bg-[hsl(240deg_3.7%_22%/30%)]"
>
今日
</Button>
<Button
type="text"
size="small"
class="!h-auto !min-w-0 !rounded-xl !border-none !px-3 !py-2 !text-sm !font-bold !shadow-none sm:!px-4"
:class="periodBtnClass('7d')"
@click="activePeriod = '7d'"
>
近7天
</Button>
<Button
type="text"
size="small"
class="!h-auto !min-w-0 !rounded-xl !border-none !px-3 !py-2 !text-sm !font-bold !shadow-none sm:!px-4"
:class="periodBtnClass('30d')"
@click="activePeriod = '30d'"
>
近30天
</Button>
<Button
type="text"
size="small"
class="!h-auto !min-w-0 !rounded-xl !border-none !px-3 !py-2 !text-sm !font-bold !shadow-none sm:!px-4"
:class="periodBtnClass('90d')"
@click="activePeriod = '90d'"
>
近90天
</Button>
<Button
type="text"
size="small"
class="!h-auto !min-w-0 !rounded-xl !border-none !px-3 !py-2 !text-sm !font-bold !shadow-none sm:!px-4"
:class="periodBtnClass('month')"
@click="activePeriod = 'month'"
>
本月
</Button>
<Button
type="text"
size="small"
class="!h-auto !min-w-0 !rounded-xl !border-none !px-3 !py-2 !text-sm !font-bold !shadow-none sm:!px-4"
:class="periodBtnClass('today')"
@click="activePeriod = 'today'"
>
今日
</Button>
<Button
type="text"
size="small"
class="!h-auto !min-w-0 !rounded-xl !border-none !px-3 !py-2 !text-sm !font-bold !shadow-none sm:!px-4"
:class="periodBtnClass('7d')"
@click="activePeriod = '7d'"
>
近7天
</Button>
<Button
type="text"
size="small"
class="!h-auto !min-w-0 !rounded-xl !border-none !px-3 !py-2 !text-sm !font-bold !shadow-none sm:!px-4"
:class="periodBtnClass('30d')"
@click="activePeriod = '30d'"
>
近30天
</Button>
<Button
type="text"
size="small"
class="!h-auto !min-w-0 !rounded-xl !border-none !px-3 !py-2 !text-sm !font-bold !shadow-none sm:!px-4"
:class="periodBtnClass('90d')"
@click="activePeriod = '90d'"
>
近90天
</Button>
<Button
type="text"
size="small"
class="!h-auto !min-w-0 !rounded-xl !border-none !px-3 !py-2 !text-sm !font-bold !shadow-none sm:!px-4"
:class="periodBtnClass('month')"
@click="activePeriod = 'month'"
>
本月
</Button>
</div>
</div>
<div
class="text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"
class="flex w-full flex-wrap items-center justify-center gap-x-1 gap-y-1 rounded-2xl border border-slate-200 bg-slate-200/50 p-1.5 text-xs font-bold text-slate-500 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)] dark:text-[hsl(240deg_5%_64.9%)] sm:w-auto sm:shrink-0 sm:justify-start"
>
环比
<span class="text-emerald-600 dark:text-emerald-400">+{{ GLOBAL_SUMMARY.mom }}%</span>
· 同比
<span class="text-emerald-600 dark:text-emerald-400">+{{ GLOBAL_SUMMARY.yoy }}%</span>
<div
class="flex w-full flex-wrap items-center justify-center gap-x-1 gap-y-1 rounded-xl bg-white/30 px-2 py-1.5 dark:bg-[hsl(240deg_3.7%_22%/30%)] sm:justify-start sm:px-3"
>
环比
<span class="text-emerald-600 dark:text-emerald-400">+{{ GLOBAL_SUMMARY.mom }}%</span>
<span class="text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">·</span>
同比
<span class="text-emerald-600 dark:text-emerald-400">+{{ GLOBAL_SUMMARY.yoy }}%</span>
</div>
</div>
</div>
</template>
@@ -501,150 +501,43 @@ const panelCardClass =
</div>
<div class="grid grid-cols-1 gap-6 xl:grid-cols-2">
<div :class="panelCardClass">
<h3 class="mb-1 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
GMV 与净利润趋势
</h3>
<p class="mb-4 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
柱=GMV,线=净利润,灰柱=退款(示例区间)
</p>
<div class="h-[280px] w-full">
<EchartsUI ref="financeChartRef" />
<div :class="chartOverviewShell">
<div
class="border-b border-slate-100 px-6 pb-6 pt-6 dark:border-b-[hsl(240deg_3.7%_22%)] md:px-8 md:pb-6 md:pt-8"
>
<h3 class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
GMV 与净利润趋势
</h3>
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
柱=GMV,线=净利润,浅柱=退款(示例区间)
</p>
</div>
<div class="px-6 py-5 md:px-8 md:py-6">
<div class="h-[280px] w-full">
<EchartsUI ref="financeChartRef" />
</div>
</div>
</div>
<div :class="panelCardClass">
<h3 class="mb-1 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
成本结构拆解(占实收比例示意)
</h3>
<p class="mb-4 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
合计约 {{ costTotal.toFixed(1) }} 万 · 扇区面积按金额(万)占比;悬浮可见占实收比例
</p>
<div class="h-[280px] w-full">
<EchartsUI ref="costPieChartRef" />
<div :class="chartOverviewShell">
<div
class="border-b border-slate-100 px-6 pb-6 pt-6 dark:border-b-[hsl(240deg_3.7%_22%)] md:px-8 md:pb-6 md:pt-8"
>
<h3 class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
成本结构拆解(占实收比例示意)
</h3>
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
合计约 {{ costTotal.toFixed(1) }} 万 · 扇区按金额(万)占比;悬浮可见占实收比例
</p>
</div>
<div class="px-6 py-5 md:px-8 md:py-6">
<div class="h-[280px] w-full">
<EchartsUI ref="costPieChartRef" />
</div>
</div>
</div>
</div>
<div class="grid grid-cols-1 gap-6 xl:grid-cols-2">
<div :class="panelCardClass">
<div class="mb-5 flex flex-wrap items-end justify-between gap-2">
<div>
<h3 class="text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
商品销量 TOP5
</h3>
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
近30天 · 按销量件数 · 含 GMV 与环比(演示)
</p>
</div>
</div>
<ul class="space-y-5">
<li
v-for="row in PRODUCT_SALES_TOP5"
:key="row.rank"
class="rounded-xl border border-slate-100 bg-slate-50/80 p-3 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/35%)]"
>
<div class="flex gap-3">
<div
class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl text-sm font-black tabular-nums"
:class="rankMedalClass(row.rank)"
>
{{ row.rank }}
</div>
<div class="min-w-0 flex-1">
<div class="flex flex-wrap items-start justify-between gap-x-2 gap-y-1">
<p class="min-w-0 flex-1 text-sm font-bold leading-snug text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
{{ row.name }}
</p>
<span
class="shrink-0 text-right text-sm font-black tabular-nums text-slate-900 dark:text-[hsl(0deg_0%_95%)]"
>
{{ row.sales.toLocaleString() }}
<span class="text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">件</span>
</span>
</div>
<div class="mt-1.5 flex flex-wrap items-center justify-between gap-2 text-xs font-bold text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
<span>GMV {{ row.gmvWan }} 万</span>
<Tag :color="row.momPct >= 0 ? 'success' : 'error'" class="!m-0 !text-[11px]">
环比 {{ row.momPct >= 0 ? '+' : '' }}{{ row.momPct }}%
</Tag>
</div>
<div class="mt-2 h-2 overflow-hidden rounded-full bg-slate-200/80 dark:bg-slate-900/60">
<div
class="h-full rounded-full transition-[width] duration-500"
:style="{
width: `${Math.round((row.sales / productSalesTopMax) * 100)}%`,
backgroundColor: row.barColor,
boxShadow: `0 0 12px ${row.barColor}55`,
}"
/>
</div>
</div>
</div>
</li>
</ul>
</div>
<div :class="panelCardClass">
<div class="mb-5 flex flex-wrap items-end justify-between gap-2">
<div>
<h3 class="text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
平台销量 TOP5
</h3>
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
全店铺聚合 · 销量(万件)与占比(演示)
</p>
</div>
</div>
<ul class="space-y-4">
<li
v-for="p in PLATFORM_SALES_TOP5"
:key="p.rank"
class="flex items-center gap-3 rounded-xl border border-slate-100 bg-slate-50/80 px-3 py-3 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/35%)]"
>
<div
class="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-xs font-black tabular-nums"
:class="rankMedalClass(p.rank)"
>
{{ p.rank }}
</div>
<div
class="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl text-[11px] font-black ring-1 ring-slate-200/80 dark:ring-[hsl(240deg_3.7%_22%)]"
:style="{
backgroundColor: `${p.color}18`,
color: p.color,
}"
>
{{ p.short }}
</div>
<div class="min-w-0 flex-1">
<div class="flex flex-wrap items-baseline justify-between gap-2">
<span class="truncate text-sm font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
{{ p.label }}
</span>
<span class="shrink-0 text-sm font-black tabular-nums text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
{{ p.salesWan }}<span class="text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">万件</span>
</span>
</div>
<div class="mt-2 flex items-center gap-3">
<div class="h-2 min-w-0 flex-1 overflow-hidden rounded-full bg-slate-200/80 dark:bg-slate-900/60">
<div
class="h-full rounded-full"
:style="{
width: `${Math.round((p.salesWan / platformSalesTopMax) * 100)}%`,
backgroundColor: p.color,
boxShadow: `0 0 10px ${p.color}44`,
}"
/>
</div>
<span class="w-12 shrink-0 text-right text-xs font-black tabular-nums text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
{{ p.sharePct }}%
</span>
</div>
</div>
</li>
</ul>
</div>
</div>
<WorkbenchOverviewTables />
</div>
</Tabs.TabPane>
@@ -1034,6 +927,17 @@ const panelCardClass =
border-radius: 0.75rem !important;
border: none !important;
font-weight: 700;
font-size: 0.875rem !important;
line-height: 1.25rem !important;
min-height: 2.125rem !important;
display: flex !important;
align-items: center !important;
background-color: rgb(255 255 255 / 0.92) !important;
}
:deep(.workbench-header-select.ant-select-single .ant-select-selector .ant-select-selection-item),
:deep(.workbench-header-select.ant-select-single .ant-select-selector .ant-select-selection-placeholder) {
line-height: 1.25rem !important;
}
html.dark :deep(.workbench-header-select .ant-select-selector) {
@@ -0,0 +1,323 @@
/**
* 工作台「全店概览」同款表格的演示数据(单位与 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,
gmvWan: number,
orderCount: number,
refundPct: number,
roi: number,
): CompanyOverviewVO.ShopSummary {
const salesAmount = Math.round(gmvWan * 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),
};
}