mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 01:49:19 +08:00
refactor(ecom-dmb): 平台维度概览改为对象结构(含合计行)并优化订单排序配置
This commit is contained in:
+10
-2
@@ -27,8 +27,8 @@ export namespace CompanyOverviewVO {
|
||||
shopComparisons?: ShopComparison[];
|
||||
/** 多品类数据横向对比 */
|
||||
categoryComparisons?: CategoryComparison[];
|
||||
/** 平台维度汇总 */
|
||||
platformSummary?: PlatformSummary[];
|
||||
/** 平台维度概览(包含合计行和平台列表) */
|
||||
platformSummary?: PlatformOverview;
|
||||
/** 汇总ROI */
|
||||
totalROI?: number;
|
||||
/** 总税后盈亏 */
|
||||
@@ -194,4 +194,12 @@ export namespace CompanyOverviewVO {
|
||||
/** 税后盈亏 */
|
||||
profitAfterTax?: number;
|
||||
}
|
||||
|
||||
/** 平台维度概览 */
|
||||
export interface PlatformOverview {
|
||||
/** 合计行 */
|
||||
total: PlatformSummary;
|
||||
/** 各平台汇总列表 */
|
||||
platforms: PlatformSummary[];
|
||||
}
|
||||
}
|
||||
|
||||
+31
-99
@@ -6,7 +6,7 @@ defineOptions({ name: 'PlatformSummaryCard' });
|
||||
|
||||
interface Props {
|
||||
taxRate?: number;
|
||||
platformSummary?: CompanyOverviewVO.PlatformSummary[];
|
||||
platformSummary?: CompanyOverviewVO.PlatformOverview;
|
||||
platformExportMode?: boolean;
|
||||
selectedExportPlatformIds?: number[];
|
||||
}
|
||||
@@ -31,70 +31,6 @@ 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')}`;
|
||||
};
|
||||
@@ -106,10 +42,10 @@ const formatPercentPlain = (value: number | undefined) => {
|
||||
|
||||
const taxRateNum = computed(() => (props.taxRate ?? 0.04) * 100);
|
||||
|
||||
// 优先使用动态数据,否则降级到静态mock
|
||||
// 使用后端返回的平台列表数据
|
||||
const platformData = computed(() => {
|
||||
if (props.platformSummary && props.platformSummary.length > 0) {
|
||||
return props.platformSummary.map(p => ({
|
||||
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,
|
||||
@@ -132,12 +68,11 @@ const platformData = computed(() => {
|
||||
profitAfterTax: p.profitAfterTax ?? 0,
|
||||
}));
|
||||
}
|
||||
return mockPlatformData;
|
||||
return [];
|
||||
});
|
||||
|
||||
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 totalData = computed(() => props.platformSummary?.total ?? null);
|
||||
|
||||
// 表格排序
|
||||
const sortField = ref<string>('salesAmount');
|
||||
@@ -352,53 +287,50 @@ const sortIcon = (field: string) => {
|
||||
</tr>
|
||||
</tbody>
|
||||
<!-- 合计行 -->
|
||||
<tfoot class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
|
||||
<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">{{ platformData.reduce((s, p) => s + p.targetOrderCount, 0).toLocaleString() }}</td>
|
||||
<td class="p-6">{{ totalData.targetOrderCount?.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">{{ formatAmount(totalData.targetAmount) }}</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">{{ formatAmount(totalData.salesAmount) }}</td>
|
||||
<td class="p-6">{{ totalData.orderCount?.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">{{ formatAmount(totalData.productCost) }}</td>
|
||||
<td class="p-6">{{ formatAmount(totalData.shippingCost) }}</td>
|
||||
<td class="p-6">{{ formatAmount(totalData.otherCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ formatAmount(totalData.refundAmount) }}</td>
|
||||
<td class="p-6">{{ formatAmount(totalData.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ formatAmount(totalData.brushFee) }}</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,
|
||||
) }}
|
||||
{{ formatPercentPlain(totalData.feeRatio) }}
|
||||
</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6">
|
||||
{{ formatAmount(platformData.reduce((s, p) => s + p.totalProfitBeforeTax, 0)) }}
|
||||
{{ formatAmount(totalData.totalProfitBeforeTax) }}
|
||||
</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)) }}
|
||||
{{ formatAmount(totalData.salesTaxAmount) }}
|
||||
</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) : '-';
|
||||
})()
|
||||
}}
|
||||
{{ totalData.roi?.toFixed(2) }}
|
||||
</td>
|
||||
<td class="bg-emerald-100 dark:bg-emerald-900/30 p-6 text-base">
|
||||
{{ formatAmount(totalProfitAfterTax) }}
|
||||
<td class="bg-emerald-100 dark:bg-emerald-900/30 p-6 text-base"
|
||||
:class="totalData.profitAfterTax >= 0 ? 'text-emerald-600' : 'text-rose-600'"
|
||||
>
|
||||
{{ formatAmount(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="19" class="p-6">暂无数据</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,6 @@ import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
Button,
|
||||
DatePicker,
|
||||
message,
|
||||
Popconfirm,
|
||||
Popover,
|
||||
|
||||
Reference in New Issue
Block a user