mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
fix(workbench): 统一区间对比增幅显示格式,优化颜色语义;欢迎页跳转工作台
This commit is contained in:
@@ -17,8 +17,8 @@ const LoadingIcon = createIconifyIcon('line-md:loading-twotone-loop');
|
||||
const ChartIcon = createIconifyIcon('solar:chart-2-linear');
|
||||
const DownloadIcon = createIconifyIcon('solar:file-download-linear');
|
||||
|
||||
const goOverview = () => {
|
||||
router.push('/store-overview');
|
||||
const goWorkbench = () => {
|
||||
router.push('/dashboard/workbench');
|
||||
};
|
||||
|
||||
const goImportTask = () => {
|
||||
@@ -76,7 +76,7 @@ const goImportTask = () => {
|
||||
</div>
|
||||
|
||||
<div class="btn-group">
|
||||
<button class="btn-primary" @click="goOverview">全店概览</button>
|
||||
<button class="btn-primary" @click="goWorkbench">工作台</button>
|
||||
<button class="btn-secondary" type="button" @click="goImportTask">
|
||||
导入订单
|
||||
</button>
|
||||
|
||||
+73
-64
@@ -56,9 +56,39 @@ function num(v: unknown): number {
|
||||
return Number.isFinite(n) ? n : 0;
|
||||
}
|
||||
|
||||
/** 百分比展示统一保留的小数位 */
|
||||
const PCT_DECIMALS = 2;
|
||||
|
||||
function roundTo(n: number, digits = PCT_DECIMALS) {
|
||||
const f = 10 ** digits;
|
||||
return Math.round(n * f) / f;
|
||||
}
|
||||
|
||||
/** 如 12.35% */
|
||||
function formatPercentValue(n: number) {
|
||||
const v = roundTo(n, PCT_DECIMALS);
|
||||
return `${v.toFixed(PCT_DECIMALS)}%`;
|
||||
}
|
||||
|
||||
/** 如 +1.25%(增幅列) */
|
||||
function formatSignedPercent(n: number) {
|
||||
const v = roundTo(n, PCT_DECIMALS);
|
||||
if (v === 0) return `${v.toFixed(PCT_DECIMALS)}%`;
|
||||
const sign = v > 0 ? '+' : '';
|
||||
return `${sign}${v.toFixed(PCT_DECIMALS)}%`;
|
||||
}
|
||||
|
||||
/** 费比差额:百分点,如 +1.25 pts */
|
||||
function formatPercentDeltaPts(d: number) {
|
||||
const v = roundTo(d, PCT_DECIMALS);
|
||||
if (v === 0) return `${v.toFixed(PCT_DECIMALS)} pts`;
|
||||
const sign = v > 0 ? '+' : '';
|
||||
return `${sign}${v.toFixed(PCT_DECIMALS)} pts`;
|
||||
}
|
||||
|
||||
function feeRatioAsPercent(row: CompanyOverviewVO.ShopSummary | null | undefined) {
|
||||
if (!row || row.feeRatio == null) return 0;
|
||||
return num(row.feeRatio) * 100;
|
||||
return roundTo(num(row.feeRatio) * 100, PCT_DECIMALS);
|
||||
}
|
||||
|
||||
function buildCompareMetrics(
|
||||
@@ -309,7 +339,7 @@ function formatCell(m: CompareMetric, side: 'a' | 'b') {
|
||||
return formatMoney(v);
|
||||
}
|
||||
case 'percent': {
|
||||
return `${v.toFixed(1)}%`;
|
||||
return formatPercentValue(v);
|
||||
}
|
||||
case 'ratio': {
|
||||
return `${v.toFixed(2)} : 1`;
|
||||
@@ -325,14 +355,17 @@ function delta(m: CompareMetric) {
|
||||
}
|
||||
|
||||
function growthPct(m: CompareMetric): number | null {
|
||||
let raw: number | null;
|
||||
if (m.format === 'ratio') {
|
||||
if (m.valueA === 0) return null;
|
||||
return ((m.valueB - m.valueA) / m.valueA) * 100;
|
||||
raw = ((m.valueB - m.valueA) / m.valueA) * 100;
|
||||
} else if (m.valueA === 0) {
|
||||
raw = m.valueB === 0 ? 0 : null;
|
||||
} else {
|
||||
raw = ((m.valueB - m.valueA) / m.valueA) * 100;
|
||||
}
|
||||
if (m.valueA === 0) {
|
||||
return m.valueB === 0 ? 0 : null;
|
||||
}
|
||||
return ((m.valueB - m.valueA) / m.valueA) * 100;
|
||||
if (raw === null || !Number.isFinite(raw)) return null;
|
||||
return roundTo(raw, PCT_DECIMALS);
|
||||
}
|
||||
|
||||
function formatDelta(m: CompareMetric) {
|
||||
@@ -348,8 +381,7 @@ function formatDelta(m: CompareMetric) {
|
||||
return body;
|
||||
}
|
||||
if (m.format === 'percent') {
|
||||
const sign = d > 0 ? '+' : '';
|
||||
return `${sign}${d.toFixed(1)} pts`;
|
||||
return formatPercentDeltaPts(d);
|
||||
}
|
||||
if (m.format === 'ratio') {
|
||||
const sign = d > 0 ? '+' : '';
|
||||
@@ -361,33 +393,25 @@ function formatDelta(m: CompareMetric) {
|
||||
function growthDisplay(m: CompareMetric) {
|
||||
const g = growthPct(m);
|
||||
if (g === null) return '—';
|
||||
const sign = g > 0 ? '+' : '';
|
||||
return `${sign}${g.toFixed(1)}%`;
|
||||
return formatSignedPercent(g);
|
||||
}
|
||||
|
||||
/** 差额 / 增幅统一按数值正负着色:正=绿,负=红,零或无法计算=灰 */
|
||||
function signedChangeClass(value: number | null | undefined) {
|
||||
if (value === null || value === undefined || !Number.isFinite(value) || value === 0) {
|
||||
return 'font-bold text-slate-500 dark:text-slate-400';
|
||||
}
|
||||
return value > 0
|
||||
? 'font-black text-emerald-600 dark:text-emerald-400'
|
||||
: 'font-black text-rose-600 dark:text-rose-400';
|
||||
}
|
||||
|
||||
function deltaClass(m: CompareMetric) {
|
||||
return signedChangeClass(delta(m));
|
||||
}
|
||||
|
||||
function growthClass(m: CompareMetric) {
|
||||
const g = growthPct(m);
|
||||
if (g === null || !Number.isFinite(g)) {
|
||||
return 'text-slate-400 dark:text-slate-500';
|
||||
}
|
||||
const inverse =
|
||||
m.key === 'refundAmount' ||
|
||||
m.key === 'totalCost' ||
|
||||
m.key === 'productCost' ||
|
||||
m.key === 'feeRatio' ||
|
||||
m.key === 'totalPromotionFee' ||
|
||||
m.key === 'brushFee' ||
|
||||
m.key === 'shippingCost' ||
|
||||
m.key === 'otherCost' ||
|
||||
m.key === 'salesTaxAmount';
|
||||
if (inverse) {
|
||||
return g <= 0
|
||||
? 'font-black text-emerald-600 dark:text-emerald-400'
|
||||
: 'font-black text-rose-600 dark:text-rose-400';
|
||||
}
|
||||
return g >= 0
|
||||
? 'font-black text-emerald-600 dark:text-emerald-400'
|
||||
: 'font-black text-rose-600 dark:text-rose-400';
|
||||
return signedChangeClass(growthPct(m));
|
||||
}
|
||||
|
||||
const shellClass =
|
||||
@@ -403,31 +427,17 @@ const growthChartHeightPx = computed(
|
||||
() => Math.max(320, metricsRows.value.length * 26 + 100),
|
||||
);
|
||||
|
||||
function isInverseMetricKey(key: string) {
|
||||
return (
|
||||
key === 'refundAmount' ||
|
||||
key === 'totalCost' ||
|
||||
key === 'productCost' ||
|
||||
key === 'feeRatio' ||
|
||||
key === 'totalPromotionFee' ||
|
||||
key === 'brushFee' ||
|
||||
key === 'shippingCost' ||
|
||||
key === 'otherCost' ||
|
||||
key === 'salesTaxAmount'
|
||||
);
|
||||
}
|
||||
|
||||
function growthBarColor(m: CompareMetric, g: number | null, dark: boolean) {
|
||||
if (g === null || !Number.isFinite(g)) {
|
||||
function growthBarColor(_m: CompareMetric, g: number | null, dark: boolean) {
|
||||
if (g === null || !Number.isFinite(g) || g === 0) {
|
||||
return dark ? '#64748b' : '#94a3b8';
|
||||
}
|
||||
const inv = isInverseMetricKey(m.key);
|
||||
const good = dark ? '#34d399' : '#059669';
|
||||
const bad = dark ? '#fb7185' : '#e11d48';
|
||||
if (inv) {
|
||||
return g <= 0 ? good : bad;
|
||||
}
|
||||
return g >= 0 ? good : bad;
|
||||
return g > 0
|
||||
? dark
|
||||
? '#34d399'
|
||||
: '#059669'
|
||||
: dark
|
||||
? '#fb7185'
|
||||
: '#e11d48';
|
||||
}
|
||||
|
||||
const moneyBarRef = ref<EchartsUIType>();
|
||||
@@ -558,7 +568,7 @@ function drawGrowthCompareChart() {
|
||||
left: 0,
|
||||
top: 0,
|
||||
textStyle: { fontSize: 13, fontWeight: 800, color: t.tipFg },
|
||||
subtext: '与表格「增幅」列同口径;区间 A 为 0 时无法计算,条形不展示有效长度。',
|
||||
subtext: '与表格「增幅」列同口径;绿=正增幅、红=负增幅;区间 A 为 0 时无法计算。',
|
||||
subtextStyle: { fontSize: 10, fontWeight: 600, color: t.axis, lineHeight: 14 },
|
||||
},
|
||||
tooltip: {
|
||||
@@ -580,8 +590,7 @@ function drawGrowthCompareChart() {
|
||||
if (rg === null || rg === undefined || !Number.isFinite(rg)) {
|
||||
return `${m.label}<br/>增幅:—<br/>A:${formatCell(m, 'a')}<br/>B:${formatCell(m, 'b')}`;
|
||||
}
|
||||
const sign = rg > 0 ? '+' : '';
|
||||
return `${m.label}<br/>增幅:${sign}${rg.toFixed(1)}%<br/>A:${formatCell(m, 'a')}<br/>B:${formatCell(m, 'b')}`;
|
||||
return `${m.label}<br/>增幅:${formatSignedPercent(rg)}<br/>A:${formatCell(m, 'a')}<br/>B:${formatCell(m, 'b')}`;
|
||||
},
|
||||
},
|
||||
grid: { left: 4, right: 56, top: 64, bottom: 8, containLabel: true },
|
||||
@@ -593,7 +602,7 @@ function drawGrowthCompareChart() {
|
||||
nameTextStyle: { color: t.axis, fontSize: 11, fontWeight: 700 },
|
||||
axisLabel: {
|
||||
color: t.axis,
|
||||
formatter: (v: number) => `${v}%`,
|
||||
formatter: (v: number) => formatPercentValue(Number(v)),
|
||||
},
|
||||
splitLine: { lineStyle: { type: 'dashed', color: t.split } },
|
||||
axisLine: { lineStyle: { color: t.split } },
|
||||
@@ -631,8 +640,7 @@ function drawGrowthCompareChart() {
|
||||
const row = p.data as { realGrowth?: number | null } | undefined;
|
||||
const rg = row?.realGrowth;
|
||||
if (rg === null || rg === undefined || !Number.isFinite(rg)) return '';
|
||||
const sign = rg > 0 ? '+' : '';
|
||||
return `${sign}${rg.toFixed(1)}%`;
|
||||
return formatSignedPercent(rg);
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -679,7 +687,7 @@ defineExpose({ redraw });
|
||||
<p
|
||||
class="mt-1 text-xs font-bold leading-relaxed text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
首次进入本 Tab 时按当前筛选与税率分别请求区间 A、区间 B;上方为<strong class="font-black text-slate-600 dark:text-slate-300">双柱对比(万元)</strong>与<strong class="font-black text-slate-600 dark:text-slate-300">相对 A 的增幅条形图</strong>,下方为明细表(与「多维度经营明细汇总」店铺表合计行同源)。
|
||||
首次进入本 Tab 时按当前筛选与税率分别请求区间 A、区间 B;上方为<strong class="font-black text-slate-600 dark:text-slate-300">双柱对比(万元)</strong>与<strong class="font-black text-slate-600 dark:text-slate-300">相对 A 的增幅条形图</strong>,下方为明细表(与「多维度经营明细汇总」店铺表合计行同源)。差额、增幅及增幅图:<span class="text-emerald-600 dark:text-emerald-400">绿色=上升</span>,<span class="text-rose-600 dark:text-rose-400">红色=下降</span>(按 B−A 数值正负,与指标好坏无关)。
|
||||
</p>
|
||||
<div
|
||||
class="mt-4 flex flex-col gap-4 lg:flex-row lg:flex-wrap lg:items-end"
|
||||
@@ -790,7 +798,8 @@ defineExpose({ redraw });
|
||||
{{ formatCell(m, 'b') }}
|
||||
</td>
|
||||
<td
|
||||
class="border-l border-slate-100 px-4 py-3 font-mono text-xs font-bold tabular-nums text-slate-800 dark:border-[hsl(240deg_3.7%_22%)] dark:text-slate-100"
|
||||
class="border-l border-slate-100 px-4 py-3 font-mono text-xs tabular-nums dark:border-[hsl(240deg_3.7%_22%)]"
|
||||
:class="deltaClass(m)"
|
||||
>
|
||||
{{ formatDelta(m) }}
|
||||
</td>
|
||||
|
||||
+322
@@ -0,0 +1,322 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
|
||||
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||
|
||||
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
|
||||
import {
|
||||
salesTaxColumnHint,
|
||||
storeOverviewHints,
|
||||
} from '#/utils/overview-table-hints';
|
||||
|
||||
defineOptions({ name: 'WorkbenchCategoryComparisonTable' });
|
||||
|
||||
interface Props {
|
||||
categorySummary?: CompanyOverviewVO.CategoryOverview;
|
||||
taxRate: number;
|
||||
categoryExportMode?: boolean;
|
||||
selectedExportCategoryIds?: number[];
|
||||
headingTitle?: string;
|
||||
headingSubtitle?: string;
|
||||
/** 首列维度名称,如「品类」「商品」 */
|
||||
firstColumnLabel?: string;
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:selectedExportCategoryIds', ids: number[]): void;
|
||||
(e: 'toggleCategoryExportMode', enabled: boolean): void;
|
||||
(e: 'export'): void;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
categoryExportMode: false,
|
||||
selectedExportCategoryIds: () => [],
|
||||
headingTitle: '各品类多维度经营明细汇总',
|
||||
headingSubtitle: '包含:规模、成本及最终损益所有维度',
|
||||
firstColumnLabel: '品类',
|
||||
});
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const allCategoriesSelected = computed(() => {
|
||||
const total = props.categorySummary?.categories?.length || 0;
|
||||
return total > 0 && props.selectedExportCategoryIds.length === total;
|
||||
});
|
||||
|
||||
const someCategoriesSelected = computed(() => {
|
||||
return props.selectedExportCategoryIds.length > 0;
|
||||
});
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
};
|
||||
|
||||
const cellMoney = (v: number | null | undefined) => formatNumberCell(v, formatAmount);
|
||||
const cellRoi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, (n) => n.toFixed(2));
|
||||
|
||||
</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="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"
|
||||
>
|
||||
<div>
|
||||
<h3 class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
{{ props.headingTitle }}
|
||||
</h3>
|
||||
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ props.headingSubtitle }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<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%)]"
|
||||
@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"
|
||||
:disabled="selectedExportCategoryIds.length === 0"
|
||||
@click="emit('export')"
|
||||
>
|
||||
导出已选品类 ({{ selectedExportCategoryIds.length }})
|
||||
</button>
|
||||
</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%)]"
|
||||
@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"
|
||||
@click="emit('export')"
|
||||
>
|
||||
导出全部
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-container overflow-x-auto">
|
||||
<table class="w-full whitespace-nowrap text-left text-sm">
|
||||
<thead
|
||||
class="bg-slate-50 dark:bg-[hsl(240deg_3.7%_15.9%)] text-xs font-black uppercase text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
<tr>
|
||||
<th
|
||||
v-if="categoryExportMode"
|
||||
rowspan="2"
|
||||
class="border-b border-r border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-r-[hsl(240deg_3.7%_22%)] bg-slate-50 dark:bg-[hsl(240deg_3.7%_15.9%)] p-3 text-center"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allCategoriesSelected"
|
||||
:indeterminate="someCategoriesSelected && !allCategoriesSelected"
|
||||
class="h-4 w-4 cursor-pointer accent-blue-600"
|
||||
@change="
|
||||
emit(
|
||||
'update:selectedExportCategoryIds',
|
||||
allCategoriesSelected
|
||||
? []
|
||||
: (categorySummary?.categories ?? []).map((c) => c.categoryId!)
|
||||
)
|
||||
"
|
||||
/>
|
||||
</th>
|
||||
<th
|
||||
rowspan="2"
|
||||
class="sticky-col border-b p-6 text-base font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)] border-r-2 border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] shadow-sm dark:shadow-none"
|
||||
>
|
||||
{{ props.firstColumnLabel }}
|
||||
</th>
|
||||
<th
|
||||
colspan="3"
|
||||
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50%)] p-3 text-center"
|
||||
>
|
||||
经营规模维度
|
||||
</th>
|
||||
<th
|
||||
colspan="8"
|
||||
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] dark:border-[hsl(240deg_3.7%_22%)] bg-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] p-3 text-center text-orange-700 dark:text-orange-400"
|
||||
>
|
||||
成本费用维度
|
||||
</th>
|
||||
<th
|
||||
colspan="5"
|
||||
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] dark:border-[hsl(240deg_3.7%_22%)] bg-emerald-50/50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-3 text-center text-emerald-700 dark:text-emerald-400"
|
||||
>
|
||||
盈利分析维度
|
||||
</th>
|
||||
</tr>
|
||||
<tr class="bg-slate-50/80 dark:bg-[hsl(240deg_3.7%_15.9%/80)] text-sm">
|
||||
<th class="border-b border-l px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<OverviewColumnHint :title="storeOverviewHints.salesAmount">
|
||||
实际销售额
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.orderCount">单量</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.averageOrderValue">客单价</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-l px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.productCost">商品成本</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.shippingCost">运费</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.otherCost">其他成本</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 font-bold text-orange-800 dark:text-orange-300">
|
||||
<OverviewColumnHint :title="storeOverviewHints.totalCost">总成本</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 font-bold text-rose-600 dark:text-rose-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.refundAmount">退款金额</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.totalPromotionFee">推广费</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 text-orange-600 dark:text-orange-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.brushFee">刷单费用</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
<OverviewColumnHint :title="storeOverviewHints.feeRatioCategoryRow">费比%</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-l px-6 py-4 font-bold">
|
||||
<OverviewColumnHint :title="storeOverviewHints.totalProfitBeforeTax">
|
||||
税前盈亏
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 italic text-rose-500 dark:text-rose-400">
|
||||
<OverviewColumnHint :title="salesTaxColumnHint(taxRate)">
|
||||
{{ (taxRate * 100).toFixed(0) }}%税额
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 font-black text-indigo-700 dark:text-indigo-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.roi">ROI</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b bg-emerald-600 dark:bg-emerald-600 px-6 py-4 font-black text-white">
|
||||
<OverviewColumnHint light :title="storeOverviewHints.profitAfterTax">
|
||||
税后盈亏
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
||||
<tr
|
||||
v-for="cat in (categorySummary?.categories || [])"
|
||||
:key="cat.categoryId ?? 'uncategorized'"
|
||||
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
||||
>
|
||||
<td
|
||||
v-if="categoryExportMode"
|
||||
class="border-b border-r border-slate-100 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-r-[hsl(240deg_3.7%_22%)] bg-white p-3 text-center dark:bg-[hsl(222.34deg_10.43%_12.27%)]"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selectedExportCategoryIds.includes(cat.categoryId!)"
|
||||
class="h-4 w-4 cursor-pointer accent-blue-600"
|
||||
@change="
|
||||
(e) => {
|
||||
const checked = (e.target as HTMLInputElement).checked;
|
||||
emit(
|
||||
'update:selectedExportCategoryIds',
|
||||
checked
|
||||
? [...selectedExportCategoryIds, cat.categoryId!]
|
||||
: selectedExportCategoryIds.filter((id) => id !== cat.categoryId)
|
||||
);
|
||||
}
|
||||
"
|
||||
/>
|
||||
</td>
|
||||
<td class="sticky-col border-r-2 border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 font-bold shadow-sm dark:shadow-none">
|
||||
<span class="inline-block rounded-full bg-blue-50 dark:bg-blue-900/30 px-3 py-1 text-sm font-bold text-blue-600 dark:text-blue-400 transition-colors hover:text-blue-300 hover:underline">
|
||||
{{ cat.categoryName }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="p-6 font-black">{{ formatAmount(cat.salesAmount) }}</td>
|
||||
<td class="p-6 font-medium">{{ formatIntCell(cat.orderCount) }}</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{ cellMoney(cat.averageOrderValue) }}
|
||||
</td>
|
||||
<td class="p-6">{{ cellMoney(cat.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(cat.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(cat.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">
|
||||
{{ cellMoney(cat.totalCost) }}
|
||||
</td>
|
||||
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">
|
||||
{{ cellMoney(cat.refundAmount) }}
|
||||
</td>
|
||||
<td class="p-6">{{ cellMoney(cat.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">
|
||||
{{ cellMoney(cat.brushFee) }}
|
||||
</td>
|
||||
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cat.feeRatio !== undefined ? formatFeeRatioPercent(cat.feeRatio) : '-' }}
|
||||
</td>
|
||||
<td class="p-6 font-bold">
|
||||
{{ cellMoney(cat.totalProfitBeforeTax) }}
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cellMoney(cat.salesTaxAmount) }}
|
||||
</td>
|
||||
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">
|
||||
{{ cellRoi(cat.roi) }}
|
||||
</td>
|
||||
<td class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-6 text-base font-black text-emerald-600">
|
||||
{{ cellMoney(cat.profitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!categorySummary?.categories?.length">
|
||||
<td :colspan="categoryExportMode ? 18 : 17" class="p-8 text-center text-gray-400">
|
||||
暂无数据
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<!-- 合计行 -->
|
||||
<tfoot v-if="categorySummary?.total" class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<td class="p-6 text-base">合计</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.salesAmount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(categorySummary?.total?.orderCount) }}</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(categorySummary?.total?.averageOrderValue) }}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(categorySummary?.total?.totalCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(categorySummary?.total?.refundAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(categorySummary?.total?.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ categorySummary?.total?.feeRatio !== undefined ? formatFeeRatioPercent(categorySummary?.total?.feeRatio) : '-' }}</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.totalProfitBeforeTax) }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(categorySummary?.total?.salesTaxAmount) }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ cellRoi(categorySummary?.total?.roi) }}</td>
|
||||
<td
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(categorySummary?.total?.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-700 dark:text-emerald-300'"
|
||||
>{{ cellMoney(categorySummary?.total?.profitAfterTax) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+11
-18
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
|
||||
import type { WorkbenchDTO } from '#/api/ecommerce/workbench/types';
|
||||
@@ -9,9 +8,9 @@ import { message, Segmented } from 'ant-design-vue';
|
||||
|
||||
import { exportByPost } from '#/utils/export';
|
||||
|
||||
import CategoryComparisonTable from '../../../../store-overview/components/CategoryComparisonTable.vue';
|
||||
import PlatformSummaryCard from '../../../../store-overview/components/PlatformSummaryCard.vue';
|
||||
import ShopComparisonTable from '../../../../store-overview/components/ShopComparisonTable.vue';
|
||||
import WorkbenchCategoryComparisonTable from './WorkbenchCategoryComparisonTable.vue';
|
||||
import WorkbenchPlatformSummaryCard from './WorkbenchPlatformSummaryCard.vue';
|
||||
import WorkbenchShopComparisonTable from './WorkbenchShopComparisonTable.vue';
|
||||
|
||||
defineOptions({ name: 'WorkbenchOverviewTables' });
|
||||
|
||||
@@ -43,8 +42,6 @@ const selectedExportProductIds = ref<number[]>([]);
|
||||
|
||||
const exportLoading = ref(false);
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const modeOptions = [
|
||||
{ label: '店铺汇总', value: 'shop' },
|
||||
{ label: '平台汇总', value: 'platform' },
|
||||
@@ -170,11 +167,6 @@ async function handleProductExport() {
|
||||
}
|
||||
}
|
||||
|
||||
function navigateToShopOverview(shopId: number) {
|
||||
router.push({
|
||||
path: `/ecom/shop/overview/${shopId}`,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -182,7 +174,7 @@ function navigateToShopOverview(shopId: number) {
|
||||
<p
|
||||
class="text-xs font-bold text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
下列表格与「全店概览」使用相同组件;四表数据由工作台接口按订单、推广费、刷单与店铺月度目标等口径汇总(与全店概览后端计算一致)。若接口未返回汇总表字段,则回退为按维度行估算(部分列为「-」)。
|
||||
四张汇总表数据由工作台接口按订单、推广费、刷单与店铺月度目标等口径汇总(与全店概览后端计算一致)。若接口未返回汇总表字段,则回退为按维度行估算(部分列为「-」)。
|
||||
</p>
|
||||
<div class="flex justify-end">
|
||||
<Segmented
|
||||
@@ -193,21 +185,21 @@ function navigateToShopOverview(shopId: number) {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ShopComparisonTable
|
||||
<WorkbenchShopComparisonTable
|
||||
v-if="activeMode === 'shop'"
|
||||
heading-title="各店铺多维度经营明细汇总"
|
||||
heading-subtitle="与全店概览同款表格;金额与目标等为后端汇总口径(元)"
|
||||
:shop-summary="shopSummary ?? undefined"
|
||||
:tax-rate="taxRate"
|
||||
:navigable="false"
|
||||
:shop-export-mode="shopExportMode"
|
||||
:selected-export-shop-ids="selectedExportShopIds"
|
||||
@update:selected-export-shop-ids="selectedExportShopIds = $event"
|
||||
@toggle-shop-export-mode="shopExportMode = $event"
|
||||
@export="handleShopExport"
|
||||
@navigate="navigateToShopOverview"
|
||||
/>
|
||||
|
||||
<PlatformSummaryCard
|
||||
<WorkbenchPlatformSummaryCard
|
||||
v-if="activeMode === 'platform'"
|
||||
heading-title="各平台多维度经营明细汇总"
|
||||
heading-subtitle="与全店概览同款表格"
|
||||
@@ -220,7 +212,7 @@ function navigateToShopOverview(shopId: number) {
|
||||
@export="handlePlatformExport"
|
||||
/>
|
||||
|
||||
<CategoryComparisonTable
|
||||
<WorkbenchCategoryComparisonTable
|
||||
v-if="activeMode === 'category'"
|
||||
heading-title="各品类多维度经营明细汇总"
|
||||
heading-subtitle="与全店概览同款表格"
|
||||
@@ -233,11 +225,12 @@ function navigateToShopOverview(shopId: number) {
|
||||
@export="handleCategoryExport"
|
||||
/>
|
||||
|
||||
<CategoryComparisonTable
|
||||
<WorkbenchCategoryComparisonTable
|
||||
v-if="activeMode === 'product'"
|
||||
heading-title="各商品多维度经营明细汇总"
|
||||
heading-subtitle="列结构与品类表一致;数据与全店概览商品维度同源"
|
||||
heading-subtitle="列结构与品类表一致;数据与全店概览商品维度同源;点击商品名可跳转商品概览"
|
||||
first-column-label="商品"
|
||||
product-navigate
|
||||
:category-summary="productSummary ?? undefined"
|
||||
:tax-rate="taxRate"
|
||||
:category-export-mode="productExportMode"
|
||||
|
||||
+424
@@ -0,0 +1,424 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
|
||||
|
||||
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||
|
||||
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
|
||||
import {
|
||||
salesTaxColumnHint,
|
||||
storeOverviewHints,
|
||||
} from '#/utils/overview-table-hints';
|
||||
|
||||
defineOptions({ name: 'WorkbenchPlatformSummaryCard' });
|
||||
|
||||
interface Props {
|
||||
taxRate?: number;
|
||||
platformSummary?: CompanyOverviewVO.PlatformOverview;
|
||||
platformExportMode?: boolean;
|
||||
selectedExportPlatformIds?: number[];
|
||||
headingTitle?: string;
|
||||
headingSubtitle?: string;
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:selectedExportPlatformIds', ids: number[]): void;
|
||||
(e: 'togglePlatformExportMode', enabled: boolean): void;
|
||||
(e: 'export'): void;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
platformExportMode: false,
|
||||
selectedExportPlatformIds: () => [],
|
||||
headingTitle: '各平台多维度经营明细汇总',
|
||||
headingSubtitle: '目标达成 · 规模 · 成本费用 · 盈利分析,四大维度完整汇总',
|
||||
});
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const allPlatformsSelected = computed(() => {
|
||||
const total = platformData.value.length;
|
||||
return total > 0 && props.selectedExportPlatformIds.length === total;
|
||||
});
|
||||
const somePlatformsSelected = computed(() => {
|
||||
return props.selectedExportPlatformIds.length > 0;
|
||||
});
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
};
|
||||
|
||||
const cellMoney = (v: number | null | undefined) => formatNumberCell(v, formatAmount);
|
||||
const cellRoi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, (n) => n.toFixed(2));
|
||||
|
||||
const formatPercentPlain = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
const taxRateNum = computed(() => (props.taxRate ?? 0.04) * 100);
|
||||
|
||||
// 使用后端返回的平台列表数据
|
||||
const platformData = computed(() => {
|
||||
if (props.platformSummary?.platforms && props.platformSummary.platforms.length > 0) {
|
||||
return props.platformSummary.platforms.map(p => ({
|
||||
platformId: p.platformId,
|
||||
platformName: p.platformName,
|
||||
targetOrderCount: p.targetOrderCount ?? 0,
|
||||
orderCountAchievementRate: p.orderCountAchievementRate ?? 0,
|
||||
targetAmount: p.targetAmount ?? 0,
|
||||
salesAmountAchievementRate: p.salesAmountAchievementRate ?? 0,
|
||||
salesAmount: p.salesAmount ?? 0,
|
||||
orderCount: p.orderCount ?? 0,
|
||||
averageOrderValue: p.averageOrderValue ?? 0,
|
||||
productCost: p.productCost ?? 0,
|
||||
shippingCost: p.shippingCost ?? 0,
|
||||
otherCost: p.otherCost ?? 0,
|
||||
totalCost: p.totalCost ?? 0,
|
||||
refundAmount: p.refundAmount ?? 0,
|
||||
totalPromotionFee: p.totalPromotionFee ?? 0,
|
||||
brushFee: p.brushFee ?? 0,
|
||||
feeRatio: p.feeRatio ?? 0,
|
||||
totalProfitBeforeTax: p.totalProfitBeforeTax ?? 0,
|
||||
salesTaxAmount: p.salesTaxAmount ?? 0,
|
||||
roi: p.roi ?? 0,
|
||||
profitAfterTax: p.profitAfterTax ?? 0,
|
||||
}));
|
||||
}
|
||||
return [];
|
||||
});
|
||||
|
||||
// 后端返回的合计行数据
|
||||
const totalData = computed(() => props.platformSummary?.total ?? null);
|
||||
|
||||
// 表格排序
|
||||
const sortField = ref<string>('salesAmount');
|
||||
const sortOrder = ref<'asc' | 'desc'>('desc');
|
||||
|
||||
const sortedData = computed(() => {
|
||||
return [...platformData.value].sort((a: any, b: any) => {
|
||||
const diff = b[sortField.value] - a[sortField.value];
|
||||
return sortOrder.value === 'desc' ? diff : -diff;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</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]"
|
||||
>
|
||||
<!-- 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"
|
||||
>
|
||||
<div>
|
||||
<h3 class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
{{ props.headingTitle }}
|
||||
</h3>
|
||||
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ props.headingSubtitle }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<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%)]"
|
||||
@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"
|
||||
:disabled="selectedExportPlatformIds.length === 0"
|
||||
@click="emit('export')"
|
||||
>
|
||||
导出已选平台 ({{ selectedExportPlatformIds.length }})
|
||||
</button>
|
||||
</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%)]"
|
||||
@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"
|
||||
@click="emit('export')"
|
||||
>
|
||||
导出全部
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 表格 -->
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full whitespace-nowrap text-left text-sm">
|
||||
<thead
|
||||
class="bg-slate-50 dark:bg-[hsl(240deg_3.7%_15.9%)] text-xs font-black uppercase text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
<tr>
|
||||
<th
|
||||
v-if="platformExportMode"
|
||||
rowspan="2"
|
||||
class="border-b border-r-2 border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-r-[hsl(240deg_3.7%_22%)] bg-slate-100 p-3 text-center dark:bg-[hsl(240deg_3.7%_22%)]"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 cursor-pointer accent-blue-600"
|
||||
:checked="allPlatformsSelected"
|
||||
:indeterminate="somePlatformsSelected && !allPlatformsSelected"
|
||||
@change="
|
||||
(e) => {
|
||||
if ((e.target as HTMLInputElement).checked) {
|
||||
emit(
|
||||
'update:selectedExportPlatformIds',
|
||||
platformData.map((p) => p.platformId) || [],
|
||||
);
|
||||
} else {
|
||||
emit('update:selectedExportPlatformIds', []);
|
||||
}
|
||||
}
|
||||
"
|
||||
/>
|
||||
</th>
|
||||
<!-- 平台名著 -->
|
||||
<th
|
||||
rowspan="2"
|
||||
class="sticky-col border-b border-r-2 border-slate-100 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-r-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 text-base font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)] shadow-sm dark:shadow-none"
|
||||
>
|
||||
平台
|
||||
</th>
|
||||
<!-- 目标达成 -->
|
||||
<th
|
||||
colspan="4"
|
||||
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] p-3 text-center bg-blue-50/50 dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)] text-blue-700 dark:text-blue-400"
|
||||
>
|
||||
目标达成维度
|
||||
</th>
|
||||
<!-- 规模 -->
|
||||
<th
|
||||
colspan="3"
|
||||
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] p-3 text-center bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50%)]"
|
||||
>
|
||||
经营规模维度
|
||||
</th>
|
||||
<!-- 成本 -->
|
||||
<th
|
||||
colspan="8"
|
||||
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] p-3 text-center bg-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] text-orange-700 dark:text-orange-400"
|
||||
>
|
||||
成本费用维度
|
||||
</th>
|
||||
<!-- 盈利 -->
|
||||
<th
|
||||
colspan="5"
|
||||
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] p-3 text-center bg-emerald-50/50 dark:bg-[hsl(142deg_71.8%_29%/20%)] text-emerald-700 dark:text-emerald-400"
|
||||
>
|
||||
盈利分析维度
|
||||
</th>
|
||||
</tr>
|
||||
<tr class="bg-slate-50/80 dark:bg-[hsl(240deg_3.7%_15.9%/80)] text-sm">
|
||||
<!-- 目标子列 -->
|
||||
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.targetOrderCount">
|
||||
目标单量
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 text-blue-600 dark:text-blue-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.orderCountAchievementRate">
|
||||
单量达成率
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.targetAmount">目标额</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 text-blue-600 dark:text-blue-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.salesAmountAchievementRate">
|
||||
销售达成率
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<!-- 规模子列 -->
|
||||
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<OverviewColumnHint :title="storeOverviewHints.salesAmount">
|
||||
实际销售额
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.orderCount">单量</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.averageOrderValue">客单价</OverviewColumnHint>
|
||||
</th>
|
||||
<!-- 成本子列 -->
|
||||
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.productCost">商品成本</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.shippingCost">运费</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.otherCost">其他成本</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-bold text-orange-800 dark:text-orange-300">
|
||||
<OverviewColumnHint :title="storeOverviewHints.totalCost">总成本</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-bold text-rose-600 dark:text-rose-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.refundAmount">退款金额</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.totalPromotionFee">推广费</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 text-orange-600 dark:text-orange-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.brushFee">刷单费用</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
<OverviewColumnHint :title="storeOverviewHints.feeRatioPlatform">费比%</OverviewColumnHint>
|
||||
</th>
|
||||
<!-- 盈利子列 -->
|
||||
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4 font-bold">
|
||||
<OverviewColumnHint :title="storeOverviewHints.totalProfitBeforeTax">
|
||||
税前盈亏
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
<OverviewColumnHint :title="salesTaxColumnHint(taxRate ?? 0.04)">
|
||||
{{ taxRateNum.toFixed(0) }}%税额
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-indigo-700 dark:text-indigo-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.roi">ROI</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b bg-emerald-600 dark:bg-emerald-600 px-6 py-4 font-black text-white">
|
||||
<OverviewColumnHint light :title="storeOverviewHints.profitAfterTax">
|
||||
税后盈亏
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
||||
<tr
|
||||
v-for="p in sortedData"
|
||||
:key="p.platformId"
|
||||
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
||||
>
|
||||
<td
|
||||
v-if="platformExportMode"
|
||||
class="border-r border-slate-100 dark:border-r-[hsl(240deg_3.7%_22%)] bg-slate-50/50 dark:bg-[hsl(240deg_3.7%_22%/50%)] p-3 text-center"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 cursor-pointer accent-blue-600"
|
||||
:checked="selectedExportPlatformIds.includes(p.platformId)"
|
||||
@change="
|
||||
(e) => {
|
||||
const checked = (e.target as HTMLInputElement).checked;
|
||||
const newIds = checked
|
||||
? [...selectedExportPlatformIds, p.platformId]
|
||||
: selectedExportPlatformIds.filter((id) => id !== p.platformId);
|
||||
emit('update:selectedExportPlatformIds', newIds);
|
||||
}
|
||||
"
|
||||
/>
|
||||
</td>
|
||||
<!-- 平台名 -->
|
||||
<td
|
||||
class="sticky-col border-r-2 border-slate-100 dark:border-r-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 font-bold shadow-sm dark:shadow-none"
|
||||
>
|
||||
<span class="inline-block rounded-full bg-blue-50 dark:bg-blue-900/30 px-3 py-1 text-sm font-bold text-blue-600 dark:text-blue-400">
|
||||
{{ p.platformName }}
|
||||
</span>
|
||||
</td>
|
||||
<!-- 目标 -->
|
||||
<td class="p-6 font-medium">{{ p.targetOrderCount.toLocaleString('zh-CN') }}</td>
|
||||
<td class="p-6 font-black text-blue-600 dark:text-blue-400">{{ formatPercentPlain(p.orderCountAchievementRate) }}</td>
|
||||
<td class="p-6 font-medium">{{ formatAmount(p.targetAmount) }}</td>
|
||||
<td class="p-6 font-black text-blue-600 dark:text-blue-400">{{ formatPercentPlain(p.salesAmountAchievementRate) }}</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6 font-black">{{ formatAmount(p.salesAmount) }}</td>
|
||||
<td class="p-6 font-medium">{{ p.orderCount.toLocaleString('zh-CN') }}</td>
|
||||
<td class="p-6 font-medium">{{ formatAmount(p.averageOrderValue) }}</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ formatAmount(p.productCost) }}</td>
|
||||
<td class="p-6">{{ formatAmount(p.shippingCost) }}</td>
|
||||
<td class="p-6">{{ formatAmount(p.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ formatAmount(p.totalCost) }}</td>
|
||||
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">{{ formatAmount(p.refundAmount) }}</td>
|
||||
<td class="p-6">{{ formatAmount(p.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ formatAmount(p.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatFeeRatioPercent(p.feeRatio) }}</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6 font-bold" :class="p.totalProfitBeforeTax >= 0 ? 'text-slate-800 dark:text-[hsl(0deg_0%_95%)]' : 'text-rose-600 dark:text-rose-400'">
|
||||
{{ formatAmount(p.totalProfitBeforeTax) }}
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatAmount(p.salesTaxAmount) }}</td>
|
||||
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">{{ p.roi.toFixed(2) }}</td>
|
||||
<td
|
||||
class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-6 text-base font-black"
|
||||
:class="p.profitAfterTax >= 0 ? 'text-emerald-600' : 'text-rose-600'"
|
||||
>
|
||||
{{ formatAmount(p.profitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<!-- 合计行 -->
|
||||
<tfoot v-if="totalData" class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<td class="sticky-col border-r-2 border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] p-6 text-base">合计</td>
|
||||
<!-- 目标 -->
|
||||
<td class="p-6">{{ formatIntCell(totalData.targetOrderCount) }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{ totalData.orderCountAchievementRate !== undefined ? formatPercentPlain(totalData.orderCountAchievementRate) : '-' }}
|
||||
</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.targetAmount) }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{ totalData.salesAmountAchievementRate !== undefined ? formatPercentPlain(totalData.salesAmountAchievementRate) : '-' }}
|
||||
</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ cellMoney(totalData.salesAmount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(totalData.orderCount) }}</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(totalData.averageOrderValue) }}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ cellMoney(totalData.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(totalData.totalCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(totalData.refundAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(totalData.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ totalData.feeRatio !== undefined ? formatFeeRatioPercent(totalData.feeRatio) : '-' }}
|
||||
</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6">
|
||||
{{ cellMoney(totalData.totalProfitBeforeTax) }}
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cellMoney(totalData.salesTaxAmount) }}
|
||||
</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">
|
||||
{{ cellRoi(totalData.roi) }}
|
||||
</td>
|
||||
<td
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(totalData.profitAfterTax ?? 0) >= 0 ? 'text-emerald-700 dark:text-emerald-300' : 'text-rose-600 dark:text-rose-400'"
|
||||
>
|
||||
{{ cellMoney(totalData.profitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tfoot v-else class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||
<tr class="text-center text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
<td :colspan="platformExportMode ? 22 : 21" class="p-6">暂无数据</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+424
@@ -0,0 +1,424 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
|
||||
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||
|
||||
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
|
||||
import {
|
||||
salesTaxColumnHint,
|
||||
storeOverviewHints,
|
||||
} from '#/utils/overview-table-hints';
|
||||
|
||||
const JumpIcon = createIconifyIcon('tdesign:jump');
|
||||
|
||||
defineOptions({ name: 'WorkbenchShopComparisonTable' });
|
||||
|
||||
interface Props {
|
||||
shopSummary?: CompanyOverviewVO.ShopOverview;
|
||||
taxRate: number;
|
||||
shopExportMode: boolean;
|
||||
selectedExportShopIds: number[];
|
||||
/** 覆盖默认表头主标题(如工作台演示) */
|
||||
headingTitle?: string;
|
||||
/** 覆盖默认表头副标题 */
|
||||
headingSubtitle?: string;
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:selectedExportShopIds', ids: number[]): void;
|
||||
(e: 'toggleShopExportMode', enabled: boolean): void;
|
||||
(e: 'export'): void;
|
||||
(e: 'navigate', shopId: number): void;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
headingTitle: '各店铺多维度经营明细汇总',
|
||||
headingSubtitle: '包含:目标达成、规模、成本及最终损益所有维度',
|
||||
});
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const allShopsSelected = computed(() => {
|
||||
const total = props.shopSummary?.shops?.length || 0;
|
||||
return total > 0 && props.selectedExportShopIds.length === total;
|
||||
});
|
||||
const someShopsSelected = computed(() => {
|
||||
return props.selectedExportShopIds.length > 0;
|
||||
});
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
};
|
||||
|
||||
const formatPercentPlain = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
const cellMoney = (v: number | null | undefined) => formatNumberCell(v, formatAmount);
|
||||
const cellRoi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, (n) => n.toFixed(2));
|
||||
</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="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"
|
||||
>
|
||||
<div>
|
||||
<h3 class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
{{ props.headingTitle }}
|
||||
</h3>
|
||||
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ props.headingSubtitle }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<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%)]"
|
||||
@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"
|
||||
:disabled="selectedExportShopIds.length === 0"
|
||||
@click="emit('export')"
|
||||
>
|
||||
导出已选店铺 ({{ selectedExportShopIds.length }})
|
||||
</button>
|
||||
</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%)]"
|
||||
@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"
|
||||
@click="emit('export')"
|
||||
>
|
||||
导出全部
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-container overflow-x-auto">
|
||||
<table class="w-full whitespace-nowrap text-left text-sm">
|
||||
<thead
|
||||
class="bg-slate-50 dark:bg-[hsl(240deg_3.7%_15.9%)] text-xs font-black uppercase text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
<tr>
|
||||
<th
|
||||
v-if="shopExportMode"
|
||||
rowspan="2"
|
||||
class="sticky-col border-b border-r-2 border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] p-3 text-center"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 cursor-pointer accent-blue-600"
|
||||
:checked="allShopsSelected"
|
||||
:indeterminate="someShopsSelected && !allShopsSelected"
|
||||
@change="
|
||||
(e) => {
|
||||
if ((e.target as HTMLInputElement).checked) {
|
||||
emit(
|
||||
'update:selectedExportShopIds',
|
||||
shopSummary?.shops?.map((s) => s.shopId) || [],
|
||||
);
|
||||
} else {
|
||||
emit('update:selectedExportShopIds', []);
|
||||
}
|
||||
}
|
||||
"
|
||||
/>
|
||||
</th>
|
||||
<th
|
||||
rowspan="2"
|
||||
class="sticky-col border-b p-6 text-base font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)] shadow-sm"
|
||||
:class="
|
||||
shopExportMode
|
||||
? 'border-l-0 bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)]'
|
||||
: 'border-r-2 border-slate-100 dark:border-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)]'
|
||||
"
|
||||
>
|
||||
店铺
|
||||
</th>
|
||||
<th
|
||||
colspan="4"
|
||||
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] dark:border-[hsl(240deg_3.7%_22%)] bg-blue-50/50 dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)] p-3 text-center text-blue-700 dark:text-blue-400"
|
||||
>
|
||||
目标达成维度
|
||||
</th>
|
||||
<th
|
||||
colspan="3"
|
||||
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100/50 dark:bg-[hsl(240deg_3.7%_22%/50%)] p-3 text-center"
|
||||
>
|
||||
经营规模维度
|
||||
</th>
|
||||
<th
|
||||
colspan="8"
|
||||
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] dark:border-[hsl(240deg_3.7%_22%)] bg-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] p-3 text-center text-orange-700 dark:text-orange-400"
|
||||
>
|
||||
成本费用维度
|
||||
</th>
|
||||
<th
|
||||
colspan="5"
|
||||
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] dark:border-[hsl(240deg_3.7%_22%)] bg-emerald-50/50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-3 text-center text-emerald-700 dark:text-emerald-400"
|
||||
>
|
||||
盈利分析维度
|
||||
</th>
|
||||
</tr>
|
||||
<tr class="bg-slate-50/80 dark:bg-[hsl(240deg_3.7%_15.9%/80)] text-sm">
|
||||
<!-- 目标 -->
|
||||
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.targetOrderCount">
|
||||
目标单量
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 text-blue-600 dark:text-blue-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.orderCountAchievementRate">
|
||||
单量达成率
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.targetAmount">目标额</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 text-blue-600 dark:text-blue-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.salesAmountAchievementRate">
|
||||
销售达成率
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<!-- 规模 -->
|
||||
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<OverviewColumnHint :title="storeOverviewHints.salesAmount">
|
||||
实际销售额
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.orderCount">单量</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.averageOrderValue">客单价</OverviewColumnHint>
|
||||
</th>
|
||||
<!-- 成本 -->
|
||||
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.productCost">商品成本</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.shippingCost">运费</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.otherCost">其他成本</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 font-bold text-orange-800 dark:text-orange-300">
|
||||
<OverviewColumnHint :title="storeOverviewHints.totalCost">总成本</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 font-bold text-rose-600 dark:text-rose-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.refundAmount">退款金额</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">
|
||||
<OverviewColumnHint :title="storeOverviewHints.totalPromotionFee">推广费</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 text-orange-600 dark:text-orange-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.brushFee">刷单费用</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
<OverviewColumnHint :title="storeOverviewHints.feeRatioShopRow">费比%</OverviewColumnHint>
|
||||
</th>
|
||||
<!-- 盈利 -->
|
||||
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4 font-bold">
|
||||
<OverviewColumnHint :title="storeOverviewHints.totalProfitBeforeTax">
|
||||
税前盈亏
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 italic text-rose-500 dark:text-rose-400">
|
||||
<OverviewColumnHint :title="salesTaxColumnHint(taxRate)">
|
||||
{{ (taxRate * 100).toFixed(0) }}%税额
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 font-black text-indigo-700 dark:text-indigo-400">
|
||||
<OverviewColumnHint :title="storeOverviewHints.roi">ROI</OverviewColumnHint>
|
||||
</th>
|
||||
<th class="border-b bg-emerald-600 dark:bg-emerald-600 px-6 py-4 font-black text-white">
|
||||
<OverviewColumnHint light :title="storeOverviewHints.profitAfterTax">
|
||||
税后盈亏
|
||||
</OverviewColumnHint>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100 dark:divide-[hsl(240deg_3.7%_22%)]">
|
||||
<tr
|
||||
v-for="shop in (shopSummary?.shops || [])"
|
||||
:key="shop.shopId"
|
||||
class="transition-colors hover:bg-blue-50/50 dark:hover:bg-[hsl(217.2deg_32.6%_17.5%/30%)] dark:bg-[hsl(217.2deg_32.6%_17.5%/50%)]"
|
||||
>
|
||||
<td
|
||||
v-if="shopExportMode"
|
||||
class="sticky-col border-r border-slate-100 dark:border-r-[hsl(240deg_3.7%_22%)] bg-slate-50/50 dark:bg-[hsl(240deg_3.7%_22%/50%)] p-3 text-center"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:value="shop.shopId"
|
||||
class="h-4 w-4 cursor-pointer accent-blue-600"
|
||||
@change="
|
||||
(e) => {
|
||||
const checked = (e.target as HTMLInputElement).checked;
|
||||
const newIds = checked
|
||||
? [...selectedExportShopIds, shop.shopId]
|
||||
: selectedExportShopIds.filter((id) => id !== shop.shopId);
|
||||
emit('update:selectedExportShopIds', newIds);
|
||||
}
|
||||
"
|
||||
/>
|
||||
</td>
|
||||
<td
|
||||
class="sticky-col border-r-2 border-slate-100 dark:border-r-[hsl(240deg_3.7%_22%)] bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 font-bold shadow-sm dark:shadow-none"
|
||||
:class="shopExportMode ? 'border-l-0' : ''"
|
||||
>
|
||||
<span
|
||||
class="inline-flex cursor-pointer items-center gap-1 rounded-full bg-blue-50 dark:bg-blue-900/30 px-3 py-1 text-sm font-bold text-blue-600 dark:text-blue-400 transition-colors hover:text-blue-300 hover:underline"
|
||||
@click="emit('navigate', shop.shopId)"
|
||||
>
|
||||
{{ shop.shopName }}
|
||||
<JumpIcon class="text-xs" />
|
||||
</span>
|
||||
</td>
|
||||
<!-- 目标 -->
|
||||
<td class="p-6 font-medium">
|
||||
{{ formatIntCell(shop.targetOrderCount) }}
|
||||
</td>
|
||||
<td class="p-6 font-black text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
shop.orderCountAchievementRate !== undefined
|
||||
? formatPercentPlain(shop.orderCountAchievementRate)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{ cellMoney(shop.targetAmount) }}
|
||||
</td>
|
||||
<td class="p-6 font-black text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
shop.salesAmountAchievementRate !== undefined
|
||||
? formatPercentPlain(shop.salesAmountAchievementRate)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6 font-black">
|
||||
{{ formatAmount(shop.salesAmount) }}
|
||||
</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{ formatIntCell(shop.orderCount) }}
|
||||
</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{ cellMoney(shop.averageOrderValue) }}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">
|
||||
{{ cellMoney(shop.productCost) }}
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(shop.shippingCost) }}
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(shop.otherCost) }}
|
||||
</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">
|
||||
{{ cellMoney(shop.totalCost) }}
|
||||
</td>
|
||||
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">
|
||||
{{ cellMoney(shop.refundAmount) }}
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(shop.totalPromotionFee) }}
|
||||
</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">
|
||||
{{ cellMoney(shop.brushFee) }}
|
||||
</td>
|
||||
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{
|
||||
shop.feeRatio !== undefined
|
||||
? formatFeeRatioPercent(shop.feeRatio)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6 font-bold">
|
||||
{{ cellMoney(shop.totalProfitBeforeTax) }}
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cellMoney(shop.salesTaxAmount) }}
|
||||
</td>
|
||||
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">
|
||||
{{ cellRoi(shop.roi) }}
|
||||
</td>
|
||||
<td class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-6 text-base font-black text-emerald-600">
|
||||
{{ cellMoney(shop.profitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!shopSummary?.shops?.length">
|
||||
<td :colspan="shopExportMode ? 22 : 21" class="p-8 text-center text-gray-400">
|
||||
暂无数据
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<!-- 合计行 -->
|
||||
<tfoot v-if="shopSummary?.total" class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<td class="p-6 text-base" :class="shopExportMode ? 'border-l-0' : ''">合计</td>
|
||||
<!-- 目标 -->
|
||||
<td class="p-6">{{ formatIntCell(shopSummary?.total?.targetOrderCount) }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
shopSummary?.total?.orderCountAchievementRate !== undefined
|
||||
? formatPercentPlain(shopSummary?.total?.orderCountAchievementRate)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.targetAmount) }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
shopSummary?.total?.salesAmountAchievementRate !== undefined
|
||||
? formatPercentPlain(shopSummary?.total?.salesAmountAchievementRate)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.salesAmount) }}</td>
|
||||
<td class="p-6">{{ formatIntCell(shopSummary?.total?.orderCount) }}</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(shopSummary?.total?.averageOrderValue) }}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(shopSummary?.total?.totalCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(shopSummary?.total?.refundAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(shopSummary?.total?.brushFee) }}</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ shopSummary?.total?.feeRatio !== undefined ? formatFeeRatioPercent(shopSummary?.total?.feeRatio) : '-' }}</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.totalProfitBeforeTax) }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(shopSummary?.total?.salesTaxAmount) }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ cellRoi(shopSummary?.total?.roi) }}</td>
|
||||
<td
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(shopSummary?.total?.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-700 dark:text-emerald-300'"
|
||||
>{{ cellMoney(shopSummary?.total?.profitAfterTax) }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user