mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 23:49:19 +08:00
feat: 添加店铺概览统计功能及退款状态支持
This commit is contained in:
+15
@@ -43,6 +43,7 @@ const formData = ref<Partial<OrderStatusDTO.Create>>({
|
||||
description: '',
|
||||
autoStatistics: 1,
|
||||
sortOrder: 0,
|
||||
isRefund: 0,
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
@@ -68,12 +69,14 @@ function open(edit: boolean, record?: OrderStatusVO.Info) {
|
||||
description: record.description || '',
|
||||
autoStatistics: record.autoStatistics,
|
||||
sortOrder: record.sortOrder || 0,
|
||||
isRefund: record.isRefund || 0,
|
||||
}
|
||||
: {
|
||||
statusName: '',
|
||||
description: '',
|
||||
autoStatistics: 1,
|
||||
sortOrder: 0,
|
||||
isRefund: 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -97,6 +100,7 @@ async function handleSubmit() {
|
||||
description: formData.value.description,
|
||||
autoStatistics: formData.value.autoStatistics!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
isRefund: formData.value.isRefund,
|
||||
};
|
||||
await updateOrderStatusApi(currentRecord.value.id, updateData);
|
||||
message.success('更新订单状态成功');
|
||||
@@ -107,6 +111,7 @@ async function handleSubmit() {
|
||||
description: formData.value.description,
|
||||
autoStatistics: formData.value.autoStatistics!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
isRefund: formData.value.isRefund,
|
||||
};
|
||||
await createOrderStatusApi(createData);
|
||||
message.success('创建订单状态成功');
|
||||
@@ -186,6 +191,16 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<Form.Item label="是否为退款状态" name="isRefund">
|
||||
<Switch
|
||||
v-model:checked="formData.isRefund"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
checked-children="是"
|
||||
un-checked-children="否"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,807 @@
|
||||
<script lang="ts" setup>
|
||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
import { Button, DatePicker, message, Spin } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { getShopOverviewStatisticsApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'ShopOverview' });
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
// 店铺ID(从路由参数获取)
|
||||
const shopId = computed(() => {
|
||||
const id = route.params.id;
|
||||
return id ? Number(id) : 0;
|
||||
});
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const overviewData = ref<null | ShopVO.OverviewStatistics>(null);
|
||||
|
||||
// 日期范围
|
||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||
dayjs().subtract(7, 'day'),
|
||||
dayjs(),
|
||||
]);
|
||||
|
||||
// 当前选中的时间范围类型
|
||||
const activeTimeRange = ref<
|
||||
'7days' | '30days' | 'custom' | 'today' | 'yesterday'
|
||||
>('7days');
|
||||
|
||||
// 自定义日期范围
|
||||
const customDateRange = ref<[dayjs.Dayjs, dayjs.Dayjs] | undefined>(undefined);
|
||||
|
||||
// 切换时间范围
|
||||
const switchTimeRange = (
|
||||
type: '7days' | '30days' | 'custom' | 'today' | 'yesterday',
|
||||
) => {
|
||||
activeTimeRange.value = type;
|
||||
let startDate: dayjs.Dayjs;
|
||||
let endDate: dayjs.Dayjs = dayjs();
|
||||
|
||||
switch (type) {
|
||||
case '7days': {
|
||||
startDate = dayjs().subtract(7, 'day');
|
||||
break;
|
||||
}
|
||||
case '30days': {
|
||||
startDate = dayjs().subtract(30, 'day');
|
||||
break;
|
||||
}
|
||||
case 'custom': {
|
||||
if (customDateRange.value) {
|
||||
dateRange.value = customDateRange.value;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 'today': {
|
||||
startDate = dayjs();
|
||||
endDate = dayjs();
|
||||
break;
|
||||
}
|
||||
case 'yesterday': {
|
||||
startDate = dayjs().subtract(1, 'day');
|
||||
endDate = dayjs().subtract(1, 'day');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dateRange.value = [startDate, endDate];
|
||||
};
|
||||
|
||||
// 自定义日期范围变化
|
||||
const handleCustomDateRangeChange = (
|
||||
value: [dayjs.Dayjs, dayjs.Dayjs] | [string, string] | null,
|
||||
_dateString?: [string, string],
|
||||
) => {
|
||||
if (value && Array.isArray(value) && value.length === 2) {
|
||||
const dates = [
|
||||
dayjs.isDayjs(value[0]) ? value[0] : dayjs(value[0]),
|
||||
dayjs.isDayjs(value[1]) ? value[1] : dayjs(value[1]),
|
||||
] as [dayjs.Dayjs, dayjs.Dayjs];
|
||||
customDateRange.value = dates;
|
||||
activeTimeRange.value = 'custom';
|
||||
dateRange.value = dates;
|
||||
}
|
||||
};
|
||||
|
||||
// 图表引用
|
||||
const trendChartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts: renderTrendChart } = useEcharts(trendChartRef);
|
||||
|
||||
// 格式化金额
|
||||
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)}%`;
|
||||
};
|
||||
|
||||
// 加载概览数据
|
||||
const loadOverviewData = async () => {
|
||||
if (!shopId.value) return;
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: ShopDTO.OverviewQuery = {
|
||||
shopId: shopId.value,
|
||||
dateRange: [
|
||||
dateRange.value[0].format('YYYY-MM-DD'),
|
||||
dateRange.value[1].format('YYYY-MM-DD'),
|
||||
],
|
||||
};
|
||||
const data = await getShopOverviewStatisticsApi(params);
|
||||
overviewData.value = data;
|
||||
} catch (error) {
|
||||
console.error('获取店铺概览数据失败:', error);
|
||||
message.error('获取店铺概览数据失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 渲染趋势图表
|
||||
const renderTrendChartData = () => {
|
||||
if (!trendChartRef.value || !overviewData.value) return;
|
||||
|
||||
const salesTrend = overviewData.value.salesAmountTrend;
|
||||
const orderTrend = overviewData.value.orderCountTrend;
|
||||
|
||||
if (!salesTrend || !orderTrend) return;
|
||||
|
||||
const dates = salesTrend.dailyDataList.map((item) =>
|
||||
dayjs(item.date).format('MM-DD'),
|
||||
);
|
||||
const salesData = salesTrend.dailyDataList.map((item) => item.value);
|
||||
const orderData = orderTrend.dailyDataList.map((item) => item.value);
|
||||
|
||||
renderTrendChart({
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '3%',
|
||||
bottom: '3%',
|
||||
top: '5%',
|
||||
containLabel: true,
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
backgroundColor: '#fff',
|
||||
textStyle: { color: '#000' },
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: dates,
|
||||
axisLine: { lineStyle: { color: '#e2e8f0' } },
|
||||
},
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value',
|
||||
name: '销售额',
|
||||
splitLine: { lineStyle: { type: 'dashed' } },
|
||||
},
|
||||
{
|
||||
type: 'value',
|
||||
name: '单量',
|
||||
position: 'right',
|
||||
splitLine: { show: false },
|
||||
},
|
||||
],
|
||||
series: [
|
||||
{
|
||||
name: '销售额',
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
lineStyle: { width: 3, color: '#3b82f6' },
|
||||
areaStyle: {
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{ offset: 0, color: 'rgba(59, 130, 246, 0.4)' },
|
||||
{ offset: 1, color: 'rgba(59, 130, 246, 0)' },
|
||||
],
|
||||
},
|
||||
},
|
||||
data: salesData,
|
||||
},
|
||||
{
|
||||
name: '日单量',
|
||||
type: 'line',
|
||||
yAxisIndex: 1,
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
lineStyle: { width: 3, color: '#10b981' },
|
||||
areaStyle: {
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{ offset: 0, color: 'rgba(16, 185, 129, 0.2)' },
|
||||
{ offset: 1, color: 'rgba(16, 185, 129, 0)' },
|
||||
],
|
||||
},
|
||||
},
|
||||
data: orderData,
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
// 监听数据变化,重新渲染图表
|
||||
watch(
|
||||
() => overviewData.value,
|
||||
() => {
|
||||
if (overviewData.value) {
|
||||
setTimeout(() => {
|
||||
renderTrendChartData();
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
// 监听日期范围变化
|
||||
watch(
|
||||
() => dateRange.value,
|
||||
() => {
|
||||
loadOverviewData();
|
||||
},
|
||||
);
|
||||
|
||||
// 监听 shopId 变化
|
||||
watch(
|
||||
() => shopId.value,
|
||||
() => {
|
||||
if (shopId.value) {
|
||||
loadOverviewData();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
if (shopId.value) {
|
||||
loadOverviewData();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="店铺经营概览" auto-content-height class="bg-[#f8fafc]">
|
||||
<template #description>
|
||||
<div class="mt-1 text-sm font-bold italic text-slate-500">
|
||||
数据更新于:{{ dayjs().format('今日 HH:mm:ss') }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<!-- 时间选择器 -->
|
||||
<div
|
||||
class="flex items-center gap-1.5 rounded-2xl border border-slate-200 bg-slate-200/50 p-1"
|
||||
>
|
||||
<!-- 快速选择按钮组 -->
|
||||
<div class="flex rounded-xl bg-white/40 p-1 shadow-inner">
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
class="!h-auto !min-w-0 !rounded-lg !border-none !px-5 !py-2 !text-sm !font-bold !shadow-none !transition-all"
|
||||
:class="
|
||||
activeTimeRange === 'today'
|
||||
? '!bg-white !font-black !text-blue-600 !shadow-sm'
|
||||
: '!bg-transparent !text-slate-500 hover:!text-slate-800'
|
||||
"
|
||||
@click="switchTimeRange('today')"
|
||||
>
|
||||
今日
|
||||
</Button>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
class="!h-auto !min-w-0 !rounded-lg !border-none !px-5 !py-2 !text-sm !font-bold !shadow-none !transition-all"
|
||||
:class="
|
||||
activeTimeRange === 'yesterday'
|
||||
? '!bg-white !font-black !text-blue-600 !shadow-sm'
|
||||
: '!bg-transparent !text-slate-500 hover:!text-slate-800'
|
||||
"
|
||||
@click="switchTimeRange('yesterday')"
|
||||
>
|
||||
昨日
|
||||
</Button>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
class="!h-auto !min-w-0 !rounded-lg !border-none !px-5 !py-2 !text-sm !font-bold !shadow-none !transition-all"
|
||||
:class="
|
||||
activeTimeRange === '7days'
|
||||
? '!bg-white !font-black !text-blue-600 !shadow-sm'
|
||||
: '!bg-transparent !text-slate-500 hover:!text-slate-800'
|
||||
"
|
||||
@click="switchTimeRange('7days')"
|
||||
>
|
||||
近7日
|
||||
</Button>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
class="!h-auto !min-w-0 !rounded-lg !border-none !px-5 !py-2 !text-sm !font-bold !shadow-none !transition-all"
|
||||
:class="
|
||||
activeTimeRange === '30days'
|
||||
? '!bg-white !font-black !text-blue-600 !shadow-sm'
|
||||
: '!bg-transparent !text-slate-500 hover:!text-slate-800'
|
||||
"
|
||||
@click="switchTimeRange('30days')"
|
||||
>
|
||||
近30日
|
||||
</Button>
|
||||
</div>
|
||||
<!-- 分隔线 -->
|
||||
<div class="mx-2 h-6 w-px bg-slate-300"></div>
|
||||
<!-- 自定义日期选择器 -->
|
||||
<div class="flex items-center gap-2 px-3">
|
||||
<span class="text-xs font-bold text-slate-400">自定义日期</span>
|
||||
<DatePicker.RangePicker
|
||||
v-model:value="customDateRange"
|
||||
size="small"
|
||||
format="YYYY-MM-DD"
|
||||
:allow-clear="false"
|
||||
:placeholder="['开始日期', '结束日期']"
|
||||
class="!cursor-pointer !border-none !bg-transparent !text-sm !font-bold"
|
||||
@change="handleCustomDateRangeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<Spin :spinning="loading">
|
||||
<div class="mx-auto w-full space-y-6 p-4 md:p-8">
|
||||
<!-- 第一层:核心统计卡片 -->
|
||||
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 xl:grid-cols-4">
|
||||
<!-- 销售大盘 -->
|
||||
<div
|
||||
class="flex flex-col justify-between rounded-[20px] border border-slate-200/80 bg-white/85 p-6 shadow-[0_4px_20px_rgba(0,0,0,0.02)] backdrop-blur-[12px]"
|
||||
>
|
||||
<div class="mb-4 flex items-start justify-between">
|
||||
<span
|
||||
class="text-xs font-black uppercase tracking-widest text-slate-400"
|
||||
>
|
||||
店铺销售总额
|
||||
</span>
|
||||
<span
|
||||
v-if="overviewData?.monthOverMonthGrowth !== undefined"
|
||||
class="rounded bg-emerald-50 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">
|
||||
{{
|
||||
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 pt-4 text-xs font-bold"
|
||||
>
|
||||
<span class="text-slate-400">销售额目标达成</span>
|
||||
<span class="font-black text-blue-600">
|
||||
{{
|
||||
formatPercentPlain(overviewData.salesAmountAchievementRate)
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 订单达成 -->
|
||||
<div
|
||||
class="flex flex-col justify-between rounded-[20px] border border-slate-200/80 bg-white/85 p-6 shadow-[0_4px_20px_rgba(0,0,0,0.02)] backdrop-blur-[12px]"
|
||||
>
|
||||
<div
|
||||
class="mb-4 text-xs font-black uppercase tracking-widest text-slate-400"
|
||||
>
|
||||
订单总量与达成
|
||||
</div>
|
||||
<div class="text-4xl font-black leading-none text-slate-900">
|
||||
{{
|
||||
overviewData?.totalOrderCount?.toLocaleString('zh-CN') || '-'
|
||||
}}
|
||||
<span class="ml-1 text-sm font-normal text-slate-400">单</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="overviewData?.orderCountAchievementRate !== undefined"
|
||||
class="mt-6"
|
||||
>
|
||||
<div
|
||||
class="mb-2 flex justify-between text-[10px] font-black text-slate-400"
|
||||
>
|
||||
<span>
|
||||
目标:
|
||||
{{
|
||||
overviewData.totalTargetOrderCount?.toLocaleString(
|
||||
'zh-CN',
|
||||
) || '-'
|
||||
}}
|
||||
单
|
||||
</span>
|
||||
<span>
|
||||
达成率:
|
||||
{{
|
||||
formatPercentPlain(overviewData.orderCountAchievementRate)
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="h-2 w-full overflow-hidden rounded-full bg-slate-100">
|
||||
<div
|
||||
class="h-full bg-indigo-500 transition-all duration-1000"
|
||||
:style="{
|
||||
width: `${Math.min(overviewData.orderCountAchievementRate || 0, 100)}%`,
|
||||
}"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 推广效率 -->
|
||||
<div
|
||||
class="flex flex-col justify-between rounded-[20px] border border-slate-200/80 bg-white/85 p-6 shadow-[0_4px_20px_rgba(0,0,0,0.02)] backdrop-blur-[12px]"
|
||||
>
|
||||
<div
|
||||
class="mb-4 text-xs font-black uppercase tracking-widest text-slate-400"
|
||||
>
|
||||
投资回报率 (ROI)
|
||||
</div>
|
||||
<div class="text-4xl font-black leading-none text-indigo-600">
|
||||
{{ overviewData?.totalROI?.toFixed(2) || '-' }}
|
||||
</div>
|
||||
<div
|
||||
v-if="overviewData?.averageFeeRatio !== undefined"
|
||||
class="mt-6 space-y-2 border-t border-slate-100 pt-4"
|
||||
>
|
||||
<div class="flex justify-between text-xs font-bold">
|
||||
<span class="text-slate-400">平均费比</span>
|
||||
<span class="text-slate-800">
|
||||
{{ formatPercentPlain(overviewData.averageFeeRatio) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 利润汇总 -->
|
||||
<div
|
||||
class="flex flex-col justify-between rounded-[20px] border-l-4 border-slate-200/80 border-l-emerald-500 bg-white/85 p-6 shadow-[0_4px_20px_rgba(0,0,0,0.02)] backdrop-blur-[12px]"
|
||||
>
|
||||
<div
|
||||
class="mb-4 text-xs font-black uppercase tracking-widest text-emerald-600"
|
||||
>
|
||||
店铺总净利润 (税后)
|
||||
</div>
|
||||
<div class="text-4xl font-black leading-none text-emerald-600">
|
||||
{{
|
||||
overviewData?.totalNetProfitAfterTax
|
||||
? formatAmount(overviewData.totalNetProfitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div
|
||||
v-if="overviewData?.totalTaxAmount !== undefined"
|
||||
class="mt-6 flex justify-between border-t border-slate-100 pt-4 text-[11px] font-bold text-slate-400"
|
||||
>
|
||||
<span>已扣除 4% 税额</span>
|
||||
<span>-{{ formatAmount(overviewData.totalTaxAmount) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第二层:趋势与财务拆解 -->
|
||||
<div class="grid grid-cols-1 gap-6 xl:grid-cols-3">
|
||||
<!-- 销售额趋势图 -->
|
||||
<div
|
||||
class="rounded-[20px] border border-slate-200/80 bg-white/85 p-8 shadow-[0_4px_20px_rgba(0,0,0,0.02)] backdrop-blur-[12px] xl:col-span-2"
|
||||
>
|
||||
<h3 class="mb-6 text-lg font-black text-slate-800">
|
||||
销售额与单量趋势分析
|
||||
</h3>
|
||||
<div class="h-[380px] w-full">
|
||||
<EchartsUI ref="trendChartRef" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 财务全维度损益清单 -->
|
||||
<div
|
||||
class="flex flex-col rounded-[20px] border border-slate-200/80 bg-white/85 p-8 shadow-[0_4px_20px_rgba(0,0,0,0.02)] backdrop-blur-[12px]"
|
||||
>
|
||||
<h3 class="mb-6 text-lg font-black text-slate-800">
|
||||
财务损益全维度 (P&L)
|
||||
</h3>
|
||||
<div class="flex flex-1 flex-col space-y-4 text-sm">
|
||||
<div class="flex justify-between border-b border-slate-100 pb-2">
|
||||
<span class="text-slate-500">推广费总支出</span>
|
||||
<span class="font-bold">
|
||||
{{
|
||||
overviewData?.totalPromotionFee
|
||||
? `-${formatAmount(overviewData.totalPromotionFee)}`
|
||||
: '-'
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex justify-between border-b border-slate-100 pb-2">
|
||||
<span class="text-slate-500">客单价 (AOV)</span>
|
||||
<span class="font-bold">
|
||||
{{
|
||||
overviewData?.totalSalesAmount &&
|
||||
overviewData?.totalOrderCount
|
||||
? formatAmount(
|
||||
overviewData.totalSalesAmount /
|
||||
overviewData.totalOrderCount,
|
||||
)
|
||||
: '-'
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex justify-between border-b border-slate-100 pb-2">
|
||||
<span class="text-slate-500">总税后盈亏 (Profit)</span>
|
||||
<span class="font-bold text-indigo-600">
|
||||
{{
|
||||
overviewData?.totalProfitAfterTax
|
||||
? formatAmount(overviewData.totalProfitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
<!-- 扣除项 -->
|
||||
<div class="mt-4 space-y-3 rounded-2xl bg-slate-50/80 p-4">
|
||||
<div class="flex justify-between text-xs">
|
||||
<span class="text-slate-400">销售额 4% 税额</span>
|
||||
<span class="font-bold text-rose-500">
|
||||
{{
|
||||
overviewData?.totalTaxAmount
|
||||
? formatAmount(overviewData.totalTaxAmount)
|
||||
: '-'
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex justify-between text-xs">
|
||||
<span class="text-slate-400">较上月同期增长</span>
|
||||
<span class="font-black text-emerald-500">
|
||||
{{ formatPercent(overviewData?.monthOverMonthGrowth) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 最终结果 -->
|
||||
<div
|
||||
class="mt-auto flex items-center justify-between rounded-2xl bg-slate-900 p-5 text-white shadow-2xl"
|
||||
>
|
||||
<div>
|
||||
<p class="text-[10px] font-black uppercase opacity-60">
|
||||
Final Net Profit
|
||||
</p>
|
||||
<p class="text-xs font-bold">税后最终净利</p>
|
||||
</div>
|
||||
<div class="text-3xl font-black">
|
||||
{{
|
||||
overviewData?.totalNetProfitAfterTax
|
||||
? formatAmount(overviewData.totalNetProfitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第三层:多商品 16 维度横向对比表 -->
|
||||
<div
|
||||
class="overflow-hidden rounded-[20px] border border-slate-200/80 bg-white/85 shadow-[0_4px_20px_rgba(0,0,0,0.02)] backdrop-blur-[12px]"
|
||||
>
|
||||
<div
|
||||
class="flex items-center justify-between border-b border-slate-100 bg-white/40 p-8"
|
||||
>
|
||||
<div>
|
||||
<h3 class="text-xl font-black text-slate-800">
|
||||
核心商品多维度损益对比表
|
||||
</h3>
|
||||
<p class="mt-1 text-xs font-bold text-slate-400">
|
||||
横向对比各商品规模、成本及 ROI 效率
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
type="primary"
|
||||
class="!h-auto !rounded-2xl !border-none !bg-slate-900 !px-8 !py-3 !text-sm !font-black !shadow-xl !shadow-slate-200 !transition-all hover:!scale-105 active:!scale-95"
|
||||
>
|
||||
导出商品明细报表
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div class="table-container overflow-x-auto">
|
||||
<table class="w-full whitespace-nowrap text-left text-sm">
|
||||
<!-- 分类复合表头 -->
|
||||
<thead
|
||||
class="bg-slate-50 text-[10px] font-black uppercase tracking-tighter text-slate-500"
|
||||
>
|
||||
<tr>
|
||||
<th
|
||||
rowspan="2"
|
||||
class="sticky-col border-b px-6 py-6 text-sm text-slate-900"
|
||||
>
|
||||
商品详情
|
||||
</th>
|
||||
<th
|
||||
colspan="3"
|
||||
class="border-b border-l border-slate-200 bg-slate-100/50 px-3 py-3 text-center"
|
||||
>
|
||||
商品规模 (Scale)
|
||||
</th>
|
||||
<th
|
||||
colspan="4"
|
||||
class="border-b border-l border-slate-200 bg-orange-50/50 px-3 py-3 text-center italic text-orange-700"
|
||||
>
|
||||
费用成本 (Costs)
|
||||
</th>
|
||||
<th
|
||||
colspan="5"
|
||||
class="border-b border-l border-slate-200 bg-emerald-50/50 px-3 py-3 text-center italic text-emerald-700"
|
||||
>
|
||||
单品损益 (Profitability)
|
||||
</th>
|
||||
</tr>
|
||||
<tr class="bg-slate-50/80">
|
||||
<!-- 规模 -->
|
||||
<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 border-l px-6 py-4">成本运费</th>
|
||||
<th class="border-b px-6 py-4 text-rose-600">退款金额</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 text-indigo-700">单品 ROI</th>
|
||||
<th class="border-b px-6 py-4">税前盈亏</th>
|
||||
<th class="border-b px-6 py-4 italic text-rose-500">
|
||||
4%税额
|
||||
</th>
|
||||
<th
|
||||
class="border-b bg-emerald-600 px-6 py-4 font-black text-white"
|
||||
>
|
||||
税后净利
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100">
|
||||
<tr
|
||||
v-for="product in overviewData?.productComparisons"
|
||||
:key="product.productId"
|
||||
class="transition-colors hover:bg-blue-50/30"
|
||||
>
|
||||
<td
|
||||
class="sticky-col border-r-2 border-slate-100 bg-white px-6 py-6 font-bold text-slate-900"
|
||||
>
|
||||
<div>{{ product.productName }}</div>
|
||||
<div
|
||||
v-if="product.productCode"
|
||||
class="text-[10px] font-normal text-slate-300"
|
||||
>
|
||||
编码: {{ product.productCode }}
|
||||
</div>
|
||||
</td>
|
||||
<!-- 规模 -->
|
||||
<td class="px-6 py-4 font-black">
|
||||
{{ formatAmount(product.salesAmount) }}
|
||||
</td>
|
||||
<td class="px-6 py-4 font-medium">
|
||||
{{ product.orderCount?.toLocaleString('zh-CN') || '-' }}
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
{{
|
||||
product.averageOrderValue
|
||||
? formatAmount(product.averageOrderValue)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="px-6 py-4">
|
||||
{{
|
||||
product.shippingCost
|
||||
? formatAmount(product.shippingCost)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="px-6 py-4 font-bold text-rose-500">
|
||||
{{
|
||||
product.refundAmount
|
||||
? formatAmount(product.refundAmount)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
{{
|
||||
product.totalPromotionFee
|
||||
? formatAmount(product.totalPromotionFee)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-amber-500">
|
||||
{{
|
||||
product.brushFee ? formatAmount(product.brushFee) : '-'
|
||||
}}
|
||||
</td>
|
||||
<!-- 损益 -->
|
||||
<td class="px-6 py-4 text-slate-400">
|
||||
{{
|
||||
product.feeRatio !== undefined
|
||||
? formatPercentPlain(product.feeRatio)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="px-6 py-4 font-black text-indigo-700">
|
||||
{{ product.roi?.toFixed(2) || '-' }}
|
||||
</td>
|
||||
<td class="px-6 py-4 font-bold text-slate-600">
|
||||
{{
|
||||
product.totalProfitBeforeTax
|
||||
? formatAmount(product.totalProfitBeforeTax)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="px-6 py-4 italic text-slate-400">
|
||||
{{
|
||||
product.salesTaxAmount
|
||||
? formatAmount(product.salesTaxAmount)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td
|
||||
class="bg-emerald-50/30 px-6 py-4 text-base font-black"
|
||||
:class="
|
||||
product.profitAfterTax && product.profitAfterTax < 0
|
||||
? 'text-rose-500'
|
||||
: 'text-emerald-600'
|
||||
"
|
||||
>
|
||||
{{
|
||||
product.profitAfterTax
|
||||
? formatAmount(product.profitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!overviewData?.productComparisons?.length">
|
||||
<td colspan="13" class="p-8 text-center text-gray-400">
|
||||
暂无数据
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Spin>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 表格滚动条优化 */
|
||||
.table-container::-webkit-scrollbar {
|
||||
height: 6px;
|
||||
}
|
||||
.table-container::-webkit-scrollbar-thumb {
|
||||
background: #e2e8f0;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
/* 固定商品名称列 */
|
||||
.sticky-col {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
z-index: 10;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user