mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 05:49:20 +08:00
feat(ecom-dmb): 新增平台维度汇总功能
后端: - CompanyOverviewVO 新增 platformSummary 平台维度汇总数据 - CompanyOverviewServiceImpl 新增 calculatePlatformSummary() 方法,按平台聚合数据 - PlatformExportDTO 导出参数 DTO - ExportService/ExportServiceImpl 新增 exportPlatformOverview 导出方法 - ExportController 新增 POST /ec/platform-overview/export 接口 前端: - PlatformSummaryCard 组件显示各平台多维度经营明细对比 - 支持指定平台导出和导出全部两种模式 - 组件优先使用动态数据,无数据时降级到 mock 数据 - types.vo.ts 新增 PlatformSummary 类型定义 - index.vue 集成平台导出功能
This commit is contained in:
+405
@@ -0,0 +1,405 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import type { CompanyOverviewVO } from '#/api/ecommerce/company-overview';
|
||||
|
||||
defineOptions({ name: 'PlatformSummaryCard' });
|
||||
|
||||
interface Props {
|
||||
taxRate?: number;
|
||||
platformSummary?: CompanyOverviewVO.PlatformSummary[];
|
||||
platformExportMode?: boolean;
|
||||
selectedExportPlatformIds?: number[];
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:selectedExportPlatformIds', ids: number[]): void;
|
||||
(e: 'togglePlatformExportMode', enabled: boolean): void;
|
||||
(e: 'export'): void;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
platformExportMode: false,
|
||||
selectedExportPlatformIds: () => [],
|
||||
});
|
||||
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 mockPlatformData = [
|
||||
{
|
||||
platformId: 1, platformName: '淘宝',
|
||||
targetOrderCount: 5000, orderCountAchievementRate: 90.4,
|
||||
targetAmount: 320000, salesAmountAchievementRate: 88.6,
|
||||
salesAmount: 283600, orderCount: 4521, averageOrderValue: 62.7,
|
||||
productCost: 156000, shippingCost: 8500, otherCost: 3200,
|
||||
refundAmount: 12600, totalPromotionFee: 9800, brushFee: 4200,
|
||||
feeRatio: 18.7,
|
||||
totalProfitBeforeTax: 98600, salesTaxAmount: 11344, roi: 2.34, profitAfterTax: 87256,
|
||||
},
|
||||
{
|
||||
platformId: 2, platformName: '京东',
|
||||
targetOrderCount: 3500, orderCountAchievementRate: 93.7,
|
||||
targetAmount: 210000, salesAmountAchievementRate: 93.7,
|
||||
salesAmount: 196800, orderCount: 3280, averageOrderValue: 60.0,
|
||||
productCost: 108000, shippingCost: 6200, otherCost: 1800,
|
||||
refundAmount: 8900, totalPromotionFee: 6800, brushFee: 2100,
|
||||
feeRatio: 17.6,
|
||||
totalProfitBeforeTax: 71000, salesTaxAmount: 7872, roi: 2.61, profitAfterTax: 63128,
|
||||
},
|
||||
{
|
||||
platformId: 3, platformName: '拼多多',
|
||||
targetOrderCount: 6500, orderCountAchievementRate: 90.6,
|
||||
targetAmount: 170000, salesAmountAchievementRate: 90.7,
|
||||
salesAmount: 154200, orderCount: 5890, averageOrderValue: 26.2,
|
||||
productCost: 92400, shippingCost: 11800, otherCost: 2200,
|
||||
refundAmount: 18200, totalPromotionFee: 5600, brushFee: 3800,
|
||||
feeRatio: 25.9,
|
||||
totalProfitBeforeTax: 22200, salesTaxAmount: 6168, roi: 0.76, profitAfterTax: 16032,
|
||||
},
|
||||
{
|
||||
platformId: 4, platformName: '抖音',
|
||||
targetOrderCount: 2200, orderCountAchievementRate: 95.5,
|
||||
targetAmount: 60000, salesAmountAchievementRate: 103.3,
|
||||
salesAmount: 62000, orderCount: 2100, averageOrderValue: 29.5,
|
||||
productCost: 34100, shippingCost: 4200, otherCost: 1500,
|
||||
refundAmount: 3100, totalPromotionFee: 3200, brushFee: 0,
|
||||
feeRatio: 19.7,
|
||||
totalProfitBeforeTax: 15900, salesTaxAmount: 2480, roi: 2.12, profitAfterTax: 13420,
|
||||
},
|
||||
{
|
||||
platformId: 5, platformName: '天猫',
|
||||
targetOrderCount: 700, orderCountAchievementRate: 97.1,
|
||||
targetAmount: 36000, salesAmountAchievementRate: 98.3,
|
||||
salesAmount: 35400, orderCount: 680, averageOrderValue: 52.1,
|
||||
productCost: 19400, shippingCost: 680, otherCost: 560,
|
||||
refundAmount: 1100, totalPromotionFee: 1800, brushFee: 0,
|
||||
feeRatio: 11.5,
|
||||
totalProfitBeforeTax: 12860, salesTaxAmount: 1416, roi: 3.89, profitAfterTax: 11444,
|
||||
},
|
||||
{
|
||||
platformId: 6, platformName: '快手',
|
||||
targetOrderCount: 600, orderCountAchievementRate: 86.7,
|
||||
targetAmount: 15000, salesAmountAchievementRate: 85.3,
|
||||
salesAmount: 12800, orderCount: 520, averageOrderValue: 24.6,
|
||||
productCost: 7680, shippingCost: 1040, otherCost: 280,
|
||||
refundAmount: 620, totalPromotionFee: 960, brushFee: 0,
|
||||
feeRatio: 19.5,
|
||||
totalProfitBeforeTax: 2220, salesTaxAmount: 512, roi: 1.52, profitAfterTax: 1708,
|
||||
},
|
||||
];
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN')}`;
|
||||
};
|
||||
|
||||
const formatPercentPlain = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
const taxRateNum = computed(() => (props.taxRate ?? 0.04) * 100);
|
||||
|
||||
// 优先使用动态数据,否则降级到静态mock
|
||||
const platformData = computed(() => {
|
||||
if (props.platformSummary && props.platformSummary.length > 0) {
|
||||
return props.platformSummary.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,
|
||||
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 mockPlatformData;
|
||||
});
|
||||
|
||||
const totalSales = computed(() => platformData.value.reduce((sum, p) => sum + p.salesAmount, 0));
|
||||
const totalOrderCount = computed(() => platformData.value.reduce((sum, p) => sum + p.orderCount, 0));
|
||||
const totalProfitAfterTax = computed(() => platformData.value.reduce((sum, p) => sum + p.profitAfterTax, 0));
|
||||
|
||||
// 表格排序
|
||||
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;
|
||||
});
|
||||
});
|
||||
|
||||
const toggleSort = (field: string) => {
|
||||
if (sortField.value === field) {
|
||||
sortOrder.value = sortOrder.value === 'desc' ? 'asc' : 'desc';
|
||||
} else {
|
||||
sortField.value = field;
|
||||
sortOrder.value = 'desc';
|
||||
}
|
||||
};
|
||||
|
||||
const sortIcon = (field: string) => {
|
||||
if (sortField.value !== field) return '';
|
||||
return sortOrder.value === 'desc' ? '↓' : '↑';
|
||||
};
|
||||
</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%)]">
|
||||
各平台多维度经营明细对比
|
||||
</h3>
|
||||
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
目标达成 · 规模 · 成本费用 · 盈利分析,四大维度完整对比
|
||||
</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="7"
|
||||
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-b-[hsl(240deg_3.7%_22%)] px-6 py-4">目标单量</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">单量达成率</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">目标额</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">销售达成率</th>
|
||||
<!-- 规模子列 -->
|
||||
<th class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">实际销售额</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">单量</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">客单价</th>
|
||||
<!-- 成本子列 -->
|
||||
<th class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">商品成本</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">运费</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">其他成本</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">退款金额</th>
|
||||
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">推广费</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">刷单费用</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%)]">费比%</th>
|
||||
<!-- 盈利子列 -->
|
||||
<th class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-bold">税前盈亏</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%)]">{{ taxRateNum.toFixed(0) }}%税额</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">ROI</th>
|
||||
<th class="border-b bg-emerald-600 dark:bg-emerald-600 px-6 py-4 font-black text-white">税后盈亏</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
|
||||
class="sticky-col border-r-2 border-slate-100 bg-white dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 font-bold shadow-sm dark:shadow-none"
|
||||
>
|
||||
<span class="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-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%)]">{{ formatPercentPlain(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 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">{{ platformData.reduce((s, p) => s + p.targetOrderCount, 0).toLocaleString() }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">-</td>
|
||||
<td class="p-6">{{ formatAmount(platformData.reduce((s, p) => s + p.targetAmount, 0)) }}</td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">-</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ formatAmount(totalSales) }}</td>
|
||||
<td class="p-6">{{ totalOrderCount.toLocaleString() }}</td>
|
||||
<td class="p-6">-</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ formatAmount(platformData.reduce((s, p) => s + p.productCost, 0)) }}</td>
|
||||
<td class="p-6">{{ formatAmount(platformData.reduce((s, p) => s + p.shippingCost, 0)) }}</td>
|
||||
<td class="p-6">{{ formatAmount(platformData.reduce((s, p) => s + p.otherCost, 0)) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ formatAmount(platformData.reduce((s, p) => s + p.refundAmount, 0)) }}</td>
|
||||
<td class="p-6">{{ formatAmount(platformData.reduce((s, p) => s + p.totalPromotionFee, 0)) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ formatAmount(platformData.reduce((s, p) => s + p.brushFee, 0)) }}</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ formatPercentPlain(
|
||||
totalSales > 0
|
||||
? platformData.reduce((s, p) => s + p.productCost + p.shippingCost + p.otherCost + p.refundAmount + p.totalPromotionFee + p.brushFee, 0) / totalSales * 100
|
||||
: 0,
|
||||
) }}
|
||||
</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6">
|
||||
{{ formatAmount(platformData.reduce((s, p) => s + p.totalProfitBeforeTax, 0)) }}
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ formatAmount(platformData.reduce((s, p) => s + p.salesTaxAmount, 0)) }}
|
||||
</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">
|
||||
{{
|
||||
(() => {
|
||||
const totalProfit = platformData.reduce((s, p) => s + p.totalProfitBeforeTax, 0);
|
||||
const totalCost = platformData.reduce((s, p) => s + p.productCost + p.shippingCost + p.otherCost + p.refundAmount + p.totalPromotionFee + p.brushFee, 0);
|
||||
return totalCost > 0 ? (totalProfit / totalCost).toFixed(2) : '-';
|
||||
})()
|
||||
}}
|
||||
</td>
|
||||
<td class="bg-emerald-100 dark:bg-emerald-900/30 p-6 text-base">
|
||||
{{ formatAmount(totalProfitAfterTax) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -26,6 +26,7 @@ import { exportByPost } from '#/utils/export';
|
||||
import CategoryComparisonTable from './components/CategoryComparisonTable.vue';
|
||||
import KpiCards from './components/KpiCards.vue';
|
||||
import ShopCharts from './components/ShopCharts.vue';
|
||||
import PlatformSummaryCard from './components/PlatformSummaryCard.vue';
|
||||
import ShopComparisonTable from './components/ShopComparisonTable.vue';
|
||||
|
||||
defineOptions({ name: 'CompanyOverview' });
|
||||
@@ -44,6 +45,10 @@ const shopCount = ref(0);
|
||||
const shopExportMode = ref(false);
|
||||
const selectedExportShopIds = ref<number[]>([]);
|
||||
|
||||
// 指定平台导出模式
|
||||
const platformExportMode = ref(false);
|
||||
const selectedExportPlatformIds = ref<number[]>([]);
|
||||
|
||||
// 日期范围
|
||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||
dayjs().subtract(30, 'day'),
|
||||
@@ -406,6 +411,40 @@ const toggleShopExportMode = (enabled: boolean) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 切换平台导出模式
|
||||
const togglePlatformExportMode = (enabled: boolean) => {
|
||||
platformExportMode.value = enabled;
|
||||
if (!enabled) {
|
||||
selectedExportPlatformIds.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
// 导出平台维度汇总
|
||||
const handlePlatformExport = async () => {
|
||||
try {
|
||||
exportLoading.value = true;
|
||||
const [startDate, endDate] = dateRange.value;
|
||||
const filename = `平台维度汇总_${startDate.format('YYYYMMDD')}_${endDate.format('YYYYMMDD')}.xlsx`;
|
||||
await exportByPost(
|
||||
'/ec/platform-overview/export',
|
||||
{
|
||||
dateRange: [
|
||||
startDate.format('YYYY-MM-DD'),
|
||||
endDate.format('YYYY-MM-DD'),
|
||||
],
|
||||
platformIds: selectedExportPlatformIds.value.length > 0
|
||||
? selectedExportPlatformIds.value
|
||||
: undefined,
|
||||
taxRate: taxRate.value,
|
||||
},
|
||||
filename,
|
||||
);
|
||||
platformExportMode.value = false;
|
||||
} finally {
|
||||
exportLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 跳转到店铺详情页
|
||||
const navigateToShopOverview = (shopId: number) => {
|
||||
router.push({
|
||||
@@ -539,7 +578,18 @@ const navigateToShopOverview = (shopId: number) => {
|
||||
:shop-efficiency-quadrants="overviewData?.shopEfficiencyQuadrants"
|
||||
/>
|
||||
|
||||
<!-- 第三层:横向对比大表 -->
|
||||
<!-- 第三层:平台维度汇总 -->
|
||||
<PlatformSummaryCard
|
||||
:platform-summary="overviewData?.platformSummary"
|
||||
:tax-rate="taxRate"
|
||||
:platform-export-mode="platformExportMode"
|
||||
:selected-export-platform-ids="selectedExportPlatformIds"
|
||||
@update:selected-export-platform-ids="(ids) => (selectedExportPlatformIds = ids)"
|
||||
@toggle-platform-export-mode="togglePlatformExportMode"
|
||||
@export="handlePlatformExport"
|
||||
/>
|
||||
|
||||
<!-- 第四层:横向对比大表 -->
|
||||
<ShopComparisonTable
|
||||
:shop-comparisons="overviewData?.shopComparisons"
|
||||
:tax-rate="taxRate"
|
||||
@@ -551,7 +601,7 @@ const navigateToShopOverview = (shopId: number) => {
|
||||
@navigate="navigateToShopOverview"
|
||||
/>
|
||||
|
||||
<!-- 第四层:品类多维度经营明细对比 -->
|
||||
<!-- 第五层:品类多维度经营明细对比 -->
|
||||
<CategoryComparisonTable
|
||||
:category-comparisons="overviewData?.categoryComparisons"
|
||||
:tax-rate="taxRate"
|
||||
|
||||
Reference in New Issue
Block a user