mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:59:19 +08:00
refactor: 拆分公司概览页为独立组件
- KpiCards.vue: 4个KPI指标卡片 - ShopCharts.vue: 销售占比排行+效率象限图 - ShopComparisonTable.vue: 店铺多维度经营明细对比表 - CategoryComparisonTable.vue: 品类多维度经营明细对比表 - index.vue: 仅保留数据层/筛选逻辑/模板组合,1427行→561行 - 修复 ShopComparisonTable 中 v-model 用于 prop 的报错
This commit is contained in:
+153
@@ -0,0 +1,153 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CompanyOverviewVO } from '#/api/ecommerce/company-overview';
|
||||
|
||||
defineOptions({ name: 'CategoryComparisonTable' });
|
||||
|
||||
interface Props {
|
||||
categoryComparisons?: CompanyOverviewVO.CategoryComparison[];
|
||||
taxRate: number;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN')}`;
|
||||
};
|
||||
|
||||
const formatPercentPlain = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value.toFixed(1)}%`;
|
||||
};
|
||||
</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%)]">
|
||||
各品类多维度经营明细对比
|
||||
</h3>
|
||||
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
包含:规模、成本及最终损益所有维度
|
||||
</p>
|
||||
</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
|
||||
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"
|
||||
>
|
||||
品类名称
|
||||
</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="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%)] 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%)]">
|
||||
实际销售额
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">单量</th>
|
||||
<th class="border-b px-6 py-4">客单价</th>
|
||||
<th class="border-b border-l px-6 py-4">商品成本</th>
|
||||
<th class="border-b px-6 py-4">运费</th>
|
||||
<th class="border-b px-6 py-4">其他成本</th>
|
||||
<th class="border-b px-6 py-4 font-bold text-rose-600 dark:text-rose-400">
|
||||
退款金额
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">推广费</th>
|
||||
<th class="border-b px-6 py-4 text-orange-600 dark:text-orange-400">刷单费用</th>
|
||||
<th class="border-b px-6 py-4 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">费比 %</th>
|
||||
<th class="border-b border-l px-6 py-4 font-bold">
|
||||
税前盈亏
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 italic text-rose-500 dark:text-rose-400">
|
||||
{{ (taxRate * 100).toFixed(0) }}%税额
|
||||
</th>
|
||||
<th class="border-b 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="cat in categoryComparisons"
|
||||
: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 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="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">{{ cat.orderCount?.toLocaleString('zh-CN') || '-' }}</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{
|
||||
cat.averageOrderValue ? formatAmount(cat.averageOrderValue) : '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6">{{ cat.productCost ? formatAmount(cat.productCost) : '-' }}</td>
|
||||
<td class="p-6">{{ cat.shippingCost ? formatAmount(cat.shippingCost) : '-' }}</td>
|
||||
<td class="p-6">{{ cat.otherCost ? formatAmount(cat.otherCost) : '-' }}</td>
|
||||
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">
|
||||
{{ cat.refundAmount ? formatAmount(cat.refundAmount) : '-' }}
|
||||
</td>
|
||||
<td class="p-6">{{ cat.totalPromotionFee ? formatAmount(cat.totalPromotionFee) : '-' }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">
|
||||
{{ cat.brushFee ? formatAmount(cat.brushFee) : '-' }}
|
||||
</td>
|
||||
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cat.feeRatio !== undefined ? formatPercentPlain(cat.feeRatio) : '-' }}
|
||||
</td>
|
||||
<td class="p-6 font-bold">
|
||||
{{ cat.totalProfitBeforeTax ? formatAmount(cat.totalProfitBeforeTax) : '-' }}
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cat.salesTaxAmount ? formatAmount(cat.salesTaxAmount) : '-' }}
|
||||
</td>
|
||||
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">
|
||||
{{ cat.roi?.toFixed(2) || '-' }}
|
||||
</td>
|
||||
<td class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-6 text-base font-black text-emerald-600">
|
||||
{{ cat.profitAfterTax ? formatAmount(cat.profitAfterTax) : '-' }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!categoryComparisons?.length">
|
||||
<td colspan="14" class="p-8 text-center text-gray-400">
|
||||
暂无数据
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CompanyOverviewVO } from '#/api/ecommerce/company-overview';
|
||||
|
||||
defineOptions({ name: 'KpiCards' });
|
||||
|
||||
interface Props {
|
||||
overviewData: CompanyOverviewVO.Info | null;
|
||||
taxRate: number;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN')}`;
|
||||
};
|
||||
|
||||
const formatPercent = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value > 0 ? '+' : ''}${value.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
const formatPercentPlain = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value.toFixed(1)}%`;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 xl:grid-cols-4">
|
||||
<!-- 销售额 -->
|
||||
<div
|
||||
class="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%)] p-6 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]"
|
||||
>
|
||||
<div class="mb-4 flex items-start justify-between">
|
||||
<span class="text-xs font-black text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
全店总销售额
|
||||
</span>
|
||||
<span
|
||||
v-if="overviewData?.monthOverMonthGrowth !== undefined"
|
||||
class="rounded bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%/20%)] px-2 py-1 text-xs font-bold text-emerald-600"
|
||||
>
|
||||
{{ formatPercent(overviewData.monthOverMonthGrowth) }} 较上月
|
||||
</span>
|
||||
</div>
|
||||
<div class="text-4xl font-black leading-none text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
{{
|
||||
overviewData?.totalSalesAmount
|
||||
? formatAmount(overviewData.totalSalesAmount)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div
|
||||
v-if="overviewData?.salesAmountAchievementRate !== undefined"
|
||||
class="mt-6 flex items-center justify-between border-t border-slate-100 dark:border-t-[hsl(240deg_3.7%_22%)] pt-4"
|
||||
>
|
||||
<span class="text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
销售额目标达成率
|
||||
</span>
|
||||
>
|
||||
<span class="text-sm font-black text-blue-600 dark:text-blue-400 dark:text-blue-400">
|
||||
{{
|
||||
formatPercentPlain(overviewData.salesAmountAchievementRate)
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ROI效率 -->
|
||||
<div
|
||||
class="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%)] p-6 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]"
|
||||
>
|
||||
<div class="mb-4 text-xs font-black text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
投资回报率 (ROI)
|
||||
</div>
|
||||
<div class="text-4xl font-black leading-none text-indigo-600 dark:text-indigo-400">
|
||||
{{ overviewData?.totalROI?.toFixed(2) || '-' }}
|
||||
</div>
|
||||
<div
|
||||
v-if="overviewData?.averageFeeRatio !== undefined"
|
||||
class="mt-6 flex justify-between border-t border-slate-100 dark:border-t-[hsl(240deg_3.7%_22%)] pt-4 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
<span>全店平均费比</span>
|
||||
<span class="text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
{{ formatPercentPlain(overviewData.averageFeeRatio) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 订单达成 -->
|
||||
<div
|
||||
class="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%)] p-6 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]"
|
||||
>
|
||||
<div class="mb-4 text-xs font-black text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
销量目标达成率 (订单数)
|
||||
</div>
|
||||
<div class="text-4xl font-black leading-none text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
{{
|
||||
overviewData?.orderCountAchievementRate !== undefined
|
||||
? formatPercentPlain(overviewData.orderCountAchievementRate)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div
|
||||
v-if="overviewData?.orderCountAchievementRate !== undefined"
|
||||
class="mt-6 h-2 w-full overflow-hidden rounded-full bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]"
|
||||
>
|
||||
<div
|
||||
class="h-full bg-indigo-500"
|
||||
:style="{
|
||||
width: `${Math.min(overviewData.orderCountAchievementRate, 100)}%`,
|
||||
}"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 税后利润 -->
|
||||
<div
|
||||
class="rounded-2xl border-l-4 border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] border-l-emerald-500 dark:border-l-emerald-500 bg-white/90 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-6 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]"
|
||||
>
|
||||
<div class="mb-4 text-xs font-black text-emerald-600 dark:text-emerald-400">
|
||||
全店总净利润 (税后)
|
||||
</div>
|
||||
<div class="text-4xl font-black leading-none text-emerald-600 dark:text-emerald-400">
|
||||
{{
|
||||
overviewData?.totalNetProfitAfterTax
|
||||
? formatAmount(overviewData.totalNetProfitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div
|
||||
v-if="overviewData?.totalTaxAmount !== undefined"
|
||||
class="mt-6 flex justify-between border-t border-slate-100 dark:border-t-[hsl(240deg_3.7%_22%)] pt-4 text-[11px] font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
<span>已扣除预扣税额 ({{ (taxRate * 100).toFixed(0) }}%)</span>
|
||||
<span>{{ formatAmount(overviewData.totalTaxAmount) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+256
@@ -0,0 +1,256 @@
|
||||
<script lang="ts" setup>
|
||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||
|
||||
import type { CompanyOverviewVO } from '#/api/ecommerce/company-overview';
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
defineOptions({ name: 'ShopCharts' });
|
||||
|
||||
interface Props {
|
||||
shopSalesRatios?: CompanyOverviewVO.ShopSalesRatio[];
|
||||
shopComparisons?: CompanyOverviewVO.ShopComparison[];
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const barChartRef = ref<EchartsUIType>();
|
||||
const scatterChartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts: renderBarChart } = useEcharts(barChartRef);
|
||||
const { renderEcharts: renderScatterChart } = useEcharts(scatterChartRef);
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN')}`;
|
||||
};
|
||||
|
||||
// 渲染店铺销售占比排行图表
|
||||
const renderShopBarChart = () => {
|
||||
if (!barChartRef.value || !props.shopSalesRatios) return;
|
||||
|
||||
const ratios = props.shopSalesRatios;
|
||||
const shopNames = ratios.map((r) => r.shopName).reverse();
|
||||
const salesAmounts = ratios.map((r) => r.salesAmount).reverse();
|
||||
|
||||
renderBarChart({
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '12%',
|
||||
bottom: '3%',
|
||||
top: '3%',
|
||||
containLabel: true,
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
formatter: (params: any) => {
|
||||
const param = Array.isArray(params) ? params[0] : params;
|
||||
const index = param.dataIndex;
|
||||
const shop = ratios[ratios.length - 1 - index];
|
||||
if (!shop) return '';
|
||||
return `${shop.shopName}<br/>销售额: ${formatAmount(shop.salesAmount)}<br/>占比: ${shop.ratio.toFixed(2)}%`;
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
axisLabel: { show: false },
|
||||
splitLine: { show: false },
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: shopNames,
|
||||
axisLine: { show: false },
|
||||
axisTick: { show: false },
|
||||
axisLabel: {
|
||||
fontWeight: 'bold',
|
||||
color: 'hsl(240deg 5% 64.9%)',
|
||||
fontSize: 13,
|
||||
},
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
data: salesAmounts,
|
||||
barWidth: 20,
|
||||
itemStyle: {
|
||||
borderRadius: [0, 10, 10, 0],
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 1,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 0,
|
||||
colorStops: [
|
||||
{ offset: 0, color: '#6366f1' },
|
||||
{ offset: 1, color: '#a5b4fc' },
|
||||
],
|
||||
},
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
position: 'right',
|
||||
formatter: (params: any) =>
|
||||
`¥${params.value.toLocaleString('zh-CN')}`,
|
||||
fontWeight: 900,
|
||||
color:
|
||||
document.documentElement.classList.contains('dark')
|
||||
? 'hsl(0deg 0% 95%)'
|
||||
: '#334155',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
// 渲染店铺效率象限图
|
||||
const renderShopScatterChart = () => {
|
||||
if (!scatterChartRef.value || !props.shopComparisons) return;
|
||||
|
||||
const scatterSource = props.shopComparisons.map((shop) => ({
|
||||
shopId: shop.shopId,
|
||||
shopName: shop.shopName,
|
||||
roi: Number(shop.roi),
|
||||
netProfit: Number(shop.profitAfterTax),
|
||||
}));
|
||||
|
||||
const data: Array<[number, number, string]> = scatterSource.map((q) => {
|
||||
const roi = Number.isFinite(q.roi) ? q.roi : 0;
|
||||
const netProfit = Number.isFinite(q.netProfit) ? q.netProfit : 0;
|
||||
return [roi, netProfit / 10_000, q.shopName];
|
||||
});
|
||||
|
||||
const roiValues = data.map((item) => item[0]);
|
||||
const profitValues = data.map((item) => item[1]);
|
||||
const minRoi = roiValues.length ? Math.min(...roiValues) : 0;
|
||||
const maxRoi = roiValues.length ? Math.max(...roiValues) : 1;
|
||||
const minProfit = profitValues.length ? Math.min(...profitValues) : 0;
|
||||
const maxProfit = profitValues.length ? Math.max(...profitValues) : 1;
|
||||
const roiPadding = minRoi === maxRoi ? 1 : (maxRoi - minRoi) * 0.2;
|
||||
const profitPadding =
|
||||
minProfit === maxProfit ? 1 : (maxProfit - minProfit) * 0.2;
|
||||
|
||||
renderScatterChart({
|
||||
grid: {
|
||||
left: '6%',
|
||||
right: '4%',
|
||||
top: '8%',
|
||||
bottom: '16%',
|
||||
containLabel: true,
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: (params: any) => {
|
||||
const shop = scatterSource[params.dataIndex];
|
||||
if (!shop) return '';
|
||||
return `<div style="padding:4px; font-weight:bold">${shop.shopName}</div><hr/>投资回报率 (ROI): ${shop.roi.toFixed(2)}<br/>净利润: ¥${(shop.netProfit / 10_000).toFixed(2)}万`;
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
min: minRoi - roiPadding,
|
||||
max: Math.max(maxRoi + roiPadding, 3.5),
|
||||
name: '投资回报率 (ROI)',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 35,
|
||||
axisLabel: { fontWeight: 'bold' },
|
||||
splitLine: {
|
||||
lineStyle: { type: 'dashed' },
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
min: Math.min(minProfit - profitPadding, 0),
|
||||
max: Math.max(maxProfit + profitPadding, 10),
|
||||
name: '税后净利润 (单位: 万元)',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 50,
|
||||
axisLabel: { fontWeight: 'bold' },
|
||||
splitLine: {
|
||||
lineStyle: { type: 'dashed' },
|
||||
},
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'scatter',
|
||||
symbolSize: 45,
|
||||
data,
|
||||
label: {
|
||||
show: true,
|
||||
position: 'top',
|
||||
color:
|
||||
document.documentElement.classList.contains('dark')
|
||||
? 'hsl(0deg 0% 95%)'
|
||||
: '#334155',
|
||||
fontWeight: 700,
|
||||
formatter: (params: any) => params.data?.[2] ?? '',
|
||||
},
|
||||
itemStyle: {
|
||||
color: (params: any) => {
|
||||
const roi = params.data?.[0];
|
||||
const profit = params.data?.[1];
|
||||
if (roi >= 3.5 && profit >= 10) return '#10b981';
|
||||
if (roi < 3 || profit < 0) return '#f43f5e';
|
||||
return '#6366f1';
|
||||
},
|
||||
shadowBlur: 15,
|
||||
shadowColor: 'rgba(0,0,0,0.1)',
|
||||
},
|
||||
markLine: {
|
||||
silent: true,
|
||||
lineStyle: { type: 'dashed', color: '#94a3b8' },
|
||||
data: [{ xAxis: 3.5 }, { yAxis: 10 }],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
// 暴露方法给父组件调用
|
||||
defineExpose({ renderShopBarChart, renderShopScatterChart });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid grid-cols-1 gap-6 xl:grid-cols-2">
|
||||
<!-- 销售占比排行 -->
|
||||
<div
|
||||
class="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%)] p-8 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]"
|
||||
>
|
||||
<h3 class="mb-6 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
各店铺销售贡献排行
|
||||
</h3>
|
||||
<div class="h-[380px] w-full">
|
||||
<EchartsUI ref="barChartRef" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- 效率象限图 -->
|
||||
<div
|
||||
class="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%)] p-8 shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]"
|
||||
>
|
||||
<h3 class="mb-6 text-lg font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
店铺经营效率象限 (ROI vs 净利)
|
||||
</h3>
|
||||
<div class="h-[380px] w-full">
|
||||
<EchartsUI ref="scatterChartRef" />
|
||||
</div>
|
||||
<div class="mt-4 flex justify-center gap-6">
|
||||
<div
|
||||
class="flex items-center gap-2 text-xs font-bold text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
<span class="h-3 w-3 rounded-full bg-emerald-500"></span>
|
||||
高产区
|
||||
</div>
|
||||
<div
|
||||
class="flex items-center gap-2 text-xs font-bold text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
<span class="h-3 w-3 rounded-full bg-blue-500"></span>
|
||||
潜力区
|
||||
</div>
|
||||
<div
|
||||
class="flex items-center gap-2 text-xs font-bold text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
<span class="h-3 w-3 rounded-full bg-rose-500"></span>
|
||||
风险区
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+340
@@ -0,0 +1,340 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CompanyOverviewVO } from '#/api/ecommerce/company-overview';
|
||||
|
||||
import { computed } from 'vue';
|
||||
|
||||
defineOptions({ name: 'ShopComparisonTable' });
|
||||
|
||||
interface Props {
|
||||
shopComparisons?: CompanyOverviewVO.ShopComparison[];
|
||||
taxRate: number;
|
||||
shopExportMode: boolean;
|
||||
selectedExportShopIds: number[];
|
||||
}
|
||||
|
||||
interface Emits {
|
||||
(e: 'update:selectedExportShopIds', ids: number[]): void;
|
||||
(e: 'toggleShopExportMode', enabled: boolean): void;
|
||||
(e: 'export'): void;
|
||||
(e: 'navigate', shopId: number): void;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const allShopsSelected = computed(() => {
|
||||
const total = props.shopComparisons?.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')}`;
|
||||
};
|
||||
|
||||
const formatPercentPlain = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value.toFixed(1)}%`;
|
||||
};
|
||||
</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%)]">
|
||||
各店铺多维度经营明细对比
|
||||
</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="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',
|
||||
shopComparisons?.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="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%)] 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">目标单量</th>
|
||||
<th class="border-b px-6 py-4 text-blue-600 dark:text-blue-400">单量达成率</th>
|
||||
<th class="border-b px-6 py-4">目标额</th>
|
||||
<th class="border-b px-6 py-4 text-blue-600 dark:text-blue-400">销售达成率</th>
|
||||
<!-- 规模 -->
|
||||
<th class="border-b border-l px-6 py-4 font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
实际销售额
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">单量</th>
|
||||
<th class="border-b px-6 py-4">客单价</th>
|
||||
<!-- 成本 -->
|
||||
<th class="border-b border-l px-6 py-4">商品成本</th>
|
||||
<th class="border-b px-6 py-4">运费</th>
|
||||
<th class="border-b px-6 py-4">其他成本</th>
|
||||
<th class="border-b px-6 py-4 font-bold text-rose-600 dark:text-rose-400">
|
||||
退款金额
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">推广费</th>
|
||||
<th class="border-b px-6 py-4 text-orange-600 dark:text-orange-400">刷单费用</th>
|
||||
<th class="border-b px-6 py-4 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">费比 %</th>
|
||||
<!-- 盈利 -->
|
||||
<th class="border-b border-l px-6 py-4 font-bold">
|
||||
税前盈亏
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 italic text-rose-500 dark:text-rose-400">
|
||||
{{ (taxRate * 100).toFixed(0) }}%税额
|
||||
</th>
|
||||
<th class="border-b 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="shop in shopComparisons"
|
||||
: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 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 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="cursor-pointer text-blue-600 dark:text-blue-400 transition-colors hover:text-blue-300 hover:underline"
|
||||
@click="emit('navigate', shop.shopId)"
|
||||
>
|
||||
{{ shop.shopName }}
|
||||
</span>
|
||||
</td>
|
||||
<!-- 目标 -->
|
||||
<td class="p-6 font-medium">
|
||||
{{ shop.targetOrderCount?.toLocaleString('zh-CN') || '-' }}
|
||||
</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">
|
||||
{{
|
||||
shop.targetAmount ? formatAmount(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">
|
||||
{{ shop.orderCount?.toLocaleString('zh-CN') || '-' }}
|
||||
</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{
|
||||
shop.averageOrderValue
|
||||
? formatAmount(shop.averageOrderValue)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">
|
||||
{{
|
||||
shop.productCost ? formatAmount(shop.productCost) : '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{
|
||||
shop.shippingCost ? formatAmount(shop.shippingCost) : '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{
|
||||
shop.otherCost ? formatAmount(shop.otherCost) : '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">
|
||||
{{
|
||||
shop.refundAmount ? formatAmount(shop.refundAmount) : '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{
|
||||
shop.totalPromotionFee
|
||||
? formatAmount(shop.totalPromotionFee)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">
|
||||
{{ shop.brushFee ? formatAmount(shop.brushFee) : '-' }}
|
||||
</td>
|
||||
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{
|
||||
shop.feeRatio !== undefined
|
||||
? formatPercentPlain(shop.feeRatio)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6 font-bold">
|
||||
{{
|
||||
shop.totalProfitBeforeTax
|
||||
? formatAmount(shop.totalProfitBeforeTax)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{
|
||||
shop.salesTaxAmount
|
||||
? formatAmount(shop.salesTaxAmount)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">
|
||||
{{ shop.roi?.toFixed(2) || '-' }}
|
||||
</td>
|
||||
<td class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%/20%)] p-6 text-base font-black text-emerald-600">
|
||||
{{
|
||||
shop.profitAfterTax
|
||||
? formatAmount(shop.profitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!shopComparisons?.length">
|
||||
<td colspan="17" class="p-8 text-center text-gray-400">
|
||||
暂无数据
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user