feat: 优化工作台页面UI

This commit is contained in:
2026-08-12 22:56:41 +08:00
parent 055367bbd4
commit 44fb58b878
11 changed files with 1137 additions and 157 deletions
@@ -13,6 +13,8 @@ import {
storeOverviewHints,
} from '#/utils/overview-table-hints';
import { FINANCE_PANEL_SHELL } from '../finance-ui';
defineOptions({ name: 'WorkbenchCategorySummaryTable' });
const JumpIcon = createIconifyIcon('tdesign:jump');
@@ -68,30 +70,28 @@ const cellRoi = (v: number | null | undefined) =>
</script>
<template>
<div
class="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]"
>
<div :class="FINANCE_PANEL_SHELL">
<div
class="flex flex-col items-start justify-between gap-4 border-b border-slate-100 dark:border-b-[hsl(240deg_3.7%_22%)] p-8 md:flex-row md:items-center"
class="flex flex-col items-start justify-between gap-4 border-b border-slate-100 p-5 md:flex-row md:items-center md:px-6 dark:border-b-[hsl(240deg_3.7%_22%)]"
>
<div>
<h3 class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
<h3 class="text-base font-semibold 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%)]">
<p class="mt-1 text-xs font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ props.headingSubtitle }}
</p>
</div>
<div class="flex items-center gap-3">
<template v-if="categoryExportMode">
<button
class="rounded-2xl border border-slate-300 bg-white px-4 py-2 text-sm font-bold text-slate-700 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
@click="emit('toggleCategoryExportMode', false)"
>
取消选择
</button>
<button
class="rounded-2xl bg-blue-600 px-8 py-3 text-sm font-bold text-white shadow-xl shadow-slate-200 transition-all hover:scale-105 active:scale-95 dark:shadow-none"
class="rounded-[10px] bg-blue-500 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(59,130,246,0.28)] transition-colors hover:bg-blue-600 disabled:opacity-50 dark:shadow-none"
:disabled="selectedExportCategoryIds.length === 0"
@click="emit('export')"
>
@@ -100,13 +100,13 @@ const cellRoi = (v: number | null | undefined) =>
</template>
<template v-else>
<button
class="rounded-2xl border border-slate-300 bg-white px-4 py-2 text-sm font-bold text-slate-700 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
@click="emit('toggleCategoryExportMode', true)"
>
指定品类导出
</button>
<button
class="rounded-2xl bg-slate-900 px-8 py-3 text-sm font-bold text-white shadow-xl shadow-slate-200 transition-all hover:scale-105 active:scale-95 dark:shadow-none"
class="rounded-[10px] bg-slate-800 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(15,23,42,0.18)] transition-colors hover:bg-slate-900 dark:shadow-none"
@click="emit('export')"
>
导出全部
@@ -7,6 +7,7 @@ import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { formatWanShort, formatYuanDetail } from '../../../utils/money';
import { FINANCE_PANEL_SHELL } from '../finance-ui';
defineOptions({ name: 'WorkbenchFinancePlatformSalesPieChart' });
@@ -15,21 +16,18 @@ const props = defineProps<{
}>();
const PLATFORM_PIE_COLORS = [
'#2563eb',
'#d97706',
'#059669',
'#e11d48',
'#6366f1',
'#14b8a6',
'#8b5cf6',
'#3b82f6',
'#f59e0b',
'#10b981',
'#ef4444',
'#8b5cf6',
'#06b6d4',
'#6366f1',
'#f97316',
'#64748b',
'#ec4899',
];
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 pieChartRef = ref<EchartsUIType>();
const { renderEcharts: renderPieChart } = useEcharts(pieChartRef);
@@ -75,7 +73,7 @@ function drawPie() {
top: 'center',
itemWidth: 10,
itemHeight: 10,
textStyle: { color: legendColor, fontSize: 11, fontWeight: 700 },
textStyle: { color: legendColor, fontSize: 11, fontWeight: 500 },
},
series: [
{
@@ -162,23 +160,23 @@ defineExpose({ redraw });
</script>
<template>
<div :class="chartOverviewShell">
<div :class="FINANCE_PANEL_SHELL">
<div
class="border-b border-slate-100 px-6 pb-6 pt-6 md:px-8 md:pb-6 md:pt-8 dark:border-b-[hsl(240deg_3.7%_22%)]"
class="border-b border-slate-100 px-5 pb-3.5 pt-5 md:px-6 md:pt-5 dark:border-b-[hsl(240deg_3.7%_22%)]"
>
<h3
class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]"
class="text-base font-semibold 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%)]">
<p class="mt-1 text-xs font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
占当前筛选条件下实际销售额合计的比例
</p>
</div>
<div class="px-6 py-5 md:px-8 md:py-6">
<div class="px-5 py-4 md:px-6 md:py-5">
<div
v-show="!hasData"
class="flex h-[280px] items-center justify-center text-sm font-bold text-slate-400"
class="flex h-[280px] items-center justify-center text-sm text-slate-400"
>
暂无销售额数据
</div>
@@ -10,6 +10,10 @@ import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
import { formatYuanDetail, yuanToWanNum } from '../../../utils/money';
import { getFinanceKpiHint } from '../finance-kpi-hints';
import {
FINANCE_KPI_CARD_SHELL,
FINANCE_TONE_ICON,
} from '../finance-ui';
import {
cardById,
clampFinanceKpiColsPerRow,
@@ -67,7 +71,6 @@ const orderedCards = computed(() => {
card,
primaryLabel,
primaryKpi,
primaryMeta: kpiMetaByLabel(primaryLabel),
members,
};
})
@@ -180,47 +183,45 @@ function formatDelta(kpi: WorkbenchVO.KpiItem, pct: number | undefined | null):
function deltaTextClass(good: boolean): string {
return good
? 'text-emerald-600 dark:text-emerald-400'
: 'text-rose-600 dark:text-rose-400';
? 'font-semibold text-emerald-500 dark:text-emerald-400'
: 'font-semibold text-rose-500 dark:text-rose-400';
}
function onPickPrimary(cardId: FinanceKpiCardId, metricLabel: string) {
emit('set-primary', { cardId, metricLabel });
}
const cardShellClass =
'group flex min-h-[6.75rem] min-w-0 flex-col rounded-xl border border-slate-200/90 bg-gradient-to-b from-white to-slate-50/80 p-3.5 shadow-sm transition-[border-color,box-shadow] duration-200 hover:border-slate-300 hover:shadow-md dark:border-[hsl(240deg_3.7%_22%)] dark:from-[hsl(222.34deg_10.43%_12.27%)] dark:to-[hsl(222.34deg_10.43%_10%)] dark:shadow-none dark:hover:border-[hsl(240deg_3.7%_32%)]';
const labelClass =
'truncate text-xs font-semibold leading-none text-slate-600 dark:text-[hsl(240deg_5%_72%)]';
const valueUnitClass =
'text-sm font-semibold leading-none text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]';
const trendChipClass =
'inline-flex cursor-default items-baseline gap-px rounded-full border border-slate-200/80 bg-white/80 px-1.5 py-0.5 text-[11px] font-medium leading-none text-slate-500 dark:border-[hsl(240deg_3.7%_26%)] dark:bg-[hsl(240deg_3.7%_14%)] dark:text-[hsl(240deg_5%_64.9%)]';
function toneIconClass(tone: string): string {
return FINANCE_TONE_ICON[tone] ?? FINANCE_TONE_ICON.blue;
}
const emptyShellClass =
'rounded-[14px] border border-dashed border-slate-200 bg-white px-4 py-8 text-center text-sm text-slate-400 shadow-[0_1px_2px_rgba(15,23,42,0.04)] dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)] dark:text-[hsl(240deg_5%_64.9%)] dark:shadow-none';
</script>
<template>
<div
v-if="kpis.length === 0"
class="rounded-xl border border-dashed border-slate-200 bg-white/60 px-4 py-8 text-center text-sm text-slate-400 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)] dark:text-[hsl(240deg_5%_64.9%)]"
:class="emptyShellClass"
>
暂无 KPI 数据
</div>
<div
v-else-if="showEmptyPrefsHint"
class="rounded-xl border border-dashed border-amber-200 bg-amber-50/60 px-4 py-8 text-center text-sm text-amber-700 dark:border-amber-900/40 dark:bg-amber-950/20 dark:text-amber-300"
class="rounded-[14px] border border-dashed border-amber-200 bg-amber-50/60 px-4 py-8 text-center text-sm text-amber-700 dark:border-amber-900/40 dark:bg-amber-950/20 dark:text-amber-300"
>
未选择任何 KPI 卡片,请点击上方「KPI 显示设置」勾选要展示的卡片。
</div>
<div
v-else-if="orderedCards.length === 0"
class="rounded-xl border border-dashed border-slate-200 bg-white/60 px-4 py-8 text-center text-sm text-slate-400 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)] dark:text-[hsl(240deg_5%_64.9%)]"
:class="emptyShellClass"
>
当前筛选下暂无已选 KPI 数据
</div>
<div
v-else
ref="gridRef"
class="grid gap-3"
class="grid gap-3.5"
:style="gridStyle"
>
<Popover
@@ -240,10 +241,10 @@ const trendChipClass =
v-for="m in row.members"
:key="m.label"
type="button"
class="flex w-full items-center justify-between gap-3 rounded-lg px-2 py-1.5 text-left transition-colors hover:bg-slate-100 dark:hover:bg-[hsl(240deg_3.7%_18%)]"
class="flex w-full items-center justify-between gap-3 rounded-lg px-2 py-1.5 text-left transition-colors hover:bg-blue-50 dark:hover:bg-[hsl(240deg_3.7%_18%)]"
:class="
m.isPrimary
? 'bg-slate-100/80 dark:bg-[hsl(240deg_3.7%_16%)]'
? 'bg-blue-50/80 dark:bg-[hsl(240deg_3.7%_16%)]'
: ''
"
@click="onPickPrimary(row.card.id, m.label)"
@@ -278,107 +279,125 @@ const trendChipClass =
</div>
</template>
<div :class="cardShellClass">
<div class="mb-2 flex items-start justify-between gap-2">
<div class="flex min-w-0 flex-1 items-center gap-1.5">
<component
:is="row.primaryMeta.icon"
class="size-4 shrink-0 text-slate-400 dark:text-[hsl(240deg_5%_55%)]"
/>
<div :class="FINANCE_KPI_CARD_SHELL">
<div class="flex items-start justify-between gap-2">
<div class="min-w-0 flex-1">
<OverviewColumnHint
class="min-w-0"
:title="getFinanceKpiHint(row.primaryLabel, taxRate ?? 0.04)"
>
<span :class="labelClass">
<span
class="block truncate text-[13px] font-medium leading-snug text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
>
{{ row.card.title }}
<span class="font-normal text-slate-400">· {{ row.primaryLabel }}</span>
</span>
</OverviewColumnHint>
<p
class="mt-0.5 truncate text-[11px] font-semibold text-slate-800 dark:text-[hsl(0deg_0%_90%)]"
>
{{ row.primaryLabel }}
</p>
</div>
<div
v-if="row.primaryKpi"
class="flex shrink-0 items-center gap-1"
class="grid size-9 shrink-0 place-items-center rounded-[10px]"
:class="toneIconClass(row.card.tone)"
>
<Tooltip
:title="compareRangeHint(momCompareDateStart, momCompareDateEnd)"
>
<span :class="trendChipClass">
<span class="text-slate-400 dark:text-[hsl(240deg_5%_55%)]">环</span>
<span
:class="
deltaTextClass(
trendIsGood(row.primaryKpi, row.primaryKpi.up === true),
)
"
>
{{ formatDelta(row.primaryKpi, row.primaryKpi.changePct) }}
</span>
</span>
</Tooltip>
<Tooltip
v-if="
row.primaryKpi.yoyChangePct != null &&
row.primaryKpi.yoyUp != null
"
:title="compareRangeHint(yoyCompareDateStart, yoyCompareDateEnd)"
>
<span :class="trendChipClass">
<span class="text-slate-400 dark:text-[hsl(240deg_5%_55%)]">同</span>
<span
:class="
deltaTextClass(
trendIsGood(
row.primaryKpi,
row.primaryKpi.yoyUp === true,
),
)
"
>
{{ formatDelta(row.primaryKpi, row.primaryKpi.yoyChangePct) }}
</span>
</span>
</Tooltip>
<component :is="row.card.icon" class="size-4" />
</div>
</div>
<template v-if="row.primaryKpi">
<span class="inline-flex max-w-full items-baseline whitespace-nowrap">
<div class="mt-3 inline-flex max-w-full items-baseline gap-0.5 whitespace-nowrap">
<Tooltip
v-if="primaryLine(row.primaryKpi).hover"
:title="primaryLine(row.primaryKpi).hover"
>
<span
class="cursor-default tabular-nums text-2xl font-bold leading-none tracking-tight text-slate-900 dark:text-[hsl(0deg_0%_95%)]"
class="cursor-default tabular-nums text-[26px] font-bold leading-none tracking-tight text-slate-800 dark:text-[hsl(0deg_0%_95%)]"
>
{{ primaryLine(row.primaryKpi).display }}
</span>
</Tooltip>
<span
v-else
class="tabular-nums text-2xl font-bold leading-none tracking-tight text-slate-900 dark:text-[hsl(0deg_0%_95%)]"
class="tabular-nums text-[26px] font-bold leading-none tracking-tight text-slate-800 dark:text-[hsl(0deg_0%_95%)]"
>
{{ primaryLine(row.primaryKpi).display }}
</span>
<span
v-if="primaryLine(row.primaryKpi).unitText"
:class="valueUnitClass"
class="text-sm font-semibold leading-none text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"
>
{{ primaryLine(row.primaryKpi).unitText }}
</span>
</span>
</div>
<div
class="mt-2.5 flex min-h-[1.25rem] items-center justify-between gap-2 text-xs text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
>
<div class="flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1">
<Tooltip
:title="compareRangeHint(momCompareDateStart, momCompareDateEnd)"
>
<span class="inline-flex cursor-default items-baseline gap-1">
<span>环比</span>
<span
:class="
deltaTextClass(
trendIsGood(row.primaryKpi, row.primaryKpi.up === true),
)
"
>
{{
row.primaryKpi.up === true
? '↑'
: row.primaryKpi.up === false
? '↓'
: ''
}}
{{ formatDelta(row.primaryKpi, row.primaryKpi.changePct) }}
</span>
</span>
</Tooltip>
<Tooltip
v-if="
row.primaryKpi.yoyChangePct != null &&
row.primaryKpi.yoyUp != null
"
:title="compareRangeHint(yoyCompareDateStart, yoyCompareDateEnd)"
>
<span class="inline-flex cursor-default items-baseline gap-1">
<span>同比</span>
<span
:class="
deltaTextClass(
trendIsGood(
row.primaryKpi,
row.primaryKpi.yoyUp === true,
),
)
"
>
{{ row.primaryKpi.yoyUp === true ? '↑' : '↓' }}
{{ formatDelta(row.primaryKpi, row.primaryKpi.yoyChangePct) }}
</span>
</span>
</Tooltip>
</div>
<span
v-if="row.members.length > 1"
class="shrink-0 text-[11px] font-medium text-blue-500"
>
{{ row.members.length }} 项
</span>
</div>
<p
v-if="row.primaryKpi.sub"
class="mt-1.5 w-full truncate text-right text-[11px] leading-snug text-slate-400 dark:text-[hsl(240deg_5%_55%)]"
class="mt-1.5 w-full truncate text-[11px] leading-snug text-slate-400 dark:text-[hsl(240deg_5%_55%)]"
>
{{ row.primaryKpi.sub }}
</p>
<p
v-else-if="row.members.length > 1"
class="mt-1.5 w-full truncate text-right text-[11px] leading-snug text-slate-400 dark:text-[hsl(240deg_5%_55%)]"
>
悬停查看同组 {{ row.members.length }} 项指标
</p>
</template>
</div>
</Popover>
@@ -7,6 +7,7 @@ import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { formatWanWithYuanDetail, yuanToWanNum } from '../../../utils/money';
import { FINANCE_PANEL_SHELL } from '../finance-ui';
defineOptions({ name: 'WorkbenchFinanceTrendChart' });
@@ -14,9 +15,6 @@ const props = defineProps<{
trend: WorkbenchVO.TrendPoint[];
}>();
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 financeChartRef = ref<EchartsUIType>();
const { renderEcharts: renderFinanceTrend } = useEcharts(financeChartRef);
@@ -336,32 +334,32 @@ defineExpose({ redraw });
</script>
<template>
<div :class="chartOverviewShell">
<div :class="FINANCE_PANEL_SHELL">
<div
class="border-b border-slate-100 px-6 pb-4 pt-6 md:px-8 md:pt-8 dark:border-b-[hsl(240deg_3.7%_22%)]"
class="border-b border-slate-100 px-5 pb-3.5 pt-5 md:px-6 md:pt-5 dark:border-b-[hsl(240deg_3.7%_22%)]"
>
<div class="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
<div>
<h3
class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]"
class="text-base font-semibold 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%)]">
柱状为实际销售额,折线为毛利/净利;右轴为日净利率,便于看「赚了多少」与「赚得好不好」
<p class="mt-1 text-xs font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
柱状为实际销售额,折线为毛利/净利;右轴为日净利率
</p>
</div>
<div
v-if="hasData"
class="flex flex-wrap gap-2 text-xs font-bold"
class="flex flex-wrap gap-2 text-xs font-medium"
>
<span
class="rounded-lg bg-blue-50 px-2.5 py-1 text-blue-700 dark:bg-blue-950/50 dark:text-blue-300"
class="rounded-lg bg-blue-50 px-2.5 py-1 text-blue-600 dark:bg-blue-950/50 dark:text-blue-300"
>
区间销售 {{ formatWanWithYuanDetail(periodSummary.sales) }}
</span>
<span
class="rounded-lg bg-violet-50 px-2.5 py-1 text-violet-700 dark:bg-violet-950/50 dark:text-violet-300"
class="rounded-lg bg-violet-50 px-2.5 py-1 text-violet-600 dark:bg-violet-950/50 dark:text-violet-300"
>
区间净利 {{ formatWanWithYuanDetail(periodSummary.net) }}
<template v-if="periodSummary.netMarginPct != null">
@@ -371,10 +369,10 @@ defineExpose({ redraw });
</div>
</div>
</div>
<div class="px-6 py-5 md:px-8 md:py-6">
<div class="px-5 py-4 md:px-6 md:py-5">
<div
v-show="!hasData"
class="flex h-[320px] items-center justify-center text-sm font-bold text-slate-400"
class="flex h-[320px] items-center justify-center text-sm text-slate-400"
>
所选时段暂无趋势数据
</div>
@@ -243,29 +243,29 @@ async function handleProductExport() {
<style scoped>
:deep(.ant-segmented-thumb) {
border-radius: 999px !important;
border-radius: 10px !important;
}
:deep(.workbench-overview-segmented) {
background: rgb(148 163 184 / 16%);
border-radius: 999px;
background: rgb(241 245 249);
border-radius: 12px;
padding: 4px;
}
:deep(.workbench-overview-segmented .ant-segmented-item) {
border-radius: 999px;
border-radius: 10px;
}
:deep(.workbench-overview-segmented .ant-segmented-item-label) {
font-weight: 700;
padding: 6px 16px;
border-radius: 999px;
font-weight: 500;
padding: 6px 14px;
border-radius: 10px;
}
:deep(.workbench-overview-segmented .ant-segmented-item-selected) {
background: white;
color: #1d4ed8;
box-shadow: 0 1px 3px rgb(0 0 0 / 10%);
color: #3b82f6;
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
:global(html.dark) :deep(.workbench-overview-segmented) {
@@ -273,7 +273,7 @@ async function handleProductExport() {
}
:global(html.dark) :deep(.workbench-overview-segmented .ant-segmented-item) {
border-radius: 999px;
border-radius: 10px;
color: hsl(240deg 5% 64.9%);
}
@@ -11,6 +11,8 @@ import {
storeOverviewHints,
} from '#/utils/overview-table-hints';
import { FINANCE_PANEL_SHELL } from '../finance-ui';
defineOptions({ name: 'WorkbenchPlatformSummaryCard' });
interface Props {
@@ -109,31 +111,29 @@ const sortedData = computed(() => {
</script>
<template>
<div
class="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]"
>
<div :class="FINANCE_PANEL_SHELL">
<!-- Header -->
<div
class="flex flex-col items-start justify-between gap-4 border-b border-slate-100 dark:border-b-[hsl(240deg_3.7%_22%)] p-8 md:flex-row md:items-center"
class="flex flex-col items-start justify-between gap-4 border-b border-slate-100 p-5 md:flex-row md:items-center md:px-6 dark:border-b-[hsl(240deg_3.7%_22%)]"
>
<div>
<h3 class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
<h3 class="text-base font-semibold 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%)]">
<p class="mt-1 text-xs font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ props.headingSubtitle }}
</p>
</div>
<div class="flex items-center gap-3">
<template v-if="platformExportMode">
<button
class="rounded-2xl border border-slate-300 bg-white px-4 py-2 text-sm font-bold text-slate-700 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
@click="emit('togglePlatformExportMode', false)"
>
取消选择
</button>
<button
class="rounded-2xl bg-blue-600 px-8 py-3 text-sm font-bold text-white shadow-xl shadow-slate-200 transition-all hover:scale-105 active:scale-95 dark:shadow-none"
class="rounded-[10px] bg-blue-500 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(59,130,246,0.28)] transition-colors hover:bg-blue-600 disabled:opacity-50 dark:shadow-none"
:disabled="selectedExportPlatformCodes.length === 0"
@click="emit('export')"
>
@@ -142,13 +142,13 @@ const sortedData = computed(() => {
</template>
<template v-else>
<button
class="rounded-2xl border border-slate-300 bg-white px-4 py-2 text-sm font-bold text-slate-700 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
@click="emit('togglePlatformExportMode', true)"
>
指定平台导出
</button>
<button
class="rounded-2xl bg-slate-900 px-8 py-3 text-sm font-bold text-white shadow-xl shadow-slate-200 transition-all hover:scale-105 active:scale-95 dark:shadow-none"
class="rounded-[10px] bg-slate-800 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(15,23,42,0.18)] transition-colors hover:bg-slate-900 dark:shadow-none"
@click="emit('export')"
>
导出全部
@@ -13,6 +13,8 @@ import {
storeOverviewHints,
} from '#/utils/overview-table-hints';
import { FINANCE_PANEL_SHELL } from '../finance-ui';
const JumpIcon = createIconifyIcon('tdesign:jump');
defineOptions({ name: 'WorkbenchShopSummaryTable' });
@@ -64,30 +66,28 @@ const cellRoi = (v: number | null | undefined) =>
</script>
<template>
<div
class="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]"
>
<div :class="FINANCE_PANEL_SHELL">
<div
class="flex flex-col items-start justify-between gap-4 border-b border-slate-100 dark:border-b-[hsl(240deg_3.7%_22%)] p-8 md:flex-row md:items-center"
class="flex flex-col items-start justify-between gap-4 border-b border-slate-100 p-5 md:flex-row md:items-center md:px-6 dark:border-b-[hsl(240deg_3.7%_22%)]"
>
<div>
<h3 class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
<h3 class="text-base font-semibold 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%)]">
<p class="mt-1 text-xs font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ props.headingSubtitle }}
</p>
</div>
<div class="flex items-center gap-3">
<template v-if="shopExportMode">
<button
class="rounded-2xl border border-slate-300 bg-white px-4 py-2 text-sm font-bold text-slate-700 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
@click="emit('toggleShopExportMode', false)"
>
取消选择
</button>
<button
class="rounded-2xl bg-blue-600 px-8 py-3 text-sm font-bold text-white shadow-xl shadow-slate-200 transition-all hover:scale-105 active:scale-95 dark:shadow-none"
class="rounded-[10px] bg-blue-500 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(59,130,246,0.28)] transition-colors hover:bg-blue-600 disabled:opacity-50 dark:shadow-none"
:disabled="selectedExportShopIds.length === 0"
@click="emit('export')"
>
@@ -96,13 +96,13 @@ const cellRoi = (v: number | null | undefined) =>
</template>
<template v-else>
<button
class="rounded-2xl border border-slate-300 bg-white px-4 py-2 text-sm font-bold text-slate-700 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
class="rounded-[10px] border border-slate-200 bg-white px-3.5 py-2 text-sm font-medium text-slate-600 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%)] dark:text-[hsl(240deg_5%_64.9%)]"
@click="emit('toggleShopExportMode', true)"
>
指定店铺导出
</button>
<button
class="rounded-2xl bg-slate-900 px-8 py-3 text-sm font-bold text-white shadow-xl shadow-slate-200 transition-all hover:scale-105 active:scale-95 dark:shadow-none"
class="rounded-[10px] bg-slate-800 px-5 py-2 text-sm font-semibold text-white shadow-[0_8px_18px_rgba(15,23,42,0.18)] transition-colors hover:bg-slate-900 dark:shadow-none"
@click="emit('export')"
>
导出全部
@@ -0,0 +1,19 @@
/** 经营概览 Tab:对齐 temp/1.html 演示页的卡片与配色 */
export const FINANCE_PANEL_SHELL =
'overflow-hidden rounded-[14px] border border-slate-200/90 bg-white shadow-[0_1px_2px_rgba(15,23,42,0.04),0_8px_24px_rgba(15,23,42,0.04)] dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)] dark:shadow-none';
export const FINANCE_KPI_CARD_SHELL =
'group relative flex min-h-[7.25rem] min-w-0 cursor-default flex-col rounded-[14px] border border-slate-200/90 bg-white p-4 shadow-[0_1px_2px_rgba(15,23,42,0.04),0_8px_24px_rgba(15,23,42,0.04)] transition-[border-color,box-shadow] duration-150 hover:border-indigo-200 hover:shadow-[0_10px_28px_rgba(59,130,246,0.1)] dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)] dark:shadow-none dark:hover:border-blue-500/40';
export const FINANCE_TONE_ICON: Record<
string,
string
> = {
blue: 'bg-blue-50 text-blue-500 dark:bg-blue-950/40 dark:text-blue-300',
green: 'bg-emerald-50 text-emerald-500 dark:bg-emerald-950/40 dark:text-emerald-300',
purple: 'bg-violet-50 text-violet-500 dark:bg-violet-950/40 dark:text-violet-300',
orange: 'bg-amber-50 text-amber-500 dark:bg-amber-950/40 dark:text-amber-300',
cyan: 'bg-cyan-50 text-cyan-500 dark:bg-cyan-950/40 dark:text-cyan-300',
rose: 'bg-rose-50 text-rose-500 dark:bg-rose-950/40 dark:text-rose-300',
};
@@ -108,15 +108,20 @@ defineExpose({ redraw });
<template>
<div class="mt-4 space-y-4">
<div class="flex flex-wrap items-center justify-between gap-3">
<span class="text-sm text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
经营 KPI
<span v-if="visibleKpiCount > 0" class="ml-1 text-slate-400">
(已选 {{ visibleKpiCount }} 张卡片 · 最多 {{ colsPerRow }} 列)
</span>
</span>
<div>
<h2 class="text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
经营概览
</h2>
<p class="mt-0.5 text-xs text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
经营 KPI
<span v-if="visibleKpiCount > 0">
· 已选 {{ visibleKpiCount }} 张 · 最多 {{ colsPerRow }} 列
</span>
</p>
</div>
<Button
type="default"
class="shrink-0 whitespace-nowrap"
class="shrink-0 whitespace-nowrap !rounded-[10px] !border-slate-200 !bg-white !text-slate-600 shadow-[0_1px_2px_rgba(15,23,42,0.04)] hover:!border-blue-200 hover:!text-blue-600 dark:!border-[hsl(240deg_3.7%_22%)] dark:!bg-[hsl(222.34deg_10.43%_12.27%)] dark:!text-[hsl(240deg_5%_72%)] dark:hover:!border-blue-500/40 dark:hover:!text-blue-300"
@click="kpiSettingsOpen = true"
>
<template #icon>
@@ -144,7 +149,7 @@ defineExpose({ redraw });
:yoy-compare-date-end="finance.yoyCompareDateEnd"
@set-primary="onSetPrimary"
/>
<div class="grid grid-cols-1 gap-6 xl:grid-cols-3">
<div class="grid grid-cols-1 gap-3.5 xl:grid-cols-3">
<FinanceTrendChart
ref="trendChartRef"
:trend="finance.gmvTrend"
@@ -85,6 +85,8 @@ export const FINANCE_KPI_METRIC_META: Record<string, FinanceKpiMetricMeta> = {
广告ROI: { label: '广告ROI', upIsGood: true, icon: IconRoi },
};
export type FinanceKpiCardTone = 'blue' | 'green' | 'purple' | 'orange' | 'cyan' | 'rose';
export type FinanceKpiCardDef = {
id: FinanceKpiCardId;
title: string;
@@ -92,6 +94,8 @@ export type FinanceKpiCardDef = {
metrics: string[];
defaultPrimary: string;
icon: Component;
/** 图标底色,对齐演示页风格 */
tone: FinanceKpiCardTone;
};
/** 复合卡目录(展示顺序) */
@@ -102,6 +106,7 @@ export const FINANCE_KPI_CARDS: FinanceKpiCardDef[] = [
metrics: ['实际销售额', '总GMV', '净销售额', 'GMV与销售差额'],
defaultPrimary: '实际销售额',
icon: IconSales,
tone: 'blue',
},
{
id: 'orders',
@@ -109,6 +114,7 @@ export const FINANCE_KPI_CARDS: FinanceKpiCardDef[] = [
metrics: ['销售单量', 'GMV单量'],
defaultPrimary: '销售单量',
icon: IconOrders,
tone: 'blue',
},
{
id: 'qty',
@@ -116,6 +122,7 @@ export const FINANCE_KPI_CARDS: FinanceKpiCardDef[] = [
metrics: ['实际销量', 'GMV销量'],
defaultPrimary: '实际销量',
icon: IconPackage,
tone: 'cyan',
},
{
id: 'aov',
@@ -123,6 +130,7 @@ export const FINANCE_KPI_CARDS: FinanceKpiCardDef[] = [
metrics: ['客单价', 'GMV客单价', '销售件单价', 'GMV件单价'],
defaultPrimary: '客单价',
icon: IconAov,
tone: 'purple',
},
{
id: 'refund',
@@ -130,6 +138,7 @@ export const FINANCE_KPI_CARDS: FinanceKpiCardDef[] = [
metrics: ['退款率', '退款额'],
defaultPrimary: '退款率',
icon: IconRefund,
tone: 'orange',
},
{
id: 'cost',
@@ -137,6 +146,7 @@ export const FINANCE_KPI_CARDS: FinanceKpiCardDef[] = [
metrics: ['订单成本', '商品成本', '运费成本', '其他成本'],
defaultPrimary: '订单成本',
icon: IconCost,
tone: 'orange',
},
{
id: 'profit',
@@ -144,6 +154,7 @@ export const FINANCE_KPI_CARDS: FinanceKpiCardDef[] = [
metrics: ['净利润', '毛利润'],
defaultPrimary: '净利润',
icon: IconGross,
tone: 'green',
},
{
id: 'ads',
@@ -151,6 +162,7 @@ export const FINANCE_KPI_CARDS: FinanceKpiCardDef[] = [
metrics: ['广告ROI', '推广费', '刷单费', '税额'],
defaultPrimary: '广告ROI',
icon: IconRoi,
tone: 'rose',
},
];