mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
feat: 优化静态页面UI
This commit is contained in:
@@ -6,10 +6,17 @@ export const GLOBAL_SUMMARY = {
|
||||
periodLabel: '近30天',
|
||||
mom: 18.3,
|
||||
yoy: 42.7,
|
||||
currentStoreName: '优品生活旗舰店',
|
||||
storeRating: 4.87,
|
||||
};
|
||||
|
||||
/** 电商平台筛选(演示,对接接口后可替换) */
|
||||
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',
|
||||
@@ -100,6 +107,17 @@ export const COST_STRUCTURE = [
|
||||
{ name: '其他费用', value: 18.0, pct: 6.6 },
|
||||
] as const;
|
||||
|
||||
/** 与 COST_STRUCTURE 顺序一一对应,用于成本结构饼图 */
|
||||
export const COST_STRUCTURE_PIE_COLORS = [
|
||||
'#22c55e',
|
||||
'#3b82f6',
|
||||
'#ef4444',
|
||||
'#f59e0b',
|
||||
'#a855f7',
|
||||
'#94a3b8',
|
||||
'#14b8a6',
|
||||
] as const;
|
||||
|
||||
export const FUNNEL_STEPS = [
|
||||
{ name: 'GMV', value: 286.4 },
|
||||
{ name: '实收金额', value: 271.8 },
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
Card,
|
||||
Progress,
|
||||
Radio,
|
||||
Select,
|
||||
Table,
|
||||
Tabs,
|
||||
Tag,
|
||||
@@ -21,12 +22,14 @@ import {
|
||||
ADS_KPIS,
|
||||
CATEGORY_GMV_SHARE,
|
||||
COST_STRUCTURE,
|
||||
COST_STRUCTURE_PIE_COLORS,
|
||||
FINANCE_KPIS,
|
||||
FUNNEL_STAGE_COLORS,
|
||||
FUNNEL_STEPS,
|
||||
GLOBAL_SUMMARY,
|
||||
GMV_TREND,
|
||||
MONTHLY_GMV_NET_RATE,
|
||||
PLATFORM_OPTIONS,
|
||||
PRODUCT_RANK,
|
||||
PRODUCT_TIME_SEGMENTS,
|
||||
PROMO_TABLE,
|
||||
@@ -45,6 +48,18 @@ type PeriodKey = 'today' | '7d' | '30d' | '90d' | 'month';
|
||||
const activePeriod = ref<PeriodKey>('30d');
|
||||
const activeTab = ref('finance');
|
||||
const selectedStoreIndex = ref(0);
|
||||
const selectedPlatform = ref<string>('pdd');
|
||||
|
||||
const storeSelectOptions = computed(() =>
|
||||
STORES.map((s, i) => ({
|
||||
label: `${s.name}(${s.star})`,
|
||||
value: i,
|
||||
})),
|
||||
);
|
||||
|
||||
const platformSelectOptions = computed(() =>
|
||||
PLATFORM_OPTIONS.map((o) => ({ label: o.label, value: o.value })),
|
||||
);
|
||||
|
||||
const financeChartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts: renderFinanceTrend } = useEcharts(financeChartRef);
|
||||
@@ -55,6 +70,9 @@ const { renderEcharts: renderFunnelChart } = useEcharts(funnelChartRef);
|
||||
const monthlyChartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts: renderMonthlyChart } = useEcharts(monthlyChartRef);
|
||||
|
||||
const costPieChartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts: renderCostPieChart } = useEcharts(costPieChartRef);
|
||||
|
||||
const compareDataSource = computed(() => storeCompareRows());
|
||||
|
||||
const selectedStore = computed(() => STORES[selectedStoreIndex.value]!);
|
||||
@@ -338,9 +356,75 @@ const drawMonthlyGmvNetRate = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const drawCostPie = () => {
|
||||
if (!costPieChartRef.value) return;
|
||||
const isDark = document.documentElement.classList.contains('dark');
|
||||
const labelColor = isDark ? 'hsl(0deg 0% 95%)' : '#334155';
|
||||
const legendColor = isDark ? 'hsl(240deg 5% 64.9%)' : '#64748b';
|
||||
const border = isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff';
|
||||
|
||||
renderCostPieChart({
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff',
|
||||
textStyle: { color: isDark ? 'hsl(0deg 0% 95%)' : '#0f172a' },
|
||||
formatter: (params: any) => {
|
||||
const name = String(params.name ?? '');
|
||||
const val = Number(params.value ?? 0);
|
||||
const row = COST_STRUCTURE.find((r) => r.name === name);
|
||||
const pctText = row
|
||||
? `${row.pct}%(占实收)`
|
||||
: `${Number(params.percent ?? 0).toFixed(1)}%`;
|
||||
return `${name}<br/>${val} 万<br/>${pctText}`;
|
||||
},
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
right: '0',
|
||||
top: 'center',
|
||||
itemWidth: 10,
|
||||
itemHeight: 10,
|
||||
textStyle: { color: legendColor, fontSize: 11, fontWeight: 700 },
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'pie',
|
||||
radius: ['40%', '68%'],
|
||||
center: ['36%', '50%'],
|
||||
avoidLabelOverlap: true,
|
||||
itemStyle: {
|
||||
borderRadius: 6,
|
||||
borderColor: border,
|
||||
borderWidth: 2,
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
formatter: '{b}\n{d}%',
|
||||
color: labelColor,
|
||||
fontSize: 11,
|
||||
fontWeight: 700,
|
||||
},
|
||||
labelLine: {
|
||||
length: 12,
|
||||
length2: 8,
|
||||
lineStyle: { color: isDark ? 'hsl(240deg 3.7% 35%)' : '#cbd5e1' },
|
||||
},
|
||||
data: COST_STRUCTURE.map((row, i) => ({
|
||||
name: row.name,
|
||||
value: row.value,
|
||||
itemStyle: {
|
||||
color: COST_STRUCTURE_PIE_COLORS[i] ?? '#6366f1',
|
||||
},
|
||||
})),
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
const rerenderFinanceCharts = async () => {
|
||||
await nextTick();
|
||||
drawFinanceTrend();
|
||||
drawCostPie();
|
||||
drawFunnel();
|
||||
drawMonthlyGmvNetRate();
|
||||
};
|
||||
@@ -409,12 +493,32 @@ const panelCardClass =
|
||||
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%)]"
|
||||
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"
|
||||
>
|
||||
<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 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>
|
||||
</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"
|
||||
@@ -533,21 +637,10 @@ const panelCardClass =
|
||||
成本结构拆解(占实收比例示意)
|
||||
</h3>
|
||||
<p class="mb-4 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
合计约 {{ costTotal.toFixed(1) }} 万 · 各分项来自原型看板
|
||||
合计约 {{ 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 class="h-[280px] w-full">
|
||||
<EchartsUI ref="costPieChartRef" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -955,6 +1048,20 @@ const panelCardClass =
|
||||
:deep(.workbench-tabs .ant-tabs-tab) {
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
:deep(.workbench-header-select) {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
:deep(.workbench-header-select .ant-select-selector) {
|
||||
border-radius: 0.75rem !important;
|
||||
border: none !important;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
html.dark :deep(.workbench-header-select .ant-select-selector) {
|
||||
background-color: hsl(240deg 3.7% 15.9% / 55%) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- 深色下 Tab 吸顶背景与页面一致(scoped 无法命中 html.dark) -->
|
||||
|
||||
Reference in New Issue
Block a user