mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 06:29:20 +08:00
feat: 经营趋势增加单量统计
This commit is contained in:
@@ -37,8 +37,12 @@ export namespace WorkbenchVO {
|
||||
date: string;
|
||||
/** 日成交金额(元):全部订单状态商家实收 */
|
||||
dealYuan?: number;
|
||||
/** 日成交单量:与 KPI「成交单量」同口径 */
|
||||
dealOrderCount?: number;
|
||||
/** 日实际销售额(元),与 KPI「实际销售额」同口径 */
|
||||
salesYuan?: number;
|
||||
/** 日实际销售单量:与 KPI「销售单量」同口径 */
|
||||
salesOrderCount?: number;
|
||||
/** 日毛利润(元)= 销售额−成本−退款 */
|
||||
profitYuan?: number;
|
||||
/** 日净利润(元),与 KPI「净利润」及多维分析分摊口径一致 */
|
||||
|
||||
+68
-7
@@ -29,6 +29,8 @@ const hasData = computed(
|
||||
(d) =>
|
||||
Number(d.dealYuan ?? 0) !== 0 ||
|
||||
Number(d.salesYuan ?? 0) !== 0 ||
|
||||
Number(d.dealOrderCount ?? 0) !== 0 ||
|
||||
Number(d.salesOrderCount ?? 0) !== 0 ||
|
||||
Number(d.profitYuan ?? 0) !== 0 ||
|
||||
Number(d.netProfitYuan ?? 0) !== 0,
|
||||
),
|
||||
@@ -39,15 +41,19 @@ const periodSummary = computed(() => {
|
||||
let sales = 0;
|
||||
let gross = 0;
|
||||
let net = 0;
|
||||
let dealOrders = 0;
|
||||
let salesOrders = 0;
|
||||
for (const d of props.trend) {
|
||||
deal += Number(d.dealYuan ?? 0);
|
||||
sales += Number(d.salesYuan ?? 0);
|
||||
gross += Number(d.profitYuan ?? 0);
|
||||
net += Number(d.netProfitYuan ?? 0);
|
||||
dealOrders += Number(d.dealOrderCount ?? 0);
|
||||
salesOrders += Number(d.salesOrderCount ?? 0);
|
||||
}
|
||||
const netMarginPct =
|
||||
sales > 0 ? Number(((net / sales) * 100).toFixed(1)) : null;
|
||||
return { deal, sales, gross, net, netMarginPct };
|
||||
return { deal, sales, gross, net, netMarginPct, dealOrders, salesOrders };
|
||||
});
|
||||
|
||||
function pctOfSales(part: number, sales: number): string {
|
||||
@@ -79,6 +85,8 @@ function drawFinanceTrend() {
|
||||
|
||||
const dealWan = props.trend.map((d) => yuanToWanNum(Number(d.dealYuan ?? 0)));
|
||||
const salesWan = props.trend.map((d) => yuanToWanNum(Number(d.salesYuan ?? 0)));
|
||||
const dealOrders = props.trend.map((d) => Number(d.dealOrderCount ?? 0));
|
||||
const salesOrders = props.trend.map((d) => Number(d.salesOrderCount ?? 0));
|
||||
const grossWan = props.trend.map((d) => yuanToWanNum(Number(d.profitYuan ?? 0)));
|
||||
const netWan = props.trend.map((d) => yuanToWanNum(Number(d.netProfitYuan ?? 0)));
|
||||
const refundWan = props.trend.map((d) => yuanToWanNum(Number(d.refundYuan ?? 0)));
|
||||
@@ -105,6 +113,8 @@ function drawFinanceTrend() {
|
||||
if (!row) return '';
|
||||
const deal = Number(row.dealYuan ?? 0);
|
||||
const sales = Number(row.salesYuan ?? 0);
|
||||
const dealOrder = Number(row.dealOrderCount ?? 0);
|
||||
const salesOrder = Number(row.salesOrderCount ?? 0);
|
||||
const gross = Number(row.profitYuan ?? 0);
|
||||
const net = Number(row.netProfitYuan ?? 0);
|
||||
const refund = Number(row.refundYuan ?? 0);
|
||||
@@ -114,7 +124,9 @@ function drawFinanceTrend() {
|
||||
const lines: string[] = [
|
||||
`<div style="font-weight:800;margin-bottom:6px">${title}</div>`,
|
||||
`<span style="color:${isDark ? '#fbbf24' : '#d97706'}">●</span> 成交金额:${formatWanWithYuanDetail(deal)}`,
|
||||
`<span style="color:${isDark ? '#f59e0b' : '#b45309'}">●</span> 成交单量:${dealOrder} 单`,
|
||||
`<span style="color:${isDark ? '#60a5fa' : '#1d4ed8'}">●</span> 实际销售额:${formatWanWithYuanDetail(sales)}`,
|
||||
`<span style="color:${isDark ? '#38bdf8' : '#0369a1'}">●</span> 实际销售单量:${salesOrder} 单`,
|
||||
`<span style="color:${isDark ? '#34d399' : '#059669'}">●</span> 毛利:${formatWanWithYuanDetail(gross)} <span style="opacity:0.75">(毛利率 ${pctOfSales(gross, sales)})</span>`,
|
||||
`<span style="color:${isDark ? '#c4b5fd' : '#6d28d9'}">●</span> 净利:${formatWanWithYuanDetail(net)} <span style="opacity:0.75">(净利率 ${pctOfSales(net, sales)})</span>`,
|
||||
];
|
||||
@@ -134,6 +146,8 @@ function drawFinanceTrend() {
|
||||
data: [
|
||||
'成交金额',
|
||||
'实际销售额',
|
||||
'成交单量',
|
||||
'实际销售单量',
|
||||
'毛利',
|
||||
'净利',
|
||||
'退款',
|
||||
@@ -141,13 +155,14 @@ function drawFinanceTrend() {
|
||||
],
|
||||
selected: {
|
||||
退款: props.trend.some((d) => Number(d.refundYuan ?? 0) > 0),
|
||||
净利率: false,
|
||||
},
|
||||
},
|
||||
grid: {
|
||||
left: '2%',
|
||||
right: '4%',
|
||||
right: '6%',
|
||||
bottom: showDataZoom ? 48 : '3%',
|
||||
top: 72,
|
||||
top: 88,
|
||||
containLabel: true,
|
||||
},
|
||||
dataZoom: showDataZoom
|
||||
@@ -189,9 +204,19 @@ function drawFinanceTrend() {
|
||||
},
|
||||
{
|
||||
type: 'value',
|
||||
name: '净利率(%)',
|
||||
name: '单量',
|
||||
nameTextStyle: { color: axisLabel, fontSize: 11, fontWeight: 700 },
|
||||
splitLine: { show: false },
|
||||
axisLabel: {
|
||||
color: axisLabel,
|
||||
formatter: (v: number) => (Number.isFinite(v) ? String(v) : ''),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'value',
|
||||
name: '净利率(%)',
|
||||
show: false,
|
||||
splitLine: { show: false },
|
||||
axisLabel: {
|
||||
color: axisLabel,
|
||||
formatter: (v: number) => `${v}%`,
|
||||
@@ -240,6 +265,40 @@ function drawFinanceTrend() {
|
||||
data: salesWan,
|
||||
z: 1,
|
||||
},
|
||||
{
|
||||
name: '成交单量',
|
||||
type: 'line',
|
||||
yAxisIndex: 1,
|
||||
smooth: 0.35,
|
||||
symbol: 'circle',
|
||||
symbolSize: 6,
|
||||
showSymbol: props.trend.length <= 31,
|
||||
lineStyle: { width: 2.5, color: isDark ? '#f59e0b' : '#b45309' },
|
||||
itemStyle: {
|
||||
color: isDark ? '#f59e0b' : '#b45309',
|
||||
borderWidth: 2,
|
||||
borderColor: isDark ? '#0f172a' : '#fff',
|
||||
},
|
||||
data: dealOrders,
|
||||
z: 5,
|
||||
},
|
||||
{
|
||||
name: '实际销售单量',
|
||||
type: 'line',
|
||||
yAxisIndex: 1,
|
||||
smooth: 0.35,
|
||||
symbol: 'circle',
|
||||
symbolSize: 6,
|
||||
showSymbol: props.trend.length <= 31,
|
||||
lineStyle: { width: 2.5, color: isDark ? '#38bdf8' : '#0369a1' },
|
||||
itemStyle: {
|
||||
color: isDark ? '#38bdf8' : '#0369a1',
|
||||
borderWidth: 2,
|
||||
borderColor: isDark ? '#0f172a' : '#fff',
|
||||
},
|
||||
data: salesOrders,
|
||||
z: 5,
|
||||
},
|
||||
{
|
||||
name: '毛利',
|
||||
type: 'line',
|
||||
@@ -288,7 +347,7 @@ function drawFinanceTrend() {
|
||||
{
|
||||
name: '净利率',
|
||||
type: 'line',
|
||||
yAxisIndex: 1,
|
||||
yAxisIndex: 2,
|
||||
smooth: 0.35,
|
||||
symbol: 'none',
|
||||
lineStyle: {
|
||||
@@ -298,7 +357,7 @@ function drawFinanceTrend() {
|
||||
},
|
||||
itemStyle: { color: isDark ? '#94a3b8' : '#64748b' },
|
||||
data: netMarginPct,
|
||||
z: 5,
|
||||
z: 6,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -374,7 +433,7 @@ defineExpose({ redraw });
|
||||
经营趋势
|
||||
</h3>
|
||||
<p class="mt-1 text-xs font-normal text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
柱状为成交金额 / 实际销售额,折线为毛利 / 净利;右轴为日净利率
|
||||
柱状为成交金额 / 实际销售额,折线含成交单量 / 实际销售单量与毛利 / 净利
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
@@ -385,11 +444,13 @@ defineExpose({ redraw });
|
||||
class="rounded-lg bg-amber-50 px-2.5 py-1 text-amber-700 dark:bg-amber-950/50 dark:text-amber-300"
|
||||
>
|
||||
区间成交 {{ formatWanWithYuanDetail(periodSummary.deal) }}
|
||||
· {{ periodSummary.dealOrders }} 单
|
||||
</span>
|
||||
<span
|
||||
class="rounded-lg bg-blue-50 px-2.5 py-1 text-blue-600 dark:bg-blue-950/50 dark:text-blue-300"
|
||||
>
|
||||
区间销售 {{ formatWanWithYuanDetail(periodSummary.sales) }}
|
||||
· {{ periodSummary.salesOrders }} 单
|
||||
</span>
|
||||
<span
|
||||
class="rounded-lg bg-violet-50 px-2.5 py-1 text-violet-600 dark:bg-violet-950/50 dark:text-violet-300"
|
||||
|
||||
Reference in New Issue
Block a user