mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 03:49:19 +08:00
feat: 完善公司全店概览
This commit is contained in:
+35
-25
@@ -29,6 +29,14 @@ export namespace CompanyOverviewVO {
|
||||
totalROI?: number;
|
||||
/** 总税后盈亏 */
|
||||
totalProfitAfterTax?: number;
|
||||
/** 全店总销量目标(目标订单数) */
|
||||
totalTargetOrderCount?: number;
|
||||
/** 全店总销售额目标 */
|
||||
totalTargetAmount?: number;
|
||||
/** 销量目标达成率(实际订单数/目标订单数) */
|
||||
orderCountAchievementRate?: number;
|
||||
/** 销售额目标达成率(实际销售额/目标销售额) */
|
||||
salesAmountAchievementRate?: number;
|
||||
}
|
||||
|
||||
/** 店铺销售占比 */
|
||||
@@ -65,35 +73,37 @@ export namespace CompanyOverviewVO {
|
||||
shopName: string;
|
||||
/** 平台 */
|
||||
platform?: string;
|
||||
/** 目标销量(目标订单数) */
|
||||
targetOrderCount?: number;
|
||||
/** 销量达成率 */
|
||||
orderCountAchievementRate?: number;
|
||||
/** 目标销售额 */
|
||||
targetAmount?: number;
|
||||
/** 销售额达成率 */
|
||||
salesAmountAchievementRate?: number;
|
||||
/** 销售额 */
|
||||
salesAmount: number;
|
||||
/** ROI */
|
||||
roi?: number;
|
||||
/** 退款金额 */
|
||||
refundAmount?: number;
|
||||
/** 刷单费 */
|
||||
brushFee?: number;
|
||||
/** 推广费总和 */
|
||||
totalPromotionFee?: number;
|
||||
/** 税后盈亏 */
|
||||
profitAfterTax?: number;
|
||||
/** 订单数量 */
|
||||
/** 单量 */
|
||||
orderCount?: number;
|
||||
/** 总成本 */
|
||||
totalCost?: number;
|
||||
/** 总利润(税前) */
|
||||
totalProfitBeforeTax?: number;
|
||||
/** 税额 */
|
||||
taxAmount?: number;
|
||||
/** 费比 */
|
||||
feeRatio?: number;
|
||||
/** 客单价 */
|
||||
averageOrderValue?: number;
|
||||
/** 利润率 */
|
||||
profitMargin?: number;
|
||||
/** 推广费占比 */
|
||||
promotionFeeRatio?: number;
|
||||
/** 退款率 */
|
||||
refundRate?: number;
|
||||
/** 成本运费 */
|
||||
shippingCost?: number;
|
||||
/** 退款金额 */
|
||||
refundAmount?: number;
|
||||
/** 推广费 */
|
||||
totalPromotionFee?: number;
|
||||
/** 刷单费用 */
|
||||
brushFee?: number;
|
||||
/** 费比 */
|
||||
feeRatio?: number;
|
||||
/** 税前盈亏 */
|
||||
totalProfitBeforeTax?: number;
|
||||
/** 销售额4%税额 */
|
||||
salesTaxAmount?: number;
|
||||
/** 税后盈亏 */
|
||||
profitAfterTax?: number;
|
||||
/** ROI */
|
||||
roi?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import type {
|
||||
ShopMonthlyTargetDTO,
|
||||
ShopMonthlyTargetVO,
|
||||
} from './types';
|
||||
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
/**
|
||||
* 店铺月销量目标管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* 创建店铺月销量目标
|
||||
*/
|
||||
export async function createShopMonthlyTargetApi(
|
||||
data: ShopMonthlyTargetDTO.Create,
|
||||
) {
|
||||
return requestClient.post<ShopMonthlyTargetVO.Info>(
|
||||
'/ec/shop-monthly-target/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新店铺月销量目标
|
||||
*/
|
||||
export async function updateShopMonthlyTargetApi(
|
||||
id: number,
|
||||
data: ShopMonthlyTargetDTO.Update,
|
||||
) {
|
||||
return requestClient.put<ShopMonthlyTargetVO.Info>(
|
||||
`/ec/shop-monthly-target/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除店铺月销量目标
|
||||
*/
|
||||
export async function deleteShopMonthlyTargetApi(id: number) {
|
||||
return requestClient.delete(`/ec/shop-monthly-target/delete/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取店铺月销量目标列表
|
||||
*/
|
||||
export async function getShopMonthlyTargetPageApi(
|
||||
params: PageQueryDTO<ShopMonthlyTargetDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<ShopMonthlyTargetVO.Info>>(
|
||||
'/ec/shop-monthly-target/page',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺月销量目标详情
|
||||
*/
|
||||
export async function getShopMonthlyTargetByIdApi(id: number) {
|
||||
return requestClient.get<ShopMonthlyTargetVO.Info>(
|
||||
`/ec/shop-monthly-target/detail/${id}`,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 店铺月销量目标管理模块API导出
|
||||
*/
|
||||
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 店铺月销量目标管理模块类型定义导出
|
||||
*/
|
||||
|
||||
export * from './types.dto';
|
||||
export * from './types.vo';
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 店铺月销量目标相关DTO类型定义
|
||||
*/
|
||||
|
||||
export namespace ShopMonthlyTargetDTO {
|
||||
/** 创建店铺月销量目标参数 */
|
||||
export interface Create {
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 目标月份(格式:YYYY-MM-01) */
|
||||
targetMonth: string;
|
||||
/** 目标销售额 */
|
||||
targetAmount: number;
|
||||
/** 目标订单数 */
|
||||
targetOrderCount: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 更新店铺月销量目标参数 */
|
||||
export interface Update {
|
||||
/** 目标月份(格式:YYYY-MM-01) */
|
||||
targetMonth: string;
|
||||
/** 目标销售额 */
|
||||
targetAmount: number;
|
||||
/** 目标订单数 */
|
||||
targetOrderCount: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/** 店铺月销量目标过滤条件 */
|
||||
export interface Filters {
|
||||
/** 店铺ID */
|
||||
shopId?: number;
|
||||
/** 目标月份范围-开始月份 */
|
||||
startTargetMonth?: string;
|
||||
/** 目标月份范围-结束月份 */
|
||||
endTargetMonth?: string;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 店铺月销量目标相关VO类型定义
|
||||
*/
|
||||
|
||||
export namespace ShopMonthlyTargetVO {
|
||||
/** 店铺月销量目标信息 */
|
||||
export interface Info {
|
||||
/** 目标ID */
|
||||
id: number;
|
||||
/** 公司ID */
|
||||
companyId: number;
|
||||
/** 店铺ID */
|
||||
shopId: number;
|
||||
/** 店铺名称 */
|
||||
shopName: string;
|
||||
/** 目标月份 */
|
||||
targetMonth: string;
|
||||
/** 目标销售额 */
|
||||
targetAmount: number;
|
||||
/** 目标订单数 */
|
||||
targetOrderCount: number;
|
||||
/** 备注 */
|
||||
remark?: string;
|
||||
/** 创建时间 */
|
||||
createTime: string;
|
||||
/** 更新时间 */
|
||||
updateTime: string;
|
||||
/** 创建人ID */
|
||||
createBy?: number;
|
||||
/** 更新人ID */
|
||||
updateBy?: number;
|
||||
}
|
||||
}
|
||||
@@ -101,11 +101,6 @@ const { renderEcharts: renderScatterChart } = useEcharts(scatterChartRef);
|
||||
|
||||
// 格式化金额
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${(amount / 10_000).toFixed(2)}万`;
|
||||
};
|
||||
|
||||
// 格式化金额(完整)
|
||||
const formatAmountFull = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN')}`;
|
||||
};
|
||||
|
||||
@@ -115,6 +110,12 @@ const formatPercent = (value: number | undefined) => {
|
||||
return `${value > 0 ? '+' : ''}${value.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
// 格式化百分比(不带符号)
|
||||
const formatPercentPlain = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
// 加载店铺数量
|
||||
const loadShopCount = async () => {
|
||||
try {
|
||||
@@ -155,9 +156,16 @@ const renderShopBarChart = () => {
|
||||
|
||||
const ratios = overviewData.value.shopSalesRatios;
|
||||
const shopNames = ratios.map((r) => r.shopName).reverse();
|
||||
const salesAmounts = ratios.map((r) => r.salesAmount / 1000).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) => {
|
||||
@@ -165,23 +173,32 @@ const renderShopBarChart = () => {
|
||||
const index = param.dataIndex;
|
||||
const shop = ratios[ratios.length - 1 - index];
|
||||
if (!shop) return '';
|
||||
return `${shop.shopName}<br/>销售额: ${formatAmountFull(shop.salesAmount)}<br/>占比: ${shop.ratio.toFixed(2)}%`;
|
||||
return `${shop.shopName}<br/>销售额: ${formatAmount(shop.salesAmount)}<br/>占比: ${shop.ratio.toFixed(2)}%`;
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
show: false,
|
||||
axisLabel: { show: false },
|
||||
splitLine: { show: false },
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: shopNames,
|
||||
axisLine: { show: false },
|
||||
axisTick: { show: false },
|
||||
axisLabel: {
|
||||
fontWeight: 'bold',
|
||||
color: '#1e293b',
|
||||
fontSize: 13,
|
||||
},
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
data: salesAmounts,
|
||||
barWidth: 20,
|
||||
itemStyle: {
|
||||
borderRadius: [0, 10, 10, 0],
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 1,
|
||||
@@ -193,9 +210,15 @@ const renderShopBarChart = () => {
|
||||
{ offset: 1, color: '#a5b4fc' },
|
||||
],
|
||||
},
|
||||
borderRadius: [0, 10, 10, 0],
|
||||
},
|
||||
barWidth: 25,
|
||||
label: {
|
||||
show: true,
|
||||
position: 'right',
|
||||
formatter: (params: any) =>
|
||||
`¥${params.value.toLocaleString('zh-CN')}`,
|
||||
fontWeight: 900,
|
||||
color: '#0f172a',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -207,52 +230,59 @@ const renderShopScatterChart = () => {
|
||||
return;
|
||||
|
||||
const quadrants = overviewData.value.shopEfficiencyQuadrants;
|
||||
const data = quadrants.map((q) => [q.roi, q.netProfit / 1000]); // 净利转换为千元
|
||||
const data = quadrants.map((q) => [
|
||||
q.roi,
|
||||
q.netProfit / 10_000, // 转换为万元
|
||||
q.shopName,
|
||||
]);
|
||||
|
||||
renderScatterChart({
|
||||
grid: {
|
||||
top: '10%',
|
||||
bottom: '10%',
|
||||
left: '10%',
|
||||
right: '10%',
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: (params: any) => {
|
||||
const index = params.dataIndex;
|
||||
const shop = quadrants[index];
|
||||
const shop = quadrants[params.dataIndex];
|
||||
if (!shop) return '';
|
||||
return `${shop.shopName}<br/>ROI: ${shop.roi.toFixed(2)}<br/>净利: ${formatAmountFull(shop.netProfit)}`;
|
||||
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: {
|
||||
name: 'ROI',
|
||||
name: '投资回报率 (ROI)',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 30,
|
||||
nameGap: 35,
|
||||
axisLabel: { fontWeight: 'bold' },
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
},
|
||||
lineStyle: { type: 'dashed' },
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
name: '净利(千元)',
|
||||
name: '税后净利润 (单位: 万元)',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 50,
|
||||
axisLabel: { fontWeight: 'bold' },
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
},
|
||||
lineStyle: { type: 'dashed' },
|
||||
},
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'scatter',
|
||||
symbolSize: 40,
|
||||
symbolSize: 45,
|
||||
data,
|
||||
itemStyle: {
|
||||
color: '#6366f1',
|
||||
opacity: 0.6,
|
||||
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 }],
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -290,142 +320,111 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page
|
||||
title="全店铺经营大盘"
|
||||
auto-content-height
|
||||
class="bg-gradient-to-br from-rose-50 via-indigo-50 to-green-50"
|
||||
>
|
||||
<Page title="全店铺经营概览大盘" auto-content-height class="bg-[#f8fafc]">
|
||||
<template #description>
|
||||
<div class="font-bold text-indigo-600">
|
||||
Company Dashboard · 共 {{ shopCount }} 家在营店铺
|
||||
<div class="mt-1 text-sm font-bold text-slate-500">
|
||||
数据范围:公司旗下所有店铺汇总统计 · 共 {{ shopCount }} 家在营店铺
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<div class="flex items-center gap-4">
|
||||
<!-- 汇总 ROI 和总税后盈亏 -->
|
||||
<div
|
||||
class="flex items-center gap-6 rounded-[2rem] border border-white/60 bg-white/50 px-6 py-3 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="text-center">
|
||||
<div class="text-[10px] font-bold uppercase text-slate-400">
|
||||
汇总 ROI
|
||||
</div>
|
||||
<div class="text-lg font-black">
|
||||
{{ overviewData?.totalROI?.toFixed(2) || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="h-8 w-px bg-slate-200"></div>
|
||||
<div class="text-center">
|
||||
<div class="text-[10px] font-bold uppercase text-slate-400">
|
||||
总税后盈亏
|
||||
</div>
|
||||
<div class="text-lg font-black text-emerald-600">
|
||||
{{
|
||||
overviewData?.totalProfitAfterTax
|
||||
? formatAmount(overviewData.totalProfitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 时间选择器组件 -->
|
||||
<div
|
||||
class="flex flex-wrap items-center gap-2 rounded-2xl border border-white/60 bg-white/40 p-1.5 shadow-[0_8px_32px_0_rgba(31,38,135,0.05)] backdrop-blur-[16px]"
|
||||
>
|
||||
<!-- 快速选择按钮 -->
|
||||
<div class="flex rounded-xl bg-white/30 p-1">
|
||||
<Button
|
||||
:type="activeTimeRange === 'today' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === 'today'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('today')"
|
||||
>
|
||||
今日
|
||||
</Button>
|
||||
<Button
|
||||
:type="activeTimeRange === 'yesterday' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === 'yesterday'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('yesterday')"
|
||||
>
|
||||
昨日
|
||||
</Button>
|
||||
<Button
|
||||
:type="activeTimeRange === '7days' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === '7days'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('7days')"
|
||||
>
|
||||
近7日
|
||||
</Button>
|
||||
<Button
|
||||
:type="activeTimeRange === '30days' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === '30days'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('30days')"
|
||||
>
|
||||
近30日
|
||||
</Button>
|
||||
</div>
|
||||
<!-- 分隔线 -->
|
||||
<div class="mx-1 h-6 w-px bg-slate-300"></div>
|
||||
<!-- 自定义时间 -->
|
||||
<div
|
||||
class="flex items-center gap-2 rounded-xl bg-white/30 px-3 py-1.5"
|
||||
<!-- 时间选择器 -->
|
||||
<div
|
||||
class="flex items-center gap-2 rounded-2xl border border-slate-200 bg-slate-200/50 p-1.5"
|
||||
>
|
||||
<!-- 快速选择按钮组 -->
|
||||
<div class="flex items-center gap-1 rounded-xl bg-white/30 p-1">
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
class="!h-auto !min-w-0 !rounded-xl !border-none !px-5 !py-2 !text-sm !font-bold !shadow-none !transition-colors"
|
||||
:class="
|
||||
activeTimeRange === 'today'
|
||||
? '!bg-white !text-blue-600 !shadow-sm'
|
||||
: '!bg-transparent !text-slate-600 hover:!bg-white/50'
|
||||
"
|
||||
@click="switchTimeRange('today')"
|
||||
>
|
||||
<span class="text-[10px] font-bold uppercase text-slate-400">
|
||||
自定义
|
||||
</span>
|
||||
<DatePicker.RangePicker
|
||||
v-model:value="customDateRange"
|
||||
size="small"
|
||||
format="YYYY-MM-DD"
|
||||
:allow-clear="false"
|
||||
class="!border-none !bg-transparent"
|
||||
:class="
|
||||
activeTimeRange === 'custom'
|
||||
? '[&_.ant-picker-input>input]:!font-bold [&_.ant-picker-input>input]:!text-indigo-600'
|
||||
: ''
|
||||
"
|
||||
@change="handleCustomDateRangeChange"
|
||||
/>
|
||||
</div>
|
||||
今日
|
||||
</Button>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
class="!h-auto !min-w-0 !rounded-xl !border-none !px-5 !py-2 !text-sm !font-bold !shadow-none !transition-colors"
|
||||
:class="
|
||||
activeTimeRange === 'yesterday'
|
||||
? '!bg-white !text-blue-600 !shadow-sm'
|
||||
: '!bg-transparent !text-slate-600 hover:!bg-white/50'
|
||||
"
|
||||
@click="switchTimeRange('yesterday')"
|
||||
>
|
||||
昨日
|
||||
</Button>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
class="!h-auto !min-w-0 !rounded-xl !border-none !px-5 !py-2 !text-sm !font-bold !shadow-none !transition-colors"
|
||||
:class="
|
||||
activeTimeRange === '7days'
|
||||
? '!bg-white !text-blue-600 !shadow-sm'
|
||||
: '!bg-transparent !text-slate-600 hover:!bg-white/50'
|
||||
"
|
||||
@click="switchTimeRange('7days')"
|
||||
>
|
||||
近7日
|
||||
</Button>
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
class="!h-auto !min-w-0 !rounded-xl !border-none !px-5 !py-2 !text-sm !font-bold !shadow-none !transition-colors"
|
||||
:class="
|
||||
activeTimeRange === '30days'
|
||||
? '!bg-white !text-blue-600 !shadow-sm'
|
||||
: '!bg-transparent !text-slate-600 hover:!bg-white/50'
|
||||
"
|
||||
@click="switchTimeRange('30days')"
|
||||
>
|
||||
近30日
|
||||
</Button>
|
||||
</div>
|
||||
<!-- 分隔线 -->
|
||||
<div class="h-6 w-px bg-slate-300"></div>
|
||||
<!-- 自定义日期选择器 -->
|
||||
<div class="flex items-center gap-2 rounded-xl bg-white/30 px-3 py-1.5">
|
||||
<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="!border-none !bg-transparent !text-sm !font-bold"
|
||||
@change="handleCustomDateRangeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<Spin :spinning="loading">
|
||||
<div class="mx-auto max-w-[1600px] space-y-8 p-6">
|
||||
<!-- 汇总卡片 -->
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-4">
|
||||
<!-- 全店总销售额 -->
|
||||
<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="rounded-[2rem] border border-white/60 bg-white/50 bg-gradient-to-br from-indigo-500/10 to-transparent p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
class="rounded-2xl border border-slate-200 bg-white/90 p-6 shadow-[0_4px_12px_rgba(0,0,0,0.03)] backdrop-blur-[10px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">全店总销售额</div>
|
||||
<div class="mt-1 text-3xl font-black">
|
||||
<div class="mb-4 flex items-start justify-between">
|
||||
<span class="text-xs font-black text-slate-500">
|
||||
全店总销售额
|
||||
</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)
|
||||
@@ -433,153 +432,346 @@ onMounted(async () => {
|
||||
}}
|
||||
</div>
|
||||
<div
|
||||
v-if="overviewData?.monthOverMonthGrowth !== undefined"
|
||||
class="mt-4 w-fit rounded-lg bg-emerald-50 px-2 py-1 text-xs font-bold text-emerald-500"
|
||||
v-if="overviewData?.salesAmountAchievementRate !== undefined"
|
||||
class="mt-6 flex items-center justify-between border-t border-slate-100 pt-4"
|
||||
>
|
||||
{{ formatPercent(overviewData.monthOverMonthGrowth) }} 较上月同期
|
||||
<span class="text-xs font-bold text-slate-400">
|
||||
销售额目标达成率
|
||||
</span>
|
||||
>
|
||||
<span class="text-sm font-black text-blue-600">
|
||||
{{
|
||||
formatPercentPlain(overviewData.salesAmountAchievementRate)
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全店总单量 -->
|
||||
<!-- ROI效率 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
class="rounded-2xl border border-slate-200 bg-white/90 p-6 shadow-[0_4px_12px_rgba(0,0,0,0.03)] backdrop-blur-[10px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">全店总单量</div>
|
||||
<div class="mt-1 text-3xl font-black">
|
||||
{{
|
||||
overviewData?.totalOrderCount?.toLocaleString('zh-CN') || '-'
|
||||
}}
|
||||
<div class="mb-4 text-xs font-black text-slate-500">
|
||||
投资回报率 (ROI)
|
||||
</div>
|
||||
<div class="mt-4 text-xs font-bold italic text-slate-400">
|
||||
目标达成率 92%
|
||||
<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 flex justify-between border-t border-slate-100 pt-4 text-xs font-bold text-slate-400"
|
||||
>
|
||||
<span>全店平均费比</span>
|
||||
<span class="text-slate-900">
|
||||
{{ formatPercentPlain(overviewData.averageFeeRatio) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 总推广费支出 -->
|
||||
<!-- 订单达成 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
class="rounded-2xl border border-slate-200 bg-white/90 p-6 shadow-[0_4px_12px_rgba(0,0,0,0.03)] backdrop-blur-[10px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">总推广费支出</div>
|
||||
<div class="mt-1 text-3xl font-black">
|
||||
<div class="mb-4 text-xs font-black text-slate-500">
|
||||
销量目标达成率 (订单数)
|
||||
</div>
|
||||
<div class="text-4xl font-black leading-none text-slate-900">
|
||||
{{
|
||||
overviewData?.totalPromotionFee
|
||||
? formatAmount(overviewData.totalPromotionFee)
|
||||
overviewData?.orderCountAchievementRate !== undefined
|
||||
? formatPercentPlain(overviewData.orderCountAchievementRate)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div class="mt-4 text-xs font-bold text-indigo-400">
|
||||
平均费比:
|
||||
{{
|
||||
overviewData?.averageFeeRatio
|
||||
? `${overviewData.averageFeeRatio.toFixed(1)}%`
|
||||
: '-'
|
||||
}}
|
||||
<div
|
||||
v-if="overviewData?.orderCountAchievementRate !== undefined"
|
||||
class="mt-6 h-2 w-full overflow-hidden rounded-full bg-slate-100"
|
||||
>
|
||||
<div
|
||||
class="h-full bg-indigo-500"
|
||||
:style="{
|
||||
width: `${Math.min(overviewData.orderCountAchievementRate, 100)}%`,
|
||||
}"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全店总净利 -->
|
||||
<!-- 税后利润 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 bg-gradient-to-br from-emerald-500/10 to-transparent p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
class="rounded-2xl border-l-4 border-slate-200 border-l-emerald-500 bg-white/90 p-6 shadow-[0_4px_12px_rgba(0,0,0,0.03)] backdrop-blur-[10px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">
|
||||
全店总净利 (税后)
|
||||
<div class="mb-4 text-xs font-black text-emerald-600">
|
||||
全店总净利润 (税后)
|
||||
</div>
|
||||
<div class="mt-1 text-3xl font-black text-emerald-600">
|
||||
<div class="text-4xl font-black leading-none text-emerald-600">
|
||||
{{
|
||||
overviewData?.totalNetProfitAfterTax
|
||||
? formatAmount(overviewData.totalNetProfitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div class="mt-4 text-xs font-bold text-slate-400">
|
||||
扣除总税额:
|
||||
{{
|
||||
overviewData?.totalTaxAmount
|
||||
? formatAmount(overviewData.totalTaxAmount)
|
||||
: '-'
|
||||
}}
|
||||
<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-8 lg:grid-cols-2">
|
||||
<!-- 店铺销售占比排行 -->
|
||||
<!-- 第二层:深度分析图表 -->
|
||||
<div class="grid grid-cols-1 gap-6 xl:grid-cols-2">
|
||||
<!-- 销售占比排行 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
class="rounded-2xl border border-slate-200 bg-white/90 p-8 shadow-[0_4px_12px_rgba(0,0,0,0.03)] backdrop-blur-[10px]"
|
||||
>
|
||||
<h3 class="mb-6 text-xl font-bold">各店铺销售占比排行</h3>
|
||||
<div class="h-[400px]">
|
||||
<h3 class="mb-6 text-lg font-black text-slate-800">
|
||||
各店铺销售贡献排行
|
||||
</h3>
|
||||
<div class="h-[380px] w-full">
|
||||
<EchartsUI ref="barChartRef" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 店铺效率象限 -->
|
||||
<!-- 效率象限图 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
class="rounded-2xl border border-slate-200 bg-white/90 p-8 shadow-[0_4px_12px_rgba(0,0,0,0.03)] backdrop-blur-[10px]"
|
||||
>
|
||||
<h3 class="mb-6 text-xl font-bold">店铺效率象限 (ROI vs 净利)</h3>
|
||||
<div class="h-[400px]">
|
||||
<h3 class="mb-6 text-lg font-black text-slate-800">
|
||||
店铺经营效率象限 (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"
|
||||
>
|
||||
<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"
|
||||
>
|
||||
<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"
|
||||
>
|
||||
<span class="h-3 w-3 rounded-full bg-rose-500"></span>
|
||||
风险区
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 店铺多维度对比表 -->
|
||||
<!-- 第三层:横向对比大表 (16维度) -->
|
||||
<div
|
||||
class="overflow-hidden rounded-[2rem] border border-white/60 bg-white/50 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
class="overflow-hidden rounded-2xl border border-slate-200 bg-white/90 shadow-[0_4px_12px_rgba(0,0,0,0.03)] backdrop-blur-[10px]"
|
||||
>
|
||||
<div class="flex items-center justify-between p-8">
|
||||
<h3 class="text-xl font-bold">多店铺数据横向对比</h3>
|
||||
<div
|
||||
class="flex flex-col items-start justify-between gap-4 border-b border-slate-100 p-8 md:flex-row md:items-center"
|
||||
>
|
||||
<div>
|
||||
<h3 class="text-xl font-black text-slate-800">
|
||||
各店铺多维度经营明细对比
|
||||
</h3>
|
||||
<p class="mt-1 text-xs font-bold text-slate-400">
|
||||
包含:目标达成、规模、成本及最终损益所有维度
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
type="primary"
|
||||
class="!h-auto !rounded-2xl !border-none !bg-slate-900 !px-8 !py-3 !text-sm !font-bold !shadow-xl !shadow-slate-200 !transition-all hover:!scale-105 active:!scale-95"
|
||||
>
|
||||
导出财务分析报表
|
||||
</Button>
|
||||
</div>
|
||||
<div class="overflow-x-auto px-4 pb-6">
|
||||
<table class="w-full border-collapse whitespace-nowrap text-left">
|
||||
|
||||
<div class="table-container overflow-x-auto">
|
||||
<table class="w-full whitespace-nowrap text-left text-sm">
|
||||
<!-- 表头分组 -->
|
||||
<thead
|
||||
class="border-b border-white/40 text-[11px] uppercase text-slate-400"
|
||||
class="bg-slate-50 text-[11px] font-black uppercase text-slate-500"
|
||||
>
|
||||
<tr>
|
||||
<th class="p-4 font-black">店铺名称</th>
|
||||
<th class="p-4 font-black">销售额</th>
|
||||
<th class="p-4 font-black text-indigo-600">ROI</th>
|
||||
<th class="p-4 font-black text-red-400">退款/刷单费</th>
|
||||
<th class="p-4 font-black">推广费总和</th>
|
||||
<th class="p-4 font-black text-emerald-600">税后盈亏</th>
|
||||
<th
|
||||
rowspan="2"
|
||||
class="sticky-col border-b p-6 text-sm font-black text-slate-900 shadow-sm"
|
||||
>
|
||||
店铺名称
|
||||
</th>
|
||||
<th
|
||||
colspan="4"
|
||||
class="border-b border-l border-slate-200 bg-blue-50/50 p-3 text-center text-blue-700"
|
||||
>
|
||||
目标达成维度
|
||||
</th>
|
||||
<th
|
||||
colspan="3"
|
||||
class="border-b border-l border-slate-200 bg-slate-100/50 p-3 text-center"
|
||||
>
|
||||
经营规模维度
|
||||
</th>
|
||||
<th
|
||||
colspan="5"
|
||||
class="border-b border-l border-slate-200 bg-orange-50/50 p-3 text-center text-orange-700"
|
||||
>
|
||||
成本费用维度
|
||||
</th>
|
||||
<th
|
||||
colspan="4"
|
||||
class="border-b border-l border-slate-200 bg-emerald-50/50 p-3 text-center text-emerald-700"
|
||||
>
|
||||
盈利分析维度
|
||||
</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 text-blue-600">单量达成率</th>
|
||||
<th class="border-b px-6 py-4">目标额</th>
|
||||
<th class="border-b px-6 py-4 text-blue-600">销售达成率</th>
|
||||
<!-- 规模 -->
|
||||
<th
|
||||
class="border-b border-l px-6 py-4 font-black text-slate-900"
|
||||
>
|
||||
实际销售额
|
||||
</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 font-bold text-rose-600">
|
||||
退款金额
|
||||
</th>
|
||||
<th class="border-b px-6 py-4">推广费</th>
|
||||
<th class="border-b px-6 py-4 text-orange-600">刷单费用</th>
|
||||
<th class="border-b px-6 py-4 text-slate-400">费比 %</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">
|
||||
4%税额
|
||||
</th>
|
||||
<th class="border-b px-6 py-4 font-black text-indigo-700">
|
||||
ROI
|
||||
</th>
|
||||
<th
|
||||
class="border-b bg-emerald-600 px-6 py-4 font-black text-white"
|
||||
>
|
||||
税后盈亏
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-sm">
|
||||
<tbody class="divide-y divide-slate-100">
|
||||
<tr
|
||||
v-for="shop in overviewData?.shopComparisons"
|
||||
:key="shop.shopId"
|
||||
class="border-t border-white/20 transition hover:bg-white/40"
|
||||
class="transition-colors hover:bg-blue-50/50"
|
||||
>
|
||||
<td class="p-4 font-bold">{{ shop.shopName }}</td>
|
||||
<td class="p-4">
|
||||
{{ formatAmountFull(shop.salesAmount) }}
|
||||
<td
|
||||
class="sticky-col border-r-2 border-slate-100 bg-white p-6 font-bold text-slate-900 shadow-sm"
|
||||
>
|
||||
{{ shop.shopName }}
|
||||
</td>
|
||||
<td class="p-4 font-black text-indigo-600">
|
||||
{{ shop.roi?.toFixed(2) || '-' }}
|
||||
<!-- 目标 -->
|
||||
<td class="p-6 font-medium">
|
||||
{{ shop.targetOrderCount?.toLocaleString('zh-CN') || '-' }}
|
||||
</td>
|
||||
<td class="p-4 text-red-400">
|
||||
{{ formatAmountFull(shop.refundAmount || 0) }} /
|
||||
{{ formatAmountFull(shop.brushFee || 0) }}
|
||||
</td>
|
||||
<td class="p-4">
|
||||
<td class="p-6 font-black text-blue-600">
|
||||
{{
|
||||
shop.totalPromotionFee
|
||||
? formatAmountFull(shop.totalPromotionFee)
|
||||
shop.orderCountAchievementRate !== undefined
|
||||
? formatPercentPlain(shop.orderCountAchievementRate)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-4 font-black text-emerald-600">
|
||||
<td class="p-6 font-medium">
|
||||
{{
|
||||
shop.targetAmount ? formatAmount(shop.targetAmount) : '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6 font-black text-blue-600">
|
||||
{{
|
||||
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.shippingCost ? formatAmount(shop.shippingCost) : '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6 font-bold text-rose-600">
|
||||
{{
|
||||
shop.refundAmount ? formatAmount(shop.refundAmount) : '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{
|
||||
shop.totalPromotionFee
|
||||
? formatAmount(shop.totalPromotionFee)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6 text-orange-600">
|
||||
{{ shop.brushFee ? formatAmount(shop.brushFee) : '-' }}
|
||||
</td>
|
||||
<td class="p-6 text-slate-400">
|
||||
{{
|
||||
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">
|
||||
{{
|
||||
shop.salesTaxAmount
|
||||
? formatAmount(shop.salesTaxAmount)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6 font-black text-indigo-700">
|
||||
{{ shop.roi?.toFixed(2) || '-' }}
|
||||
</td>
|
||||
<td
|
||||
class="bg-emerald-50 p-6 text-base font-black text-emerald-600"
|
||||
>
|
||||
{{
|
||||
shop.profitAfterTax
|
||||
? formatAmountFull(shop.profitAfterTax)
|
||||
? formatAmount(shop.profitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!overviewData?.shopComparisons?.length">
|
||||
<td colspan="6" class="p-8 text-center text-gray-400">
|
||||
<td colspan="17" class="p-8 text-center text-gray-400">
|
||||
暂无数据
|
||||
</td>
|
||||
</tr>
|
||||
@@ -593,5 +785,22 @@ onMounted(async () => {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 自定义样式 */
|
||||
/* 表格滚动条 */
|
||||
.table-container::-webkit-scrollbar {
|
||||
height: 8px;
|
||||
}
|
||||
.table-container::-webkit-scrollbar-thumb {
|
||||
background: #cbd5e1;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.table-container::-webkit-scrollbar-track {
|
||||
background: #f1f5f9;
|
||||
}
|
||||
|
||||
/* 固定首列 */
|
||||
.sticky-col {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
z-index: 10;
|
||||
}
|
||||
</style>
|
||||
|
||||
+274
@@ -0,0 +1,274 @@
|
||||
<script setup lang="ts">
|
||||
import type {
|
||||
ShopMonthlyTargetDTO,
|
||||
ShopMonthlyTargetVO,
|
||||
} from '#/api/ecommerce/shop-monthly-target';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
DatePicker,
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
Select,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
createShopMonthlyTargetApi,
|
||||
updateShopMonthlyTargetApi,
|
||||
} from '#/api/ecommerce/shop-monthly-target';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'ShopMonthlyTargetFormModal' });
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// Props
|
||||
interface Props {
|
||||
open: boolean;
|
||||
shopMonthlyTargetData?: null | ShopMonthlyTargetVO.Info;
|
||||
}
|
||||
|
||||
// Emits
|
||||
interface Emits {
|
||||
(e: 'update:open', value: boolean): void;
|
||||
(e: 'success'): void;
|
||||
(e: 'cancel'): void;
|
||||
}
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[700px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
onConfirm() {
|
||||
handleOk();
|
||||
},
|
||||
});
|
||||
|
||||
// 响应式数据
|
||||
const formRef = ref();
|
||||
const isEdit = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<ShopMonthlyTargetDTO.Create>({
|
||||
shopId: undefined as any,
|
||||
targetMonth: '',
|
||||
targetAmount: undefined as any,
|
||||
targetOrderCount: undefined as any,
|
||||
remark: '',
|
||||
});
|
||||
|
||||
// 目标月份选择器的值(dayjs对象)
|
||||
const targetMonthValue = ref<dayjs.Dayjs | null>(null);
|
||||
|
||||
// 表单验证规则
|
||||
const rules = {
|
||||
shopId: [{ required: true, message: '请选择店铺', trigger: 'change' }],
|
||||
targetMonth: [
|
||||
{ required: true, message: '请选择目标月份', trigger: 'change' },
|
||||
],
|
||||
targetAmount: [
|
||||
{ required: true, message: '请输入目标销售额', trigger: 'blur' },
|
||||
],
|
||||
targetOrderCount: [
|
||||
{ required: true, message: '请输入目标订单数', trigger: 'blur' },
|
||||
],
|
||||
} as any;
|
||||
|
||||
// 店铺列表
|
||||
const shopList = ref<ShopVO.Info[]>([]);
|
||||
const shopListLoading = ref(false);
|
||||
|
||||
// 监听props变化
|
||||
watch(
|
||||
() => props.open,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
modalApi.open();
|
||||
isEdit.value = !!props.shopMonthlyTargetData;
|
||||
if (props.shopMonthlyTargetData) {
|
||||
// 编辑模式,填充表单数据
|
||||
formData.value = {
|
||||
shopId: props.shopMonthlyTargetData.shopId,
|
||||
targetMonth: props.shopMonthlyTargetData.targetMonth,
|
||||
targetAmount: props.shopMonthlyTargetData.targetAmount,
|
||||
targetOrderCount: props.shopMonthlyTargetData.targetOrderCount,
|
||||
remark: props.shopMonthlyTargetData.remark || '',
|
||||
};
|
||||
// 设置目标月份选择器的值
|
||||
targetMonthValue.value = dayjs(props.shopMonthlyTargetData.targetMonth);
|
||||
} else {
|
||||
// 新增模式,重置表单数据
|
||||
resetFormData();
|
||||
}
|
||||
} else {
|
||||
modalApi.close();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
// 监听目标月份选择器变化
|
||||
watch(
|
||||
() => targetMonthValue.value,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
// 格式化为 YYYY-MM-01
|
||||
formData.value.targetMonth = newVal.format('YYYY-MM-01');
|
||||
} else {
|
||||
formData.value.targetMonth = '';
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 加载店铺列表
|
||||
const loadShopList = async () => {
|
||||
shopListLoading.value = true;
|
||||
try {
|
||||
const response = await getShopPageApi({
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
filters: {},
|
||||
});
|
||||
shopList.value = response.records;
|
||||
} catch (error) {
|
||||
console.error('加载店铺列表失败:', error);
|
||||
} finally {
|
||||
shopListLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 重置表单数据
|
||||
const resetFormData = () => {
|
||||
formData.value = {
|
||||
shopId: undefined as any,
|
||||
targetMonth: '',
|
||||
targetAmount: undefined as any,
|
||||
targetOrderCount: undefined as any,
|
||||
remark: '',
|
||||
};
|
||||
targetMonthValue.value = null;
|
||||
};
|
||||
|
||||
// 确认操作
|
||||
const handleOk = async () => {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
|
||||
if (isEdit.value && props.shopMonthlyTargetData) {
|
||||
// 更新店铺月销量目标
|
||||
const updateData: ShopMonthlyTargetDTO.Update = {
|
||||
targetMonth: formData.value.targetMonth,
|
||||
targetAmount: formData.value.targetAmount,
|
||||
targetOrderCount: formData.value.targetOrderCount,
|
||||
remark: formData.value.remark,
|
||||
};
|
||||
await updateShopMonthlyTargetApi(
|
||||
props.shopMonthlyTargetData.id,
|
||||
updateData,
|
||||
);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
// 创建店铺月销量目标
|
||||
await createShopMonthlyTargetApi(formData.value);
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
} catch (error) {
|
||||
console.error('操作失败:', error);
|
||||
message.error(isEdit.value ? '更新失败' : '创建失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 取消操作
|
||||
const handleCancel = () => {
|
||||
emit('cancel');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
resetFormData();
|
||||
};
|
||||
|
||||
// 组件挂载时加载数据
|
||||
onMounted(() => {
|
||||
loadShopList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="isEdit ? '编辑月销量目标' : '新增月销量目标'">
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item label="店铺" name="shopId" required>
|
||||
<Select
|
||||
v-model:value="formData.shopId"
|
||||
placeholder="请选择店铺"
|
||||
:loading="shopListLoading"
|
||||
:options="
|
||||
shopList.map((shop) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}))
|
||||
"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="目标月份" name="targetMonth" required>
|
||||
<DatePicker
|
||||
v-model:value="targetMonthValue"
|
||||
placeholder="请选择目标月份"
|
||||
picker="month"
|
||||
format="YYYY-MM"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="目标销售额" name="targetAmount" required>
|
||||
<InputNumber
|
||||
v-model:value="formData.targetAmount"
|
||||
placeholder="请输入目标销售额"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="目标订单数" name="targetOrderCount" required>
|
||||
<InputNumber
|
||||
v-model:value="formData.targetOrderCount"
|
||||
placeholder="请输入目标订单数"
|
||||
:min="0"
|
||||
:precision="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input.TextArea
|
||||
v-model:value="formData.remark"
|
||||
placeholder="请输入备注(可选)"
|
||||
:rows="4"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,330 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type {
|
||||
ShopMonthlyTargetDTO,
|
||||
ShopMonthlyTargetVO,
|
||||
} from '#/api/ecommerce/shop-monthly-target';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, message, Popconfirm, Space } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import {
|
||||
deleteShopMonthlyTargetApi,
|
||||
getShopMonthlyTargetPageApi,
|
||||
} from '#/api/ecommerce/shop-monthly-target';
|
||||
|
||||
import ShopMonthlyTargetFormModal from './components/ShopMonthlyTargetFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'ShopMonthlyTargetManagement' });
|
||||
|
||||
// 创建图标组件
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const formModalVisible = ref(false);
|
||||
const currentShopMonthlyTargetData = ref<null | ShopMonthlyTargetVO.Info>(null);
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
shopId: undefined as number | undefined,
|
||||
startTargetMonth: undefined as string | undefined,
|
||||
endTargetMonth: undefined as string | undefined,
|
||||
});
|
||||
|
||||
// 店铺选项
|
||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
field: 'shopName',
|
||||
title: '店铺名称',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'targetMonth',
|
||||
title: '目标月份',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
title: '目标销售额',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'targetAmount' },
|
||||
},
|
||||
{
|
||||
field: 'targetOrderCount',
|
||||
title: '目标订单数',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 'auto',
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
highlightHoverRow: true,
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
zoom: true,
|
||||
},
|
||||
data: [],
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
layouts: [
|
||||
'PrevJump',
|
||||
'PrevPage',
|
||||
'Number',
|
||||
'NextPage',
|
||||
'NextJump',
|
||||
'Sizes',
|
||||
'FullJump',
|
||||
'Total',
|
||||
] as (
|
||||
| 'FullJump'
|
||||
| 'NextJump'
|
||||
| 'NextPage'
|
||||
| 'Number'
|
||||
| 'PrevJump'
|
||||
| 'PrevPage'
|
||||
| 'Sizes'
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
// 配置远程加载
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<ShopMonthlyTargetDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: searchForm.value.shopId,
|
||||
startTargetMonth: searchForm.value.startTargetMonth,
|
||||
endTargetMonth: searchForm.value.endTargetMonth,
|
||||
},
|
||||
};
|
||||
const data = await getShopMonthlyTargetPageApi(params);
|
||||
return {
|
||||
items: data.records,
|
||||
total: data.total,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取店铺月销量目标列表失败:', error);
|
||||
message.error('获取店铺月销量目标列表失败');
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择店铺',
|
||||
options: shopOptions.value,
|
||||
allowClear: true,
|
||||
},
|
||||
fieldName: 'shopId',
|
||||
label: '店铺',
|
||||
},
|
||||
{
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
placeholder: '开始月份',
|
||||
picker: 'month',
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'startTargetMonth',
|
||||
label: '目标月份',
|
||||
},
|
||||
{
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
placeholder: '结束月份',
|
||||
picker: 'month',
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'endTargetMonth',
|
||||
label: '至',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
collapsedRows: 1,
|
||||
}));
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
if (gridApi) {
|
||||
gridApi.reload();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建 VbenVxeGrid 实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '店铺月销量目标管理',
|
||||
});
|
||||
|
||||
// 处理新增
|
||||
const handleAdd = () => {
|
||||
currentShopMonthlyTargetData.value = null;
|
||||
formModalVisible.value = true;
|
||||
};
|
||||
|
||||
// 处理编辑
|
||||
const handleEdit = (record: ShopMonthlyTargetVO.Info) => {
|
||||
currentShopMonthlyTargetData.value = record;
|
||||
formModalVisible.value = true;
|
||||
};
|
||||
|
||||
// 处理删除
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await deleteShopMonthlyTargetApi(id);
|
||||
message.success('删除成功');
|
||||
refreshTable();
|
||||
} catch {
|
||||
message.error('删除失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 处理表单成功
|
||||
const handleFormSuccess = () => {
|
||||
refreshTable();
|
||||
};
|
||||
|
||||
// 格式化金额
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toFixed(2)}`;
|
||||
};
|
||||
|
||||
// 获取店铺选项
|
||||
const fetchShopOptions = async () => {
|
||||
try {
|
||||
const response = await getShopPageApi({
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
filters: {},
|
||||
});
|
||||
shopOptions.value = response.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('获取店铺列表失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
fetchShopOptions();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="店铺月销量目标管理" auto-content-height>
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
管理店铺月销量目标,支持按店铺、目标月份等维度查询和统计
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-2 h-4 w-4" />
|
||||
新增月销量目标
|
||||
</Button>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<Grid :loading="loading">
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<span class="text-gray-500">
|
||||
支持按店铺、目标月份等维度查询月销量目标
|
||||
</span>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 目标销售额列 -->
|
||||
<template #targetAmount="{ row }: { row: any }">
|
||||
<span class="font-medium text-red-600">
|
||||
{{ formatAmount(row.targetAmount) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }: { row: any }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这条月销量目标吗?"
|
||||
@confirm="handleDelete(row.id)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<!-- 表单弹窗 -->
|
||||
<ShopMonthlyTargetFormModal
|
||||
v-model:open="formModalVisible"
|
||||
:shop-monthly-target-data="currentShopMonthlyTargetData"
|
||||
@success="handleFormSuccess"
|
||||
@cancel="formModalVisible = false"
|
||||
/>
|
||||
</Page>
|
||||
</template>
|
||||
Reference in New Issue
Block a user