Files
ecom-dmb/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/index.vue
T

967 lines
35 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script lang="ts" setup>
import type { EchartsUIType } from '@vben/plugins/echarts';
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
import { Page } from '@vben/common-ui';
import { $t } from '#/locales';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import {
Button,
Card,
Progress,
Radio,
Table,
Tabs,
Tag,
} from 'ant-design-vue';
import {
AD_KEYWORDS,
ADS_KPIS,
CATEGORY_GMV_SHARE,
COST_STRUCTURE,
FINANCE_KPIS,
FUNNEL_STAGE_COLORS,
FUNNEL_STEPS,
GLOBAL_SUMMARY,
GMV_TREND,
MONTHLY_GMV_NET_RATE,
PRODUCT_RANK,
PRODUCT_TIME_SEGMENTS,
PROMO_TABLE,
PROMO_TIMELINE,
STORES,
TRAFFIC_FUNNEL,
TRAFFIC_KPIS,
TRAFFIC_SOURCES,
storeCompareRows,
} from './data';
defineOptions({ name: 'PddWorkbench' });
type PeriodKey = 'today' | '7d' | '30d' | '90d' | 'month';
const activePeriod = ref<PeriodKey>('30d');
const activeTab = ref('finance');
const selectedStoreIndex = ref(0);
const financeChartRef = ref<EchartsUIType>();
const { renderEcharts: renderFinanceTrend } = useEcharts(financeChartRef);
const funnelChartRef = ref<EchartsUIType>();
const { renderEcharts: renderFunnelChart } = useEcharts(funnelChartRef);
const monthlyChartRef = ref<EchartsUIType>();
const { renderEcharts: renderMonthlyChart } = useEcharts(monthlyChartRef);
const compareDataSource = computed(() => storeCompareRows());
const selectedStore = computed(() => STORES[selectedStoreIndex.value]!);
const storeMiniKpis = computed(() => {
const s = selectedStore.value;
return [
{ label: 'GMV', value: `${s.gmv}万`, extra: `${s.growth >= 0 ? '▲' : '▼'}${Math.abs(s.growth)}%`, up: s.growth >= 0 },
{ label: '订单数', value: `${s.orders.toLocaleString()}单` },
{ label: '客单价', value: `${s.aov}元` },
{ label: '毛利率', value: `${s.grossRate}%` },
{ label: '净利率', value: `${s.netRate}%` },
{ label: '广告ROI', value: `${s.roi}:1` },
];
});
const costTotal = computed(() =>
COST_STRUCTURE.reduce((a, x) => a + x.value, 0),
);
const keywordColumnsSimple = [
{ title: '关键词', dataIndex: 'keyword', key: 'keyword', ellipsis: true },
{ title: '曝光量', dataIndex: 'impression', key: 'impression' },
{ title: '点击量', dataIndex: 'click', key: 'click' },
{ title: '点击率', dataIndex: 'ctr', key: 'ctr' },
{ title: '花费(元)', dataIndex: 'cost', key: 'cost' },
{ title: 'CPC', dataIndex: 'cpc', key: 'cpc' },
{ title: '订单数', dataIndex: 'orders', key: 'orders' },
{ title: 'GMV(元)', dataIndex: 'gmv', key: 'gmv' },
{ title: 'ROI', dataIndex: 'roi', key: 'roi' },
{ title: '状态', key: 'status', dataIndex: 'status' },
];
const productColumns = [
{ title: '排名', dataIndex: 'rank', key: 'rank', width: 64 },
{ title: '商品名称', dataIndex: 'name', key: 'name', ellipsis: true },
{ title: 'SKU数', dataIndex: 'sku', key: 'sku', width: 72 },
{ title: '售价(元)', dataIndex: 'price', key: 'price', width: 96 },
{ title: '销量', dataIndex: 'sales', key: 'sales', width: 88 },
{ title: 'GMV(万)', dataIndex: 'gmv', key: 'gmv', width: 96 },
{ title: 'GMV占比', key: 'pct', dataIndex: 'pct', width: 140 },
{ title: '毛利率', dataIndex: 'margin', key: 'margin', width: 88 },
{ title: '退款率', dataIndex: 'refund', key: 'refund', width: 88 },
{ title: '转化率', dataIndex: 'cvr', key: 'cvr', width: 88 },
{ title: '趋势', key: 'trend', width: 100 },
];
const promoColumns = [
{ title: '活动名称', dataIndex: 'name', key: 'name' },
{ title: '活动时间', dataIndex: 'period', key: 'period', width: 130 },
{ title: '目标GMV', dataIndex: 'targetGmv', key: 'targetGmv', width: 96 },
{ title: '实际GMV', dataIndex: 'actualGmv', key: 'actualGmv', width: 96 },
{ title: '完成率', dataIndex: 'rate', key: 'rate', width: 88 },
{ title: '广告花费', dataIndex: 'adCost', key: 'adCost', width: 96 },
{ title: 'ROI', dataIndex: 'roi', key: 'roi', width: 72 },
{ title: '毛利率', dataIndex: 'gross', key: 'gross', width: 88 },
{ title: '退款率', dataIndex: 'refund', key: 'refund', width: 88 },
{ title: '新客占比', dataIndex: 'newUser', key: 'newUser', width: 96 },
];
const compareColumns = [
{ title: '店铺名称', dataIndex: 'name', key: 'name', ellipsis: true },
{ title: 'GMV(万)', dataIndex: 'gmv', key: 'gmv', width: 100 },
{ title: '订单数', dataIndex: 'orders', key: 'orders', width: 110 },
{ title: '客单价(元)', dataIndex: 'aov', key: 'aov', width: 110 },
{ title: '毛利率', key: 'grossRate', dataIndex: 'grossRate', width: 88 },
{ title: '净利率', dataIndex: 'netRate', key: 'netRate', width: 88 },
{ title: '广告ROI', dataIndex: 'roi', key: 'roi', width: 96 },
{ title: '退款率', dataIndex: 'refund', key: 'refund', width: 88 },
{ title: 'GMV环比', key: 'growth', dataIndex: 'growth', width: 110 },
];
const productTimeColumns = [
{ title: '产品名称', dataIndex: 'product', key: 'product', ellipsis: true },
{ title: '第1段', dataIndex: 'w1', key: 'w1' },
{ title: '第2段', dataIndex: 'w2', key: 'w2' },
{ title: '第3段', dataIndex: 'w3', key: 'w3' },
{ title: '第4段', dataIndex: 'w4', key: 'w4' },
{ title: '区间合计', dataIndex: 'total', key: 'total' },
{ title: '趋势', key: 'up', dataIndex: 'up', width: 88 },
];
const drawFinanceTrend = () => {
if (!financeChartRef.value) return;
const isDark = document.documentElement.classList.contains('dark');
const axisLabel = isDark ? 'hsl(240deg 5% 64.9%)' : '#64748b';
const split = isDark ? 'hsl(240deg 3.7% 22%)' : '#f1f5f9';
renderFinanceTrend({
tooltip: {
trigger: 'axis',
backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff',
textStyle: { color: isDark ? 'hsl(0deg 0% 95%)' : '#0f172a' },
},
legend: {
top: 0,
textStyle: { color: axisLabel },
data: ['GMV(万)', '净利润(万)', '退款(万)'],
},
grid: { left: '3%', right: '3%', bottom: '3%', top: 48, containLabel: true },
xAxis: {
type: 'category',
data: GMV_TREND.map((d) => d.date),
axisLine: { lineStyle: { color: split } },
axisLabel: { color: axisLabel, fontSize: 11 },
},
yAxis: {
type: 'value',
splitLine: { lineStyle: { type: 'dashed', color: split } },
axisLabel: { color: axisLabel },
},
series: [
{
name: 'GMV(万)',
type: 'bar',
data: GMV_TREND.map((d) => d.gmv),
barMaxWidth: 14,
itemStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: '#6366f1' },
{ offset: 1, color: 'rgba(99, 102, 241, 0.25)' },
],
},
},
},
{
name: '净利润(万)',
type: 'line',
smooth: true,
symbolSize: 6,
data: GMV_TREND.map((d) => d.profit),
lineStyle: { width: 2.5, color: '#10b981' },
itemStyle: { color: '#10b981' },
},
{
name: '退款(万)',
type: 'bar',
data: GMV_TREND.map((d) => d.refund),
barMaxWidth: 8,
itemStyle: { color: 'rgba(148, 163, 184, 0.55)' },
},
],
});
};
const drawFunnel = () => {
if (!funnelChartRef.value) return;
const isDark = document.documentElement.classList.contains('dark');
const border = isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff';
renderFunnelChart({
tooltip: {
trigger: 'item',
backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff',
textStyle: { color: isDark ? 'hsl(0deg 0% 95%)' : '#0f172a' },
formatter: '{b}: <b>{c}</b> 万元',
},
series: [
{
type: 'funnel',
left: '6%',
width: '88%',
top: 16,
bottom: 8,
minSize: '8%',
maxSize: '100%',
sort: 'descending',
gap: 2,
label: {
show: true,
position: 'inside',
formatter: '{b}\n{c}万',
color: '#fff',
fontSize: 11,
fontWeight: 700,
},
labelLine: { show: false },
itemStyle: {
borderColor: border,
borderWidth: 2,
},
data: FUNNEL_STEPS.map((s, i) => ({
name: s.name,
value: s.value,
itemStyle: {
color: FUNNEL_STAGE_COLORS[i] ?? '#6366f1',
},
})),
},
],
});
};
const drawMonthlyGmvNetRate = () => {
if (!monthlyChartRef.value) return;
const isDark = document.documentElement.classList.contains('dark');
const axisLabel = isDark ? 'hsl(240deg 5% 64.9%)' : '#64748b';
const split = isDark ? 'hsl(240deg 3.7% 22%)' : '#f1f5f9';
renderMonthlyChart({
tooltip: {
trigger: 'axis',
backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff',
textStyle: { color: isDark ? 'hsl(0deg 0% 95%)' : '#0f172a' },
},
legend: {
top: 0,
textStyle: { color: axisLabel },
data: ['月GMV(万)', '净利率(%)'],
},
grid: { left: '3%', right: '3%', bottom: '3%', top: 48, containLabel: true },
xAxis: {
type: 'category',
data: [...MONTHLY_GMV_NET_RATE.months],
axisLine: { lineStyle: { color: split } },
axisLabel: { color: axisLabel, fontSize: 11 },
},
yAxis: [
{
type: 'value',
name: 'GMV(万)',
nameTextStyle: { color: axisLabel },
splitLine: { lineStyle: { type: 'dashed', color: split } },
axisLabel: { color: axisLabel },
},
{
type: 'value',
name: '净利率%',
min: 8,
max: 20,
position: 'right',
nameTextStyle: { color: axisLabel },
axisLabel: {
color: axisLabel,
formatter: '{value}%',
},
splitLine: { show: false },
},
],
series: [
{
name: '月GMV(万)',
type: 'bar',
data: [...MONTHLY_GMV_NET_RATE.gmvWan],
barMaxWidth: 22,
itemStyle: {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: '#6366f1' },
{ offset: 1, color: 'rgba(99, 102, 241, 0.35)' },
],
},
},
markPoint: {
data: [{ type: 'max', name: '峰值' }],
itemStyle: { color: '#f59e0b' },
},
},
{
name: '净利率(%)',
type: 'line',
yAxisIndex: 1,
smooth: true,
symbolSize: 6,
data: [...MONTHLY_GMV_NET_RATE.netRatePct],
lineStyle: { width: 2.5, color: '#10b981' },
itemStyle: { color: '#10b981' },
},
],
});
};
const rerenderFinanceCharts = async () => {
await nextTick();
drawFinanceTrend();
drawFunnel();
drawMonthlyGmvNetRate();
};
watch(activeTab, (k) => {
if (k === 'finance') {
setTimeout(() => rerenderFinanceCharts(), 80);
}
});
let darkObserver: MutationObserver | null = null;
onMounted(() => {
setTimeout(() => rerenderFinanceCharts(), 120);
darkObserver = new MutationObserver(() => {
if (activeTab.value === 'finance') {
rerenderFinanceCharts();
}
});
darkObserver.observe(document.documentElement, {
attributes: true,
attributeFilter: ['class'],
});
});
onUnmounted(() => {
darkObserver?.disconnect();
darkObserver = null;
});
const periodBtnClass = (key: PeriodKey) =>
activePeriod.value === key
? '!bg-white !text-blue-600 dark:!bg-blue-900/30 dark:!text-blue-400 !shadow-sm dark:!shadow-none'
: '!bg-transparent !text-slate-600 dark:!bg-[hsl(222.34deg_10.43%_12.27%/50%)] dark:!text-[hsl(240deg_5%_64.9%)] hover:!bg-[hsl(240deg_3.7%_22%)]';
const kpiCardClass =
'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-5 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px] sm:p-6';
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]';
</script>
<template>
<Page
auto-content-height
class="bg-[#f8fafc] dark:bg-[hsl(222.34deg_10.43%_12.27%)]"
content-padding-class="px-4 pb-4"
header-class="workbench-page-header"
>
<template #title>
<div
class="text-xl font-black tracking-tight text-slate-900 dark:text-[hsl(0deg_0%_98%)] sm:text-2xl md:text-3xl"
>
{{ $t('page.dashboard.workbench') }}
</div>
</template>
<template #description>
<span class="text-sm text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
多店铺 · 多维度经营数据(演示数据,接口就绪后可替换)
</span>
</template>
<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"
>
<div
class="flex flex-wrap items-center gap-2 rounded-2xl border border-slate-200 bg-slate-200/50 px-2 py-1.5 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)]"
>
<Tag color="blue">{{ GLOBAL_SUMMARY.currentStoreName }}</Tag>
<span class="text-xs font-bold text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
评分 {{ GLOBAL_SUMMARY.storeRating }}
</span>
</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"
>
<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
class="text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"
>
环比
<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>
</div>
</template>
<div class="workbench-page-body min-w-0">
<Tabs v-model:activeKey="activeTab" class="workbench-tabs">
<Tabs.TabPane key="finance" tab="财务概览">
<div class="mt-4 space-y-6">
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4">
<div v-for="(kpi, idx) in FINANCE_KPIS" :key="idx" :class="kpiCardClass">
<div class="mb-3 flex items-start justify-between gap-2">
<span
class="text-xs font-black text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
>
{{ kpi.label }}
</span>
<span
class="shrink-0 rounded-lg px-2 py-0.5 text-xs font-bold"
:class="
kpi.up
? 'bg-emerald-50 text-emerald-700 dark:bg-emerald-900/25 dark:text-emerald-400'
: 'bg-red-50 text-red-600 dark:bg-red-900/25 dark:text-red-400'
"
>
{{ kpi.up ? '▲' : '▼' }}{{ kpi.changePct }}{{ kpi.label === '广告ROI' ? '' : '%' }}
</span>
</div>
<div
class="text-3xl font-black leading-none text-slate-900 dark:text-[hsl(0deg_0%_95%)] sm:text-4xl"
>
{{ kpi.value
}}<span
v-if="kpi.unit"
class="ml-1 text-base font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"
>{{ kpi.unit }}</span>
</div>
<div
class="mt-4 border-t border-slate-100 pt-3 text-xs font-bold text-slate-400 dark:border-[hsl(240deg_3.7%_22%)] dark:text-[hsl(240deg_5%_64.9%)]"
>
{{ kpi.sub }}
</div>
</div>
</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>
</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="space-y-3">
<div v-for="row in COST_STRUCTURE" :key="row.name">
<div class="mb-1 flex justify-between text-xs font-bold">
<span class="text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ row.name }}</span>
<span class="text-slate-900 dark:text-[hsl(0deg_0%_95%)]">{{ row.value }}万 · {{ row.pct }}%</span>
</div>
<Progress
:percent="row.pct"
:show-info="false"
stroke-color="#6366f1"
trail-color="rgba(148,163,184,0.25)"
/>
</div>
</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%)]">
从 GMV 到净利润全链路拆解
</p>
<div class="h-[380px] w-full sm:h-[400px]">
<EchartsUI ref="funnelChartRef" />
</div>
</div>
<div :class="panelCardClass">
<h3 class="mb-1 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
月度 GMV &amp; 净利率环比
</h3>
<p class="mb-4 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
柱=月 GMV(万),折线=净利率(%)· 近12月
</p>
<div class="h-[300px] w-full sm:h-[320px]">
<EchartsUI ref="monthlyChartRef" />
</div>
</div>
</div>
</Tabs.TabPane>
<Tabs.TabPane key="multi" tab="多维分析">
<div class="mt-4 space-y-6">
<div :class="panelCardClass">
<div class="mb-4 text-xs font-black uppercase tracking-wide text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
选择店铺
</div>
<Radio.Group v-model:value="selectedStoreIndex" button-style="solid" class="w-full">
<Radio.Button
v-for="(s, i) in STORES"
:key="s.name"
:value="i"
class="!mb-2"
>
{{ s.name }}({{ s.star }})
</Radio.Button>
</Radio.Group>
</div>
<div class="grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6">
<div
v-for="(m, i) in storeMiniKpis"
:key="i"
:class="kpiCardClass + ' !p-4'"
>
<div class="text-[10px] font-black text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ m.label }}
</div>
<div class="mt-1 text-lg font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
{{ m.value }}
</div>
<div
v-if="m.extra"
class="mt-1 text-[10px] font-bold"
:class="m.up ? 'text-emerald-600' : 'text-red-500'"
>
{{ m.extra }}
</div>
</div>
</div>
<div :class="panelCardClass">
<h3 class="mb-4 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
跨店铺核心指标对比
</h3>
<Table
size="small"
:pagination="false"
:columns="compareColumns"
:data-source="compareDataSource"
:row-class-name="(r) => (r.isAvg ? 'bg-slate-50 dark:bg-[hsl(240deg_3.7%_15.9%/40%)]' : '')"
scroll-x
>
<template #bodyCell="{ column, record, text }">
<template v-if="column.key === 'growth' && !record.isAvg">
<Tag :color="text >= 0 ? 'success' : 'error'">
{{ text >= 0 ? '▲' : '▼' }}{{ Math.abs(text) }}%
</Tag>
</template>
<template v-else-if="column.key === 'growth' && record.isAvg">
{{ text }}%
</template>
<template v-else-if="column.key === 'grossRate' || column.key === 'netRate'">
{{ text }}%
</template>
<template v-else-if="column.key === 'refund'">
{{ text }}%
</template>
<template v-else>
{{ text }}
</template>
</template>
</Table>
</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 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ selectedStore.name }} · 近30天
</p>
<Table
size="small"
:pagination="false"
:columns="productTimeColumns"
:data-source="[...PRODUCT_TIME_SEGMENTS]"
row-key="product"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'up'">
<Tag :color="record.up ? 'success' : 'error'">
{{ record.up ? '↗ 上升' : '↘ 下降' }}
</Tag>
</template>
</template>
</Table>
</div>
</div>
</Tabs.TabPane>
<Tabs.TabPane key="traffic" tab="流量分析">
<div class="mt-4 space-y-6">
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4">
<div v-for="(kpi, idx) in TRAFFIC_KPIS" :key="idx" :class="kpiCardClass">
<div class="mb-2 text-xs font-black text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
{{ kpi.label }}
</div>
<div class="text-3xl font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
{{ kpi.value }}<span class="text-base font-bold text-slate-400">{{ kpi.unit }}</span>
</div>
<div class="mt-3 flex justify-between text-xs font-bold">
<span
:class="kpi.up ? 'text-emerald-600' : 'text-red-500'"
>{{ kpi.up ? '▲' : '▼' }}{{ kpi.changePct }}%</span>
<span class="text-slate-400">{{ kpi.sub }}</span>
</div>
</div>
</div>
<div
class="grid grid-cols-2 gap-px overflow-hidden rounded-2xl border border-slate-200 bg-slate-200 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_22%)] lg:grid-cols-5"
>
<div
v-for="(f, i) in TRAFFIC_FUNNEL"
:key="i"
class="bg-white/95 p-4 text-center dark:bg-[hsl(222.34deg_10.43%_12.27%)]"
>
<div class="text-lg font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
{{ f.value }}
</div>
<div class="mt-1 text-[10px] font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ f.label }}
</div>
<div
v-if="f.rate"
class="mt-1 text-[10px] font-bold text-emerald-600 dark:text-emerald-400"
>
{{ f.rate }}
</div>
</div>
</div>
<div :class="panelCardClass">
<h3 class="mb-4 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
流量来源结构(UV 占比 %)
</h3>
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
<div
v-for="src in TRAFFIC_SOURCES"
:key="src.name"
class="flex items-center gap-3"
>
<span class="w-[140px] shrink-0 truncate text-xs font-bold text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">
{{ src.name }}
</span>
<Progress :percent="src.pct" :format="(p) => `${p}%`" />
</div>
</div>
</div>
</div>
</Tabs.TabPane>
<Tabs.TabPane key="ads" tab="广告投放">
<div class="mt-4 space-y-6">
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4">
<div v-for="(kpi, idx) in ADS_KPIS" :key="idx" :class="kpiCardClass">
<div class="mb-2 text-xs font-black text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
{{ kpi.label }}
</div>
<div class="text-3xl font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
{{ kpi.value }}<span class="text-base font-bold text-slate-400">{{ kpi.unit }}</span>
</div>
<div class="mt-3 flex justify-between text-xs font-bold">
<span class="text-emerald-600">▲{{ kpi.changePct }}{{ kpi.label.includes('率') ? '%' : '%' }}</span>
<span class="text-slate-400">{{ kpi.sub }}</span>
</div>
</div>
</div>
<Card
:bordered="false"
class="!rounded-2xl !border !border-slate-200 !shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:!border-[hsl(240deg_3.7%_22%)] dark:!bg-[hsl(222.34deg_10.43%_12.27%)] dark:!shadow-none"
title="TOP 关键词 ROI 明细"
>
<Table
size="small"
:pagination="{ pageSize: 8 }"
:columns="keywordColumnsSimple"
:data-source="AD_KEYWORDS"
row-key="keyword"
scroll-x
>
<template #bodyCell="{ column, text }">
<template v-if="column.key === 'roi'">
<span
class="font-black"
:class="
text >= 4
? 'text-emerald-600'
: text >= 3
? 'text-amber-600'
: 'text-red-500'
"
>{{ text }}</span>
</template>
<template v-else-if="column.key === 'status'">
<Tag
:color="
text === '优质'
? 'success'
: text === '良好'
? 'processing'
: text === '观察'
? 'default'
: 'error'
"
>
{{ text }}
</Tag>
</template>
</template>
</Table>
</Card>
</div>
</Tabs.TabPane>
<Tabs.TabPane key="products" tab="商品排行">
<div class="mt-4 grid grid-cols-1 gap-6 xl:grid-cols-2">
<div :class="panelCardClass">
<h3 class="mb-4 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
品类 GMV 占比
</h3>
<div class="space-y-3">
<div v-for="c in CATEGORY_GMV_SHARE" :key="c.name">
<div class="mb-1 flex justify-between text-xs font-bold">
<span>{{ c.name }}</span>
<span>{{ c.value }}万</span>
</div>
<Progress
:percent="Math.round((c.value / 296) * 100)"
:format="(p) => `${p}%`"
/>
</div>
</div>
</div>
<div :class="panelCardClass + ' xl:col-span-1'">
<h3 class="mb-4 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
TOP 商品明细
</h3>
<Table
size="small"
:pagination="{ pageSize: 8 }"
:columns="productColumns"
:data-source="PRODUCT_RANK"
row-key="rank"
scroll-x
>
<template #bodyCell="{ column, record, text }">
<template v-if="column.key === 'pct'">
<div class="flex items-center gap-2">
<Progress
:percent="Math.round((record.gmv / 36.4) * 100)"
size="small"
:show-info="false"
class="!m-0 flex-1"
/>
<span class="text-xs font-bold text-slate-500">{{ text }}%</span>
</div>
</template>
<template v-else-if="column.key === 'margin' || column.key === 'refund' || column.key === 'cvr'">
{{ text }}%
</template>
<template v-else-if="column.key === 'trend'">
<Tag :color="record.trendUp ? 'success' : 'error'">
{{ record.trendUp ? '▲' : '▼' }}{{ record.trendPct }}%
</Tag>
</template>
</template>
</Table>
</div>
</div>
</Tabs.TabPane>
<Tabs.TabPane key="promotions" tab="活动复盘">
<div class="mt-4 space-y-6">
<div :class="panelCardClass">
<h3 class="mb-4 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
活动日历与复盘
</h3>
<div class="space-y-3">
<div
v-for="(p, i) in PROMO_TIMELINE"
:key="i"
class="flex flex-col gap-2 rounded-xl border border-slate-100 bg-slate-50/80 p-4 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/30%)] sm:flex-row sm:items-center sm:justify-between"
>
<div class="flex gap-4">
<div
class="flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-white text-sm font-black text-indigo-600 shadow-sm dark:bg-[hsl(222.34deg_10.43%_18%)] dark:text-indigo-400"
>
{{ p.date }}
</div>
<div>
<div class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
{{ p.name }}
</div>
<div class="mt-0.5 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ p.meta }}
</div>
</div>
</div>
<div class="flex flex-wrap items-center gap-3 sm:text-right">
<div>
<div class="text-base font-black text-amber-600 dark:text-amber-400">
{{ p.gmv }}
</div>
<div class="text-xs text-slate-400">{{ p.target }}</div>
</div>
<Tag
:color="
p.tone === 'success'
? 'success'
: p.tone === 'processing'
? 'processing'
: 'warning'
"
>
{{ p.status }}
</Tag>
</div>
</div>
</div>
</div>
<div :class="panelCardClass">
<h3 class="mb-4 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
活动核心指标汇总
</h3>
<Table
size="small"
:pagination="false"
:columns="promoColumns"
:data-source="PROMO_TABLE"
row-key="name"
scroll-x
/>
</div>
</div>
</Tabs.TabPane>
</Tabs>
</div>
</Page>
</template>
<style scoped>
:deep(.workbench-page-header) {
align-items: flex-start;
}
@media (min-width: 640px) {
:deep(.workbench-page-header) {
align-items: center;
}
}
:deep(.workbench-tabs.ant-tabs .ant-tabs-nav) {
position: sticky;
top: 0;
z-index: 20;
margin-bottom: 12px;
padding: 4px 0 10px;
background-color: #f8fafc;
border-bottom: 1px solid rgb(226 232 240);
}
:deep(.workbench-tabs .ant-tabs-tab) {
font-weight: 800;
}
</style>
<!-- 深色下 Tab 吸顶背景与页面一致(scoped 无法命中 html.dark) -->
<style>
html.dark .workbench-tabs.ant-tabs .ant-tabs-nav {
background-color: hsl(222.34deg 10.43% 12.27%);
border-bottom-color: hsl(240deg 3.7% 22%);
}
</style>