mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
feat: 优化工作台页面UI
This commit is contained in:
+10
-10
@@ -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')"
|
||||
>
|
||||
导出全部
|
||||
|
||||
+15
-17
@@ -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>
|
||||
|
||||
+98
-79
@@ -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>
|
||||
|
||||
+11
-13
@@ -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>
|
||||
|
||||
+10
-10
@@ -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%);
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -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')"
|
||||
>
|
||||
导出全部
|
||||
|
||||
+10
-10
@@ -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')"
|
||||
>
|
||||
导出全部
|
||||
|
||||
+19
@@ -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',
|
||||
};
|
||||
+13
-8
@@ -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"
|
||||
|
||||
+12
@@ -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',
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,929 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>AI SaaS · 工作台</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.min.js"></script>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #f3f5f9;
|
||||
--surface: #ffffff;
|
||||
--text: #1f2937;
|
||||
--muted: #6b7280;
|
||||
--border: #e5e7eb;
|
||||
--primary: #3b82f6;
|
||||
--primary-soft: #eff6ff;
|
||||
--green: #10b981;
|
||||
--orange: #f59e0b;
|
||||
--purple: #8b5cf6;
|
||||
--red: #ef4444;
|
||||
--sidebar-w: 220px;
|
||||
--radius: 14px;
|
||||
--shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
|
||||
--font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
html, body { height: 100%; }
|
||||
body {
|
||||
font-family: var(--font);
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
display: flex;
|
||||
min-height: 100%;
|
||||
}
|
||||
button, input { font: inherit; }
|
||||
a { color: inherit; text-decoration: none; }
|
||||
ul { list-style: none; }
|
||||
|
||||
.app { display: flex; width: 100%; min-height: 100%; }
|
||||
|
||||
/* Sidebar */
|
||||
.sidebar {
|
||||
width: var(--sidebar-w);
|
||||
background: var(--surface);
|
||||
border-right: 1px solid var(--border);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
height: 100vh;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 20px 18px 16px;
|
||||
font-weight: 700;
|
||||
font-size: 18px;
|
||||
}
|
||||
.brand-mark {
|
||||
width: 32px; height: 32px; border-radius: 9px;
|
||||
background: linear-gradient(145deg, #60a5fa, #2563eb);
|
||||
display: grid; place-items: center; color: #fff;
|
||||
box-shadow: 0 6px 14px rgba(37, 99, 235, 0.28);
|
||||
}
|
||||
.nav { padding: 8px 12px; flex: 1; overflow: auto; }
|
||||
.nav-item {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
padding: 11px 12px; border-radius: 10px;
|
||||
color: #4b5563; font-size: 14px; margin-bottom: 2px;
|
||||
cursor: pointer; transition: 0.15s ease;
|
||||
}
|
||||
.nav-item:hover { background: #f8fafc; color: var(--text); }
|
||||
.nav-item.active {
|
||||
background: var(--primary-soft);
|
||||
color: var(--primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }
|
||||
.user-box {
|
||||
margin: 12px; padding: 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
}
|
||||
.avatar {
|
||||
width: 36px; height: 36px; border-radius: 50%;
|
||||
background: linear-gradient(135deg, #93c5fd, #3b82f6);
|
||||
color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px;
|
||||
}
|
||||
.user-meta { flex: 1; min-width: 0; }
|
||||
.user-meta strong { display: block; font-size: 13px; }
|
||||
.user-meta span { font-size: 11px; color: var(--muted); }
|
||||
|
||||
/* Main */
|
||||
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
||||
.topbar {
|
||||
display: flex; align-items: center; gap: 16px;
|
||||
padding: 18px 24px 8px; flex-wrap: wrap;
|
||||
}
|
||||
.hello h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
|
||||
.hello p { color: var(--muted); font-size: 13px; margin-top: 4px; }
|
||||
.search {
|
||||
flex: 1; min-width: 220px; max-width: 520px; margin: 0 auto;
|
||||
display: flex; align-items: center; gap: 8px;
|
||||
background: var(--surface); border: 1px solid var(--border);
|
||||
border-radius: 999px; padding: 10px 16px; box-shadow: var(--shadow);
|
||||
}
|
||||
.search input {
|
||||
border: 0; outline: 0; width: 100%; background: transparent; color: var(--text);
|
||||
}
|
||||
.search input::placeholder { color: #9ca3af; }
|
||||
.top-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
|
||||
.icon-btn {
|
||||
width: 38px; height: 38px; border-radius: 50%;
|
||||
border: 1px solid var(--border); background: var(--surface);
|
||||
display: grid; place-items: center; cursor: pointer; position: relative;
|
||||
color: #64748b;
|
||||
}
|
||||
.icon-btn .badge {
|
||||
position: absolute; top: -2px; right: -2px;
|
||||
min-width: 16px; height: 16px; padding: 0 4px;
|
||||
border-radius: 999px; background: var(--red); color: #fff;
|
||||
font-size: 10px; font-weight: 700; display: grid; place-items: center;
|
||||
}
|
||||
.add-btn {
|
||||
width: 38px; height: 38px; border-radius: 50%; border: 0;
|
||||
background: var(--primary); color: #fff; font-size: 22px; line-height: 1;
|
||||
cursor: pointer; box-shadow: 0 8px 18px rgba(59, 130, 246, 0.35);
|
||||
}
|
||||
|
||||
.content { padding: 12px 24px 28px; display: flex; flex-direction: column; gap: 16px; }
|
||||
|
||||
.card {
|
||||
background: var(--surface);
|
||||
border: 1px solid rgba(229, 231, 235, 0.9);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
/* KPI — 复合卡 */
|
||||
.kpi-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
gap: 14px;
|
||||
}
|
||||
.kpi-card {
|
||||
padding: 16px 16px 14px;
|
||||
position: relative;
|
||||
cursor: default;
|
||||
transition: border-color 0.15s, box-shadow 0.15s;
|
||||
}
|
||||
.kpi-card:hover {
|
||||
border-color: #c7d2fe;
|
||||
box-shadow: 0 10px 28px rgba(59, 130, 246, 0.1);
|
||||
}
|
||||
.kpi-head {
|
||||
display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
|
||||
}
|
||||
.kpi-title {
|
||||
font-size: 13px; color: var(--muted); font-weight: 500;
|
||||
display: flex; flex-direction: column; gap: 2px;
|
||||
}
|
||||
.kpi-title .primary-name {
|
||||
color: var(--text); font-weight: 600; font-size: 13px;
|
||||
}
|
||||
.kpi-title .hint {
|
||||
font-size: 11px; color: #94a3b8;
|
||||
}
|
||||
.kpi-icon {
|
||||
width: 36px; height: 36px; border-radius: 10px;
|
||||
display: grid; place-items: center; flex-shrink: 0;
|
||||
}
|
||||
.kpi-icon.blue { background: #eff6ff; color: var(--primary); }
|
||||
.kpi-icon.green { background: #ecfdf5; color: var(--green); }
|
||||
.kpi-icon.purple { background: #f5f3ff; color: var(--purple); }
|
||||
.kpi-icon.orange { background: #fffbeb; color: var(--orange); }
|
||||
.kpi-icon.cyan { background: #ecfeff; color: #06b6d4; }
|
||||
.kpi-value {
|
||||
margin-top: 12px; font-size: 26px; font-weight: 700;
|
||||
letter-spacing: -0.03em; line-height: 1.1;
|
||||
}
|
||||
.kpi-foot {
|
||||
margin-top: 10px; font-size: 12px; color: var(--muted);
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 8px;
|
||||
}
|
||||
.kpi-trend { color: var(--green); font-weight: 600; }
|
||||
.kpi-trend.down { color: var(--red); }
|
||||
.kpi-link { color: var(--primary); font-weight: 500; }
|
||||
.spark { width: 72px; height: 28px; }
|
||||
|
||||
.kpi-popover {
|
||||
display: none;
|
||||
position: absolute; left: 12px; right: 12px; top: calc(100% - 6px);
|
||||
z-index: 20; background: #fff; border: 1px solid var(--border);
|
||||
border-radius: 12px; box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
|
||||
padding: 8px; min-width: 200px;
|
||||
}
|
||||
.kpi-card:hover .kpi-popover,
|
||||
.kpi-card:focus-within .kpi-popover { display: block; }
|
||||
.kpi-popover .tip {
|
||||
font-size: 11px; color: #94a3b8; padding: 4px 8px 8px;
|
||||
}
|
||||
.kpi-option {
|
||||
width: 100%; border: 0; background: transparent; text-align: left;
|
||||
padding: 8px 10px; border-radius: 8px; cursor: pointer;
|
||||
display: flex; justify-content: space-between; gap: 10px; align-items: center;
|
||||
}
|
||||
.kpi-option:hover { background: #f8fafc; }
|
||||
.kpi-option.active { background: var(--primary-soft); }
|
||||
.kpi-option .lab { font-size: 12px; font-weight: 600; color: var(--text); }
|
||||
.kpi-option .val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||
.kpi-option .lab small {
|
||||
margin-left: 6px; color: var(--primary); font-weight: 500; font-size: 10px;
|
||||
}
|
||||
|
||||
/* Mid row */
|
||||
.mid-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1.7fr 1fr;
|
||||
gap: 14px;
|
||||
}
|
||||
.panel { padding: 16px 18px 18px; }
|
||||
.panel-hd {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
|
||||
}
|
||||
.panel-hd h2 { font-size: 16px; font-weight: 700; }
|
||||
.tabs { display: flex; gap: 4px; background: #f1f5f9; padding: 3px; border-radius: 10px; }
|
||||
.tab {
|
||||
border: 0; background: transparent; padding: 6px 12px; border-radius: 8px;
|
||||
font-size: 12px; color: var(--muted); cursor: pointer; font-weight: 500;
|
||||
}
|
||||
.tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
|
||||
.select {
|
||||
border: 1px solid var(--border); background: #fff; border-radius: 8px;
|
||||
padding: 6px 10px; font-size: 12px; color: var(--muted);
|
||||
}
|
||||
.chart-wrap { height: 260px; position: relative; }
|
||||
.todo-list { display: flex; flex-direction: column; gap: 10px; }
|
||||
.todo-item {
|
||||
display: flex; gap: 12px; align-items: flex-start;
|
||||
padding: 12px; border-radius: 12px; background: #f8fafc;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.todo-item:hover { border-color: var(--border); background: #fff; }
|
||||
.dot {
|
||||
width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0;
|
||||
}
|
||||
.dot.blue { background: var(--primary); }
|
||||
.dot.green { background: var(--green); }
|
||||
.dot.orange { background: var(--orange); }
|
||||
.dot.red { background: var(--red); }
|
||||
.todo-body { flex: 1; min-width: 0; }
|
||||
.todo-body strong { display: block; font-size: 13px; margin-bottom: 2px; }
|
||||
.todo-body span { font-size: 12px; color: var(--muted); }
|
||||
.todo-time { font-size: 11px; color: #94a3b8; white-space: nowrap; }
|
||||
|
||||
/* Bottom row */
|
||||
.bottom-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1.25fr;
|
||||
gap: 14px;
|
||||
}
|
||||
.donut-wrap {
|
||||
height: 220px; position: relative;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.donut-center {
|
||||
position: absolute; text-align: center; pointer-events: none;
|
||||
}
|
||||
.donut-center .n { font-size: 22px; font-weight: 700; }
|
||||
.donut-center .l { font-size: 12px; color: var(--muted); }
|
||||
.legend {
|
||||
display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
|
||||
margin-top: 8px; font-size: 12px; color: var(--muted);
|
||||
}
|
||||
.legend i {
|
||||
display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px;
|
||||
}
|
||||
.rank-list { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
|
||||
.rank-row { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; align-items: center; }
|
||||
.rank-idx {
|
||||
width: 18px; height: 18px; border-radius: 6px; background: #f1f5f9;
|
||||
font-size: 11px; font-weight: 700; display: grid; place-items: center; color: #64748b;
|
||||
}
|
||||
.rank-idx.top { background: var(--primary-soft); color: var(--primary); }
|
||||
.rank-name { font-size: 13px; font-weight: 500; margin-bottom: 6px; }
|
||||
.bar {
|
||||
height: 7px; border-radius: 999px; background: #eef2f7; overflow: hidden;
|
||||
}
|
||||
.bar > span {
|
||||
display: block; height: 100%; border-radius: inherit;
|
||||
background: linear-gradient(90deg, #60a5fa, #2563eb);
|
||||
}
|
||||
.rank-val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||
|
||||
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
th {
|
||||
text-align: left; color: var(--muted); font-weight: 500; font-size: 12px;
|
||||
padding: 8px 6px; border-bottom: 1px solid var(--border);
|
||||
}
|
||||
td { padding: 11px 6px; border-bottom: 1px solid #f1f5f9; }
|
||||
tr:last-child td { border-bottom: 0; }
|
||||
.tag {
|
||||
display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
|
||||
font-size: 11px; font-weight: 600;
|
||||
}
|
||||
.tag.paid { background: #ecfdf5; color: #059669; }
|
||||
.tag.pending { background: #fffbeb; color: #d97706; }
|
||||
.tag.cancel { background: #fef2f2; color: #dc2626; }
|
||||
|
||||
.notice-strip {
|
||||
display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
|
||||
}
|
||||
.notice {
|
||||
display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px;
|
||||
}
|
||||
.notice-ico {
|
||||
width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
|
||||
background: var(--primary-soft); color: var(--primary); flex-shrink: 0;
|
||||
}
|
||||
.notice strong { display: block; font-size: 13px; margin-bottom: 2px; }
|
||||
.notice span { font-size: 12px; color: var(--muted); }
|
||||
|
||||
.settings-fab {
|
||||
position: fixed; right: 20px; bottom: 20px; z-index: 40;
|
||||
border: 0; border-radius: 999px; padding: 10px 14px;
|
||||
background: #111827; color: #fff; font-size: 12px; cursor: pointer;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
||||
}
|
||||
.modal-mask {
|
||||
display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.35);
|
||||
z-index: 50; align-items: center; justify-content: center; padding: 20px;
|
||||
}
|
||||
.modal-mask.open { display: flex; }
|
||||
.modal {
|
||||
width: min(520px, 100%); background: #fff; border-radius: 16px;
|
||||
padding: 18px 20px 16px; box-shadow: 0 24px 60px rgba(0,0,0,0.2);
|
||||
max-height: 85vh; overflow: auto;
|
||||
}
|
||||
.modal h3 { font-size: 16px; margin-bottom: 6px; }
|
||||
.modal p.desc { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
|
||||
.modal-card {
|
||||
border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px;
|
||||
}
|
||||
.modal-card label.head {
|
||||
display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px;
|
||||
margin-bottom: 8px; cursor: pointer;
|
||||
}
|
||||
.modal-card .radios {
|
||||
display: flex; flex-wrap: wrap; gap: 8px 14px; padding-left: 22px;
|
||||
}
|
||||
.modal-card .radios label {
|
||||
font-size: 12px; color: #475569; display: flex; align-items: center; gap: 4px; cursor: pointer;
|
||||
}
|
||||
.modal-actions {
|
||||
display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px;
|
||||
}
|
||||
.btn {
|
||||
border: 1px solid var(--border); background: #fff; border-radius: 10px;
|
||||
padding: 8px 14px; font-size: 13px; cursor: pointer;
|
||||
}
|
||||
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
|
||||
|
||||
@media (max-width: 1280px) {
|
||||
.kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
||||
.bottom-row, .notice-strip { grid-template-columns: 1fr 1fr; }
|
||||
}
|
||||
@media (max-width: 960px) {
|
||||
.sidebar { display: none; }
|
||||
.mid-row, .bottom-row, .kpi-row, .notice-strip { grid-template-columns: 1fr; }
|
||||
.search { order: 3; max-width: none; width: 100%; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
<aside class="sidebar">
|
||||
<div class="brand">
|
||||
<div class="brand-mark" aria-hidden="true">
|
||||
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2.2">
|
||||
<path d="M4 19V9M10 19V5M16 19v-7M22 19H2"/>
|
||||
</svg>
|
||||
</div>
|
||||
AI SaaS
|
||||
</div>
|
||||
<nav class="nav" id="nav">
|
||||
<!-- filled by JS -->
|
||||
</nav>
|
||||
<div class="user-box">
|
||||
<div class="avatar">A</div>
|
||||
<div class="user-meta">
|
||||
<strong>Admin</strong>
|
||||
<span>超级管理员</span>
|
||||
</div>
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="2"><path d="m6 9 6 6 6-6"/></svg>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div class="main">
|
||||
<header class="topbar">
|
||||
<div class="hello">
|
||||
<h1>欢迎回来, Admin 👋</h1>
|
||||
<p id="todayLabel">星期二, 2024年5月7日</p>
|
||||
</div>
|
||||
<div class="search">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="2"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg>
|
||||
<input placeholder="搜索功能、数据或用户..." />
|
||||
</div>
|
||||
<div class="top-actions">
|
||||
<button class="icon-btn" type="button" aria-label="通知">
|
||||
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg>
|
||||
<span class="badge">12</span>
|
||||
</button>
|
||||
<button class="icon-btn" type="button" aria-label="帮助">?</button>
|
||||
<button class="add-btn" type="button" aria-label="新建">+</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="content">
|
||||
<section class="kpi-row" id="kpiRow"></section>
|
||||
|
||||
<section class="mid-row">
|
||||
<div class="card panel">
|
||||
<div class="panel-hd">
|
||||
<h2>业务趋势</h2>
|
||||
<div style="display:flex;gap:10px;align-items:center;flex-wrap:wrap">
|
||||
<div class="tabs" id="trendTabs">
|
||||
<button class="tab active" data-tab="revenue" type="button">收入趋势</button>
|
||||
<button class="tab" data-tab="orders" type="button">订单趋势</button>
|
||||
<button class="tab" data-tab="users" type="button">用户趋势</button>
|
||||
</div>
|
||||
<select class="select" aria-label="时间范围">
|
||||
<option>近 7 天</option>
|
||||
<option>近 30 天</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chart-wrap"><canvas id="trendChart"></canvas></div>
|
||||
</div>
|
||||
|
||||
<div class="card panel">
|
||||
<div class="panel-hd"><h2>待办事项</h2><a class="kpi-link" href="#">查看全部</a></div>
|
||||
<ul class="todo-list" id="todoList"></ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="bottom-row">
|
||||
<div class="card panel">
|
||||
<div class="panel-hd"><h2>数据分布</h2></div>
|
||||
<div class="donut-wrap">
|
||||
<canvas id="donutChart"></canvas>
|
||||
<div class="donut-center">
|
||||
<div class="n">8,560</div>
|
||||
<div class="l">订单总数</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="legend" id="donutLegend"></div>
|
||||
</div>
|
||||
|
||||
<div class="card panel">
|
||||
<div class="panel-hd"><h2>产品使用 TOP5</h2></div>
|
||||
<div class="rank-list" id="rankList"></div>
|
||||
</div>
|
||||
|
||||
<div class="card panel">
|
||||
<div class="panel-hd"><h2>最新订单</h2><a class="kpi-link" href="#">查看全部</a></div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>订单号</th><th>用户</th><th>产品</th><th>金额</th><th>状态</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="orderBody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="notice-strip" id="noticeStrip"></section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="settings-fab" type="button" id="openSettings">KPI 显示设置</button>
|
||||
|
||||
<div class="modal-mask" id="settingsMask">
|
||||
<div class="modal" role="dialog" aria-modal="true" aria-labelledby="settingsTitle">
|
||||
<h3 id="settingsTitle">KPI 显示设置</h3>
|
||||
<p class="desc">勾选要展示的卡片,并为每张卡选择优先显示的指标。悬停卡片也可切换,设置保存在本浏览器。</p>
|
||||
<div id="settingsBody"></div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn" type="button" id="resetSettings">恢复默认</button>
|
||||
<button class="btn" type="button" id="closeSettings">取消</button>
|
||||
<button class="btn primary" type="button" id="saveSettings">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const NAV = [
|
||||
["数据驾驶舱", false],
|
||||
["工作台", true],
|
||||
["AI 助手", false],
|
||||
["数据分析", false],
|
||||
["用户管理", false],
|
||||
["产品管理", false],
|
||||
["订单管理", false],
|
||||
["营销中心", false],
|
||||
["内容管理", false],
|
||||
["财务管理", false],
|
||||
["系统设置", false],
|
||||
];
|
||||
|
||||
const KPI_CARDS = [
|
||||
{
|
||||
id: "revenue",
|
||||
title: "收入",
|
||||
tone: "blue",
|
||||
defaultPrimary: "总收入",
|
||||
metrics: [
|
||||
{ label: "总收入", value: "¥ 68,560", raw: 68560, trend: 16.3, spark: [42, 48, 45, 52, 58, 55, 68] },
|
||||
{ label: "净收入", value: "¥ 52,180", raw: 52180, trend: 11.2, spark: [30, 34, 36, 40, 44, 48, 52] },
|
||||
{ label: "退款额", value: "¥ 3,240", raw: 3240, trend: -4.1, spark: [8, 7, 9, 6, 5, 6, 4] },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "orders",
|
||||
title: "订单",
|
||||
tone: "blue",
|
||||
defaultPrimary: "订单总数",
|
||||
metrics: [
|
||||
{ label: "订单总数", value: "8,560", raw: 8560, trend: 8.2, spark: [50, 52, 54, 60, 58, 62, 70] },
|
||||
{ label: "已支付", value: "7,420", raw: 7420, trend: 9.1, spark: [40, 42, 45, 48, 50, 55, 60] },
|
||||
{ label: "待处理", value: "860", raw: 860, trend: 2.4, spark: [12, 11, 13, 12, 14, 13, 15] },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "users",
|
||||
title: "用户",
|
||||
tone: "green",
|
||||
defaultPrimary: "新增用户",
|
||||
metrics: [
|
||||
{ label: "新增用户", value: "1,256", raw: 1256, trend: 12.5, spark: [20, 24, 22, 28, 30, 34, 38] },
|
||||
{ label: "活跃用户", value: "4,560", raw: 4560, trend: 9.3, spark: [30, 32, 35, 36, 40, 42, 45] },
|
||||
{ label: "流失用户", value: "186", raw: 186, trend: -3.2, spark: [10, 9, 11, 8, 7, 8, 6] },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "conversion",
|
||||
title: "转化",
|
||||
tone: "orange",
|
||||
defaultPrimary: "转化率",
|
||||
metrics: [
|
||||
{ label: "转化率", value: "12.5%", raw: 12.5, trend: 2.4, spark: [8, 9, 9.5, 10, 11, 11.5, 12.5] },
|
||||
{ label: "下单率", value: "18.2%", raw: 18.2, trend: 1.1, spark: [14, 15, 15.5, 16, 17, 17.5, 18] },
|
||||
{ label: "复购率", value: "26.8%", raw: 26.8, trend: 3.6, spark: [20, 21, 22, 23, 24, 25, 26] },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "todos",
|
||||
title: "待办",
|
||||
tone: "cyan",
|
||||
defaultPrimary: "待办事项",
|
||||
metrics: [
|
||||
{ label: "待办事项", value: "28", raw: 28, trend: null, spark: null, link: "待处理任务 ›" },
|
||||
{ label: "今日到期", value: "6", raw: 6, trend: null, spark: null },
|
||||
{ label: "已逾期", value: "3", raw: 3, trend: null, spark: null },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const PREFS_KEY = "ai-saas-workbench-kpi-v1";
|
||||
const DEFAULT_VISIBLE = ["revenue", "orders", "users", "conversion", "todos"];
|
||||
|
||||
function loadPrefs() {
|
||||
try {
|
||||
const raw = localStorage.getItem(PREFS_KEY);
|
||||
if (!raw) return null;
|
||||
return JSON.parse(raw);
|
||||
} catch { return null; }
|
||||
}
|
||||
function savePrefs(prefs) {
|
||||
localStorage.setItem(PREFS_KEY, JSON.stringify(prefs));
|
||||
}
|
||||
function defaultPrefs() {
|
||||
const primaryByCardId = {};
|
||||
KPI_CARDS.forEach((c) => { primaryByCardId[c.id] = c.defaultPrimary; });
|
||||
return { visibleCardIds: [...DEFAULT_VISIBLE], primaryByCardId };
|
||||
}
|
||||
let prefs = Object.assign(defaultPrefs(), loadPrefs() || {});
|
||||
prefs.visibleCardIds = (prefs.visibleCardIds || DEFAULT_VISIBLE).filter((id) =>
|
||||
KPI_CARDS.some((c) => c.id === id)
|
||||
);
|
||||
if (!prefs.visibleCardIds.length) prefs.visibleCardIds = [...DEFAULT_VISIBLE];
|
||||
KPI_CARDS.forEach((c) => {
|
||||
const p = prefs.primaryByCardId?.[c.id];
|
||||
if (!p || !c.metrics.some((m) => m.label === p)) {
|
||||
prefs.primaryByCardId[c.id] = c.defaultPrimary;
|
||||
}
|
||||
});
|
||||
|
||||
function iconSvg(name) {
|
||||
const paths = {
|
||||
revenue: '<path d="M12 2v20M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/>',
|
||||
orders: '<path d="M6 2h12l2 7H4L6 2z"/><path d="M4 9v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9"/><path d="M10 13h4"/>',
|
||||
users: '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"/>',
|
||||
conversion: '<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>',
|
||||
todos: '<path d="M9 11l3 3L22 4"/><path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"/>',
|
||||
};
|
||||
return `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${paths[name] || paths.revenue}</svg>`;
|
||||
}
|
||||
|
||||
function sparkSvg(points, up = true) {
|
||||
if (!points?.length) return "";
|
||||
const w = 72, h = 28, pad = 2;
|
||||
const min = Math.min(...points), max = Math.max(...points);
|
||||
const span = max - min || 1;
|
||||
const coords = points.map((v, i) => {
|
||||
const x = pad + (i / (points.length - 1)) * (w - pad * 2);
|
||||
const y = h - pad - ((v - min) / span) * (h - pad * 2);
|
||||
return `${x},${y}`;
|
||||
});
|
||||
const color = up ? "#3b82f6" : "#ef4444";
|
||||
return `<svg class="spark" viewBox="0 0 ${w} ${h}" aria-hidden="true"><polyline fill="none" stroke="${color}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" points="${coords.join(" ")}"/></svg>`;
|
||||
}
|
||||
|
||||
function renderNav() {
|
||||
document.getElementById("nav").innerHTML = NAV.map(([name, active]) => `
|
||||
<div class="nav-item ${active ? "active" : ""}">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="7" height="7" rx="1.5"/><rect x="14" y="3" width="7" height="7" rx="1.5"/><rect x="3" y="14" width="7" height="7" rx="1.5"/><rect x="14" y="14" width="7" height="7" rx="1.5"/></svg>
|
||||
${name}
|
||||
</div>
|
||||
`).join("");
|
||||
}
|
||||
|
||||
function getPrimaryMetric(card) {
|
||||
const label = prefs.primaryByCardId[card.id] || card.defaultPrimary;
|
||||
return card.metrics.find((m) => m.label === label) || card.metrics[0];
|
||||
}
|
||||
|
||||
function setPrimary(cardId, label) {
|
||||
prefs.primaryByCardId[cardId] = label;
|
||||
savePrefs(prefs);
|
||||
renderKpis();
|
||||
}
|
||||
|
||||
function renderKpis() {
|
||||
const row = document.getElementById("kpiRow");
|
||||
const cards = KPI_CARDS.filter((c) => prefs.visibleCardIds.includes(c.id));
|
||||
row.style.gridTemplateColumns = `repeat(${Math.min(cards.length, 5)}, minmax(0, 1fr))`;
|
||||
row.innerHTML = cards.map((card) => {
|
||||
const m = getPrimaryMetric(card);
|
||||
const up = m.trend == null ? true : m.trend >= 0;
|
||||
const trendHtml = m.trend == null
|
||||
? (m.link ? `<a class="kpi-link" href="#">${m.link}</a>` : "<span></span>")
|
||||
: `<span>较上周 <span class="kpi-trend ${up ? "" : "down"}">${up ? "↑" : "↓"} ${Math.abs(m.trend)}%</span></span>`;
|
||||
const options = card.metrics.map((opt) => `
|
||||
<button type="button" class="kpi-option ${opt.label === m.label ? "active" : ""}" data-card="${card.id}" data-label="${opt.label}">
|
||||
<span class="lab">${opt.label}${opt.label === m.label ? "<small>当前</small>" : ""}</span>
|
||||
<span class="val">${opt.value}${opt.trend != null ? ` · ${opt.trend >= 0 ? "+" : ""}${opt.trend}%` : ""}</span>
|
||||
</button>
|
||||
`).join("");
|
||||
return `
|
||||
<article class="card kpi-card" tabindex="0">
|
||||
<div class="kpi-head">
|
||||
<div class="kpi-title">
|
||||
<span class="primary-name">${card.title} · ${m.label}</span>
|
||||
<span class="hint">悬停切换同组指标</span>
|
||||
</div>
|
||||
<div class="kpi-icon ${card.tone}">${iconSvg(card.id)}</div>
|
||||
</div>
|
||||
<div class="kpi-value">${m.value}</div>
|
||||
<div class="kpi-foot">
|
||||
${trendHtml}
|
||||
${m.spark ? sparkSvg(m.spark, up) : ""}
|
||||
</div>
|
||||
<div class="kpi-popover">
|
||||
<div class="tip">点击切换优先显示</div>
|
||||
${options}
|
||||
</div>
|
||||
</article>
|
||||
`;
|
||||
}).join("");
|
||||
|
||||
row.querySelectorAll(".kpi-option").forEach((btn) => {
|
||||
btn.addEventListener("click", (e) => {
|
||||
e.stopPropagation();
|
||||
setPrimary(btn.dataset.card, btn.dataset.label);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function renderTodos() {
|
||||
const items = [
|
||||
["系统维护通知", "系统将于今晚 22:00 进行例行维护", "今天 10:00", "blue"],
|
||||
["新功能上线", "AI 助手 v2.0 已正式发布", "昨天 15:30", "green"],
|
||||
["数据备份完成", "上周数据备份已成功完成", "昨天 09:15", "blue"],
|
||||
["订单异常提醒", "检测到 3 笔异常订单需要处理", "前天 16:45", "orange"],
|
||||
["用户反馈汇总", "本周共收到 28 条用户反馈", "前天 11:20", "red"],
|
||||
];
|
||||
document.getElementById("todoList").innerHTML = items.map(([t, d, time, c]) => `
|
||||
<li class="todo-item">
|
||||
<i class="dot ${c}"></i>
|
||||
<div class="todo-body"><strong>${t}</strong><span>${d}</span></div>
|
||||
<span class="todo-time">${time}</span>
|
||||
</li>
|
||||
`).join("");
|
||||
}
|
||||
|
||||
function renderRanks() {
|
||||
const rows = [
|
||||
["AI 助手", 8560, 100],
|
||||
["数据分析平台", 6540, 76],
|
||||
["智能客服", 4320, 50],
|
||||
["内容生成器", 3210, 37],
|
||||
["营销自动化", 2180, 25],
|
||||
];
|
||||
document.getElementById("rankList").innerHTML = rows.map(([name, val, pct], i) => `
|
||||
<div class="rank-row">
|
||||
<div class="rank-idx ${i < 3 ? "top" : ""}">${i + 1}</div>
|
||||
<div>
|
||||
<div class="rank-name">${name}</div>
|
||||
<div class="bar"><span style="width:${pct}%"></span></div>
|
||||
</div>
|
||||
<div class="rank-val">${val.toLocaleString("zh-CN")}</div>
|
||||
</div>
|
||||
`).join("");
|
||||
}
|
||||
|
||||
function renderOrders() {
|
||||
const rows = [
|
||||
["ORD-20240507001", "张三", "AI 助手 Pro", "¥299", "paid", "已支付"],
|
||||
["ORD-20240507002", "李四", "数据分析基础版", "¥99", "pending", "待支付"],
|
||||
["ORD-20240507003", "王五", "智能客服企业版", "¥999", "paid", "已支付"],
|
||||
["ORD-20240507004", "赵六", "内容生成器", "¥199", "cancel", "已取消"],
|
||||
["ORD-20240507005", "钱七", "营销自动化", "¥499", "paid", "已支付"],
|
||||
];
|
||||
document.getElementById("orderBody").innerHTML = rows.map((r) => `
|
||||
<tr>
|
||||
<td>${r[0]}</td><td>${r[1]}</td><td>${r[2]}</td><td>${r[3]}</td>
|
||||
<td><span class="tag ${r[4]}">${r[5]}</span></td>
|
||||
</tr>
|
||||
`).join("");
|
||||
}
|
||||
|
||||
function renderNotices() {
|
||||
const items = [
|
||||
["系统维护通知", "系统将于今晚 22:00 进行例行维护,预计持续 2 小时"],
|
||||
["新功能上线", "AI 助手 v2.0 已正式发布,欢迎体验新功能"],
|
||||
["数据备份完成", "上周数据备份已成功完成,可在设置中查看"],
|
||||
["安全提醒", "建议开启二次验证以提升账户安全性"],
|
||||
];
|
||||
document.getElementById("noticeStrip").innerHTML = items.map(([t, d]) => `
|
||||
<div class="card notice">
|
||||
<div class="notice-ico">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/></svg>
|
||||
</div>
|
||||
<div><strong>${t}</strong><span>${d}</span></div>
|
||||
</div>
|
||||
`).join("");
|
||||
}
|
||||
|
||||
const TREND = {
|
||||
revenue: [42000, 48000, 45000, 52000, 68560, 61000, 64000],
|
||||
orders: [980, 1050, 990, 1120, 1280, 1190, 1250],
|
||||
users: [160, 180, 170, 210, 256, 230, 240],
|
||||
};
|
||||
const LABELS = ["05-01", "05-02", "05-03", "05-04", "05-05", "05-06", "05-07"];
|
||||
let trendChart;
|
||||
|
||||
function buildTrend(key) {
|
||||
const ctx = document.getElementById("trendChart");
|
||||
const data = TREND[key];
|
||||
if (trendChart) trendChart.destroy();
|
||||
trendChart = new Chart(ctx, {
|
||||
type: "line",
|
||||
data: {
|
||||
labels: LABELS,
|
||||
datasets: [{
|
||||
label: key === "revenue" ? "收入" : key === "orders" ? "订单" : "用户",
|
||||
data,
|
||||
borderColor: "#3b82f6",
|
||||
backgroundColor: (c) => {
|
||||
const g = c.chart.ctx.createLinearGradient(0, 0, 0, c.chart.height);
|
||||
g.addColorStop(0, "rgba(59,130,246,0.28)");
|
||||
g.addColorStop(1, "rgba(59,130,246,0.02)");
|
||||
return g;
|
||||
},
|
||||
fill: true,
|
||||
tension: 0.4,
|
||||
pointRadius: 3,
|
||||
pointHoverRadius: 5,
|
||||
pointBackgroundColor: "#fff",
|
||||
pointBorderColor: "#3b82f6",
|
||||
pointBorderWidth: 2,
|
||||
}],
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
plugins: {
|
||||
legend: { display: false },
|
||||
tooltip: {
|
||||
backgroundColor: "#111827",
|
||||
padding: 10,
|
||||
callbacks: {
|
||||
label: (ctx) => {
|
||||
const v = ctx.parsed.y;
|
||||
if (key === "revenue") return `收入: ¥ ${v.toLocaleString("zh-CN")}`;
|
||||
return `${ctx.dataset.label}: ${v.toLocaleString("zh-CN")}`;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
scales: {
|
||||
x: { grid: { display: false }, ticks: { color: "#94a3b8" }, border: { display: false } },
|
||||
y: {
|
||||
grid: { color: "#f1f5f9" },
|
||||
ticks: {
|
||||
color: "#94a3b8",
|
||||
callback: (v) => key === "revenue" ? (v / 1000) + "k" : v,
|
||||
},
|
||||
border: { display: false },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function buildDonut() {
|
||||
const slices = [
|
||||
{ label: "基础版", value: 3200, color: "#3b82f6" },
|
||||
{ label: "专业版", value: 2800, color: "#60a5fa" },
|
||||
{ label: "企业版", value: 1800, color: "#93c5fd" },
|
||||
{ label: "定制版", value: 760, color: "#bfdbfe" },
|
||||
];
|
||||
document.getElementById("donutLegend").innerHTML = slices.map((s) =>
|
||||
`<div><i style="background:${s.color}"></i>${s.label} ${s.value.toLocaleString("zh-CN")}</div>`
|
||||
).join("");
|
||||
new Chart(document.getElementById("donutChart"), {
|
||||
type: "doughnut",
|
||||
data: {
|
||||
labels: slices.map((s) => s.label),
|
||||
datasets: [{ data: slices.map((s) => s.value), backgroundColor: slices.map((s) => s.color), borderWidth: 0, hoverOffset: 4 }],
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
maintainAspectRatio: false,
|
||||
cutout: "72%",
|
||||
plugins: { legend: { display: false } },
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/* Settings modal */
|
||||
const mask = document.getElementById("settingsMask");
|
||||
function openSettings() {
|
||||
const body = document.getElementById("settingsBody");
|
||||
body.innerHTML = KPI_CARDS.map((card) => {
|
||||
const checked = prefs.visibleCardIds.includes(card.id) ? "checked" : "";
|
||||
const radios = card.metrics.map((m) => `
|
||||
<label>
|
||||
<input type="radio" name="primary-${card.id}" value="${m.label}" ${prefs.primaryByCardId[card.id] === m.label ? "checked" : ""} />
|
||||
${m.label}
|
||||
</label>
|
||||
`).join("");
|
||||
return `
|
||||
<div class="modal-card" data-id="${card.id}">
|
||||
<label class="head"><input type="checkbox" class="vis" ${checked} /> ${card.title}</label>
|
||||
<div class="radios">${radios}</div>
|
||||
</div>
|
||||
`;
|
||||
}).join("");
|
||||
mask.classList.add("open");
|
||||
}
|
||||
function closeSettings() { mask.classList.remove("open"); }
|
||||
document.getElementById("openSettings").addEventListener("click", openSettings);
|
||||
document.getElementById("closeSettings").addEventListener("click", closeSettings);
|
||||
mask.addEventListener("click", (e) => { if (e.target === mask) closeSettings(); });
|
||||
document.getElementById("resetSettings").addEventListener("click", () => {
|
||||
prefs = defaultPrefs();
|
||||
savePrefs(prefs);
|
||||
openSettings();
|
||||
renderKpis();
|
||||
});
|
||||
document.getElementById("saveSettings").addEventListener("click", () => {
|
||||
const visible = [];
|
||||
const primaryByCardId = { ...prefs.primaryByCardId };
|
||||
document.querySelectorAll("#settingsBody .modal-card").forEach((el) => {
|
||||
const id = el.dataset.id;
|
||||
if (el.querySelector(".vis").checked) visible.push(id);
|
||||
const checked = el.querySelector(`input[name="primary-${id}"]:checked`);
|
||||
if (checked) primaryByCardId[id] = checked.value;
|
||||
});
|
||||
if (!visible.length) {
|
||||
alert("请至少选择一张 KPI 卡片");
|
||||
return;
|
||||
}
|
||||
prefs = { visibleCardIds: visible, primaryByCardId };
|
||||
savePrefs(prefs);
|
||||
renderKpis();
|
||||
closeSettings();
|
||||
});
|
||||
|
||||
document.getElementById("trendTabs").addEventListener("click", (e) => {
|
||||
const btn = e.target.closest(".tab");
|
||||
if (!btn) return;
|
||||
document.querySelectorAll("#trendTabs .tab").forEach((t) => t.classList.remove("active"));
|
||||
btn.classList.add("active");
|
||||
buildTrend(btn.dataset.tab);
|
||||
});
|
||||
|
||||
// Date label like screenshot
|
||||
document.getElementById("todayLabel").textContent = "星期二, 2024年5月7日";
|
||||
|
||||
renderNav();
|
||||
renderKpis();
|
||||
renderTodos();
|
||||
renderRanks();
|
||||
renderOrders();
|
||||
renderNotices();
|
||||
buildTrend("revenue");
|
||||
buildDonut();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user