mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
feat: 优化工作台动画交互
This commit is contained in:
+2
-2
@@ -5,12 +5,12 @@ import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/** 工作台 KPI 瘦项。 */
|
||||
/** 工作台 KPI 瘦项(value 为原始数值,展示格式化由调用方负责)。 */
|
||||
@Data
|
||||
@Builder
|
||||
public class BiKpiSlimVO {
|
||||
private String label;
|
||||
private String value;
|
||||
private BigDecimal value;
|
||||
private String unit;
|
||||
private BigDecimal changePct;
|
||||
private BigDecimal yoyChangePct;
|
||||
|
||||
+8
-1
@@ -7,6 +7,9 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 工作台 KPI 项:value 为原始数值,千分位等展示由前端负责。
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@@ -15,7 +18,11 @@ public class WorkbenchKpiItemVO {
|
||||
|
||||
private String label;
|
||||
|
||||
private String value;
|
||||
/**
|
||||
* 主指标原始值(金额为元、单量为笔、销量为件、比率为百分数、ROI 为倍数)。
|
||||
* 不含千分位格式化。
|
||||
*/
|
||||
private BigDecimal value;
|
||||
|
||||
private String unit;
|
||||
|
||||
|
||||
+22
-35
@@ -32,8 +32,6 @@ import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
@@ -42,7 +40,6 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@@ -657,77 +654,76 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
||||
List<WorkbenchKpiItemVO> list = new ArrayList<>();
|
||||
|
||||
// —— 成交口径(不含已取消/未知)——
|
||||
list.add(kpi("成交金额", formatYuanComma(cur.totalDealAmount()), "元", cur.totalDealAmount(), prev.totalDealAmount(), yoy.totalDealAmount(),
|
||||
list.add(kpi("成交金额", yuan2(cur.totalDealAmount()), "元", cur.totalDealAmount(), prev.totalDealAmount(), yoy.totalDealAmount(),
|
||||
"成交状态实收", cur.totalDealAmount(), true));
|
||||
list.add(kpiCount("成交单量", cur.dealOrderCount(), prev.dealOrderCount(), yoy.dealOrderCount(), "单",
|
||||
"日均 " + avgDailyDealOrders.stripTrailingZeros().toPlainString() + " 单"));
|
||||
list.add(kpiCount("成交销量", cur.dealQuantitySum(), prev.dealQuantitySum(), yoy.dealQuantitySum(), "件", "成交状态件数"));
|
||||
list.add(kpi("成交客单价", formatYuanComma(cur.dealAverageOrderValue()), "元",
|
||||
list.add(kpi("成交客单价", yuan2(cur.dealAverageOrderValue()), "元",
|
||||
cur.dealAverageOrderValue(), prev.dealAverageOrderValue(), yoy.dealAverageOrderValue(),
|
||||
"成交金额/成交单量", cur.dealAverageOrderValue(), false));
|
||||
|
||||
// —— 净销售口径(成交 − 退款)——
|
||||
list.add(kpi("净销售额", formatYuanComma(cur.totalSales()), "元", cur.totalSales(), prev.totalSales(), yoy.totalSales(),
|
||||
list.add(kpi("净销售额", yuan2(cur.totalSales()), "元", cur.totalSales(), prev.totalSales(), yoy.totalSales(),
|
||||
"成交−退款", cur.totalSales(), true));
|
||||
list.add(kpiCount("净销售单量", cur.orderCount(), prev.orderCount(), yoy.orderCount(), "单",
|
||||
"日均 " + avgDailySalesOrders.stripTrailingZeros().toPlainString() + " 单"));
|
||||
list.add(kpiCount("净销量", cur.salesQuantitySum(), prev.salesQuantitySum(), yoy.salesQuantitySum(), "件",
|
||||
"成交件数−退款件数"));
|
||||
list.add(kpi("净销售客单价", formatYuanComma(cur.averageOrderValue()), "元",
|
||||
list.add(kpi("净销售客单价", yuan2(cur.averageOrderValue()), "元",
|
||||
cur.averageOrderValue(), prev.averageOrderValue(), yoy.averageOrderValue(),
|
||||
"净销售额/净销售单量", cur.averageOrderValue(), false));
|
||||
|
||||
// —— 退款 ——
|
||||
list.add(kpi("退款额", formatYuanComma(cur.totalRefund()), "元", cur.totalRefund(), prev.totalRefund(), yoy.totalRefund(),
|
||||
list.add(kpi("退款额", yuan2(cur.totalRefund()), "元", cur.totalRefund(), prev.totalRefund(), yoy.totalRefund(),
|
||||
"计入退款状态", cur.totalRefund(), true));
|
||||
list.add(kpi("退款率", refundRate.setScale(2, RoundingMode.HALF_UP).toPlainString(), "%",
|
||||
list.add(kpi("退款率", refundRate.setScale(2, RoundingMode.HALF_UP), "%",
|
||||
refundRate, safePct(prev.totalRefund(), prev.totalSales()), safePct(yoy.totalRefund(), yoy.totalSales()),
|
||||
"退款/净销售额", null, null));
|
||||
|
||||
// —— 成本 ——
|
||||
list.add(kpi("订单成本", formatYuanComma(cur.totalCost()), "元", cur.totalCost(), prev.totalCost(), yoy.totalCost(),
|
||||
list.add(kpi("订单成本", yuan2(cur.totalCost()), "元", cur.totalCost(), prev.totalCost(), yoy.totalCost(),
|
||||
"成本率 " + costRate.stripTrailingZeros().toPlainString() + "%", cur.totalCost(), true));
|
||||
list.add(kpi("商品成本", formatYuanComma(cur.productCost()), "元", cur.productCost(), prev.productCost(), yoy.productCost(),
|
||||
list.add(kpi("商品成本", yuan2(cur.productCost()), "元", cur.productCost(), prev.productCost(), yoy.productCost(),
|
||||
null, cur.productCost(), true));
|
||||
list.add(kpi("运费成本", formatYuanComma(cur.freightCost()), "元", cur.freightCost(), prev.freightCost(), yoy.freightCost(),
|
||||
list.add(kpi("运费成本", yuan2(cur.freightCost()), "元", cur.freightCost(), prev.freightCost(), yoy.freightCost(),
|
||||
null, cur.freightCost(), true));
|
||||
list.add(kpi("其他成本", formatYuanComma(cur.otherCost()), "元", cur.otherCost(), prev.otherCost(), yoy.otherCost(),
|
||||
list.add(kpi("其他成本", yuan2(cur.otherCost()), "元", cur.otherCost(), prev.otherCost(), yoy.otherCost(),
|
||||
null, cur.otherCost(), true));
|
||||
|
||||
// —— 利润与费用 ——
|
||||
list.add(kpi("毛利润", formatYuanComma(cur.grossOrder()), "元", cur.grossOrder(), prev.grossOrder(), yoy.grossOrder(),
|
||||
list.add(kpi("毛利润", yuan2(cur.grossOrder()), "元", cur.grossOrder(), prev.grossOrder(), yoy.grossOrder(),
|
||||
"毛利率 " + grossMarginPct.stripTrailingZeros().toPlainString() + "%", cur.grossOrder(), true));
|
||||
list.add(kpi("推广费", formatYuanComma(cur.promotion()), "元", cur.promotion(), prev.promotion(), yoy.promotion(),
|
||||
list.add(kpi("推广费", yuan2(cur.promotion()), "元", cur.promotion(), prev.promotion(), yoy.promotion(),
|
||||
null, cur.promotion(), true));
|
||||
list.add(kpi("刷单费", formatYuanComma(cur.brush()), "元", cur.brush(), prev.brush(), yoy.brush(),
|
||||
list.add(kpi("刷单费", yuan2(cur.brush()), "元", cur.brush(), prev.brush(), yoy.brush(),
|
||||
null, cur.brush(), true));
|
||||
list.add(kpi("税额", formatYuanComma(cur.tax()), "元", cur.tax(), prev.tax(), yoy.tax(),
|
||||
list.add(kpi("税额", yuan2(cur.tax()), "元", cur.tax(), prev.tax(), yoy.tax(),
|
||||
"税率 " + taxRate.multiply(new BigDecimal("100")).stripTrailingZeros().toPlainString() + "%",
|
||||
cur.tax(), true));
|
||||
list.add(kpi("净利润", formatYuanComma(cur.netProfit()), "元", cur.netProfit(), prev.netProfit(), yoy.netProfit(),
|
||||
list.add(kpi("净利润", yuan2(cur.netProfit()), "元", cur.netProfit(), prev.netProfit(), yoy.netProfit(),
|
||||
"净利率 " + netMarginPct.stripTrailingZeros().toPlainString() + "%",
|
||||
cur.netProfit(), true));
|
||||
|
||||
// —— 运营效率 ——
|
||||
list.add(kpi("广告ROI", roi.stripTrailingZeros().toPlainString(), ":1", roi, prevRoi, yoyRoi,
|
||||
list.add(kpi("广告ROI", roi.setScale(2, RoundingMode.HALF_UP).stripTrailingZeros(), ":1", roi, prevRoi, yoyRoi,
|
||||
"净销售额/推广费", null, null));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/** 非金额类 KPI(单量、件数等) */
|
||||
/** 非金额类 KPI(单量、件数等):value 为原始整数 */
|
||||
private WorkbenchKpiItemVO kpiCount(String label, int cur, int prev, int yoy, String unit, String sub) {
|
||||
DecimalFormat df = new DecimalFormat("#,###", DecimalFormatSymbols.getInstance(Locale.CHINA));
|
||||
return kpi(label, df.format(cur), unit,
|
||||
return kpi(label, BigDecimal.valueOf(cur), unit,
|
||||
BigDecimal.valueOf(cur), BigDecimal.valueOf(prev), BigDecimal.valueOf(yoy),
|
||||
sub, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 单张 KPI:展示格式化主值 + 环比/同比变化率;{@code amountYuan} 供前端换算「万」;
|
||||
* {@code preferWanDisplay} 为 true 时建议主数字用万展示。
|
||||
* 单张 KPI:原始数值 + 环比/同比变化率;{@code amountYuan} 供前端换算「万」;
|
||||
* {@code preferWanDisplay} 为 true 时建议主数字用万展示。千分位由前端格式化。
|
||||
*/
|
||||
private WorkbenchKpiItemVO kpi(String label, String value, String unit,
|
||||
private WorkbenchKpiItemVO kpi(String label, BigDecimal value, String unit,
|
||||
BigDecimal curAmt, BigDecimal prevAmt, BigDecimal yoyAmt, String sub,
|
||||
BigDecimal amountYuan, Boolean preferWanDisplay) {
|
||||
BigDecimal change = pctChange(curAmt, prevAmt);
|
||||
@@ -799,7 +795,7 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
||||
return new DateRange(range.startDate().minusMonths(1), range.endDate().minusMonths(1));
|
||||
}
|
||||
|
||||
/** 金额统一保留两位小数(输出 VO 与前端展示) */
|
||||
/** 金额统一保留两位小数(输出 VO) */
|
||||
private static BigDecimal yuan2(BigDecimal yuan) {
|
||||
if (yuan == null) {
|
||||
return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
|
||||
@@ -807,15 +803,6 @@ public class BiWorkbenchServiceImpl implements BiWorkbenchService {
|
||||
return yuan.setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
/** KPI 主数字:千分位 + 两位小数的字符串 */
|
||||
private static String formatYuanComma(BigDecimal yuan) {
|
||||
if (yuan == null) {
|
||||
return "0.00";
|
||||
}
|
||||
BigDecimal v = yuan.setScale(2, RoundingMode.HALF_UP);
|
||||
return new DecimalFormat("#,##0.00", DecimalFormatSymbols.getInstance(Locale.CHINA)).format(v);
|
||||
}
|
||||
|
||||
/** 计算 num/den*100,分母无效时返回 0 */
|
||||
private static BigDecimal safePct(BigDecimal num, BigDecimal den) {
|
||||
if (den == null || den.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
|
||||
@@ -18,7 +18,8 @@ export namespace WorkbenchVO {
|
||||
|
||||
export interface KpiItem {
|
||||
label: string;
|
||||
value: string;
|
||||
/** 主指标原始数值(金额为元;不含千分位) */
|
||||
value: number;
|
||||
unit: string;
|
||||
changePct?: number;
|
||||
up?: boolean;
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 汇总表金额单元格:¥ 格式 + 数值滚动。
|
||||
*/
|
||||
import AnimatedNumberText from './AnimatedNumberText.vue';
|
||||
|
||||
defineOptions({ name: 'WorkbenchAnimatedMoneyCell' });
|
||||
|
||||
defineProps<{
|
||||
value: number | null | undefined;
|
||||
}>();
|
||||
|
||||
function formatAmount(amount: number) {
|
||||
return `¥${amount.toLocaleString('zh-CN', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
})}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AnimatedNumberText :value="value" :format="formatAmount" />
|
||||
</template>
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 数值滚动展示:刷新时从旧值过渡到新值,空值显示占位。
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
import { TransitionPresets, useTransition } from '@vueuse/core';
|
||||
|
||||
defineOptions({ name: 'WorkbenchAnimatedNumberText' });
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
value: number | null | undefined;
|
||||
/** 对过渡中的数值做展示格式化 */
|
||||
format?: (n: number) => string;
|
||||
decimals?: number;
|
||||
duration?: number;
|
||||
empty?: string;
|
||||
}>(),
|
||||
{
|
||||
decimals: 2,
|
||||
duration: 650,
|
||||
empty: '-',
|
||||
},
|
||||
);
|
||||
|
||||
const source = ref(0);
|
||||
const ready = ref(false);
|
||||
|
||||
const hasValue = computed(() => {
|
||||
if (props.value === null || props.value === undefined) return false;
|
||||
return Number.isFinite(Number(props.value));
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
(v) => {
|
||||
if (v === null || v === undefined || !Number.isFinite(Number(v))) {
|
||||
ready.value = false;
|
||||
return;
|
||||
}
|
||||
source.value = Number(v);
|
||||
ready.value = true;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const output = useTransition(source, {
|
||||
duration: computed(() => props.duration),
|
||||
transition: TransitionPresets.easeOutCubic,
|
||||
disabled: computed(() => !ready.value),
|
||||
});
|
||||
|
||||
const display = computed(() => {
|
||||
if (!ready.value || !hasValue.value) return props.empty;
|
||||
const n = output.value;
|
||||
if (props.format) return props.format(n);
|
||||
return n.toFixed(props.decimals);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="tabular-nums">{{ display }}</span>
|
||||
</template>
|
||||
@@ -1,5 +1,14 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
import {
|
||||
computed,
|
||||
nextTick,
|
||||
onActivated,
|
||||
onDeactivated,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
ref,
|
||||
watch,
|
||||
} from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
@@ -100,6 +109,7 @@ const ToolbarToggleIcon = createIconifyIcon('lucide:sliders-horizontal');
|
||||
const ReceiptIcon = createIconifyIcon('lucide:receipt');
|
||||
const CalendarIcon = createIconifyIcon('lucide:calendar');
|
||||
const RefreshIcon = createIconifyIcon('lucide:refresh-cw');
|
||||
const CheckIcon = createIconifyIcon('lucide:check');
|
||||
|
||||
/** 快捷区间 + 自定义 RangePicker */
|
||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||
@@ -447,38 +457,60 @@ function buildWorkbenchQuery(): WorkbenchDTO.Query {
|
||||
return query;
|
||||
}
|
||||
|
||||
/** 筛选变更后清空已加载 Tab,避免展示过期数据 */
|
||||
function invalidateDataTabs() {
|
||||
tabLoaded.finance = false;
|
||||
tabLoaded.multi = false;
|
||||
tabLoaded.salesRank = false;
|
||||
financeSlice.value = null;
|
||||
multiAnalysisData.value = null;
|
||||
salesRankData.value = null;
|
||||
const DATA_TAB_KEYS: DataTabKey[] = ['finance', 'multi', 'salesRank'];
|
||||
|
||||
/** 离开页面超过该时长再自动刷新(visibility) */
|
||||
const AUTO_REFRESH_AWAY_MS = 30_000;
|
||||
|
||||
/** 标脏但不清空已有数据,切回该 Tab 时再静默重拉 */
|
||||
function softInvalidateDataTabs(except?: DataTabKey) {
|
||||
for (const key of DATA_TAB_KEYS) {
|
||||
if (key !== except) {
|
||||
tabLoaded[key] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 按 Tab 首次激活懒加载,已加载则跳过 */
|
||||
async function loadTabData(tab: DataTabKey) {
|
||||
if (!metaLoaded.value || tabLoaded[tab]) {
|
||||
function hasTabData(tab: DataTabKey): boolean {
|
||||
switch (tab) {
|
||||
case 'finance': {
|
||||
return financeSlice.value != null;
|
||||
}
|
||||
case 'multi': {
|
||||
return multiAnalysisData.value != null;
|
||||
}
|
||||
case 'salesRank': {
|
||||
return salesRankData.value != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 按 Tab 懒加载;force 时重拉。已有数据时不打全屏 Spin */
|
||||
async function loadTabData(tab: DataTabKey, opts?: { force?: boolean }) {
|
||||
if (!metaLoaded.value) {
|
||||
return;
|
||||
}
|
||||
if (!opts?.force && tabLoaded[tab]) {
|
||||
return;
|
||||
}
|
||||
const query = buildWorkbenchQuery();
|
||||
const blocking = !hasTabData(tab);
|
||||
try {
|
||||
switch (tab) {
|
||||
case 'finance': {
|
||||
financeLoading.value = true;
|
||||
if (blocking) financeLoading.value = true;
|
||||
financeSlice.value = await getWorkbenchFinanceApi(query);
|
||||
tabLoaded.finance = true;
|
||||
break;
|
||||
}
|
||||
case 'multi': {
|
||||
multiLoading.value = true;
|
||||
if (blocking) multiLoading.value = true;
|
||||
multiAnalysisData.value = await getWorkbenchMultiAnalysisApi(query);
|
||||
tabLoaded.multi = true;
|
||||
break;
|
||||
}
|
||||
case 'salesRank': {
|
||||
salesRankLoading.value = true;
|
||||
if (blocking) salesRankLoading.value = true;
|
||||
salesRankData.value = await getWorkbenchSalesRankApi(query);
|
||||
tabLoaded.salesRank = true;
|
||||
break;
|
||||
@@ -487,19 +519,26 @@ async function loadTabData(tab: DataTabKey) {
|
||||
} catch (e: unknown) {
|
||||
const msg = e instanceof Error ? e.message : '工作台数据加载失败';
|
||||
message.error(msg);
|
||||
// 已有数据则保留;仅首屏失败时落空壳,避免空白死循环
|
||||
switch (tab) {
|
||||
case 'finance': {
|
||||
financeSlice.value = { finance: EMPTY_FINANCE, summaryTables: null };
|
||||
if (!financeSlice.value) {
|
||||
financeSlice.value = { finance: EMPTY_FINANCE, summaryTables: null };
|
||||
}
|
||||
tabLoaded.finance = true;
|
||||
break;
|
||||
}
|
||||
case 'multi': {
|
||||
multiAnalysisData.value = EMPTY_MULTI;
|
||||
if (!multiAnalysisData.value) {
|
||||
multiAnalysisData.value = EMPTY_MULTI;
|
||||
}
|
||||
tabLoaded.multi = true;
|
||||
break;
|
||||
}
|
||||
case 'salesRank': {
|
||||
salesRankData.value = EMPTY_MULTI;
|
||||
if (!salesRankData.value) {
|
||||
salesRankData.value = EMPTY_MULTI;
|
||||
}
|
||||
tabLoaded.salesRank = true;
|
||||
break;
|
||||
}
|
||||
@@ -519,35 +558,106 @@ async function loadTabData(tab: DataTabKey) {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshActiveDataTab() {
|
||||
const tab = activeTab.value;
|
||||
if (tab === 'periodCompare') {
|
||||
/** 强制刷新当前 Tab,并将其余数据 Tab 标脏 */
|
||||
async function softRefreshActiveTab() {
|
||||
if (activeTab.value === 'periodCompare') {
|
||||
await periodCompareTabRef.value?.refresh?.({ silent: true });
|
||||
softInvalidateDataTabs();
|
||||
return;
|
||||
}
|
||||
await loadTabData(tab as DataTabKey);
|
||||
const tab = activeTab.value as DataTabKey;
|
||||
await loadTabData(tab, { force: true });
|
||||
softInvalidateDataTabs(tab);
|
||||
}
|
||||
|
||||
async function refreshActiveDataTab(opts?: { force?: boolean }) {
|
||||
if (activeTab.value === 'periodCompare') {
|
||||
// 筛选变更等带 force:静默重拉,保留旧图
|
||||
await periodCompareTabRef.value?.refresh?.({ silent: !!opts?.force });
|
||||
return;
|
||||
}
|
||||
await loadTabData(activeTab.value as DataTabKey, opts);
|
||||
}
|
||||
|
||||
const refreshing = ref(false);
|
||||
/** 手动刷新成功后按钮短暂「已刷新」 */
|
||||
const refreshDone = ref(false);
|
||||
const REFRESH_DONE_MS = 1200;
|
||||
let refreshDoneTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
/** 手动刷新:强制重拉当前 Tab(含区间对比) */
|
||||
function clearRefreshDoneTimer() {
|
||||
if (refreshDoneTimer) {
|
||||
clearTimeout(refreshDoneTimer);
|
||||
refreshDoneTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
function flashRefreshDone() {
|
||||
clearRefreshDoneTimer();
|
||||
refreshDone.value = true;
|
||||
refreshDoneTimer = setTimeout(() => {
|
||||
refreshDone.value = false;
|
||||
refreshDoneTimer = null;
|
||||
}, REFRESH_DONE_MS);
|
||||
}
|
||||
|
||||
/** 手动刷新:强制重拉当前 Tab(含区间对比),其它 Tab 标脏;成功后按钮闪「已刷新」 */
|
||||
async function handleManualRefresh() {
|
||||
if (refreshing.value) {
|
||||
return;
|
||||
}
|
||||
clearRefreshDoneTimer();
|
||||
refreshDone.value = false;
|
||||
refreshing.value = true;
|
||||
try {
|
||||
await softRefreshActiveTab();
|
||||
flashRefreshDone();
|
||||
} finally {
|
||||
refreshing.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
let leftPageAt: number | null = null;
|
||||
let skipNextActivatedRefresh = true;
|
||||
|
||||
function markPageLeft() {
|
||||
leftPageAt = Date.now();
|
||||
}
|
||||
|
||||
/** 路由返回:总是静默刷新;切回浏览器标签:离开 ≥30s 才刷 */
|
||||
async function maybeAutoRefreshOnReturn(reason: 'activated' | 'visible') {
|
||||
if (reason === 'visible') {
|
||||
// 未记录离开时刻则忽略(避免无 hidden 的 visible 误刷)
|
||||
if (leftPageAt == null) {
|
||||
return;
|
||||
}
|
||||
const awayMs = Date.now() - leftPageAt;
|
||||
leftPageAt = null;
|
||||
if (awayMs < AUTO_REFRESH_AWAY_MS) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
leftPageAt = null;
|
||||
}
|
||||
if (refreshing.value) {
|
||||
return;
|
||||
}
|
||||
refreshing.value = true;
|
||||
try {
|
||||
if (activeTab.value === 'periodCompare') {
|
||||
await periodCompareTabRef.value?.refresh?.();
|
||||
return;
|
||||
}
|
||||
const tab = activeTab.value as DataTabKey;
|
||||
tabLoaded[tab] = false;
|
||||
await loadTabData(tab);
|
||||
await softRefreshActiveTab();
|
||||
} finally {
|
||||
refreshing.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onDocumentVisibilityChange() {
|
||||
if (document.hidden) {
|
||||
markPageLeft();
|
||||
return;
|
||||
}
|
||||
void maybeAutoRefreshOnReturn('visible');
|
||||
}
|
||||
|
||||
const activeTab = ref('finance');
|
||||
|
||||
function handleProductNavigate(productId: number) {
|
||||
@@ -573,7 +683,7 @@ const salesRankTabRef = ref<InstanceType<typeof WorkbenchSalesRankTab> | null>(
|
||||
const periodCompareTabRef = ref<
|
||||
| (InstanceType<typeof WorkbenchPeriodCompareTab> & {
|
||||
redraw: () => Promise<void>;
|
||||
refresh: () => Promise<void>;
|
||||
refresh: (opts?: { silent?: boolean }) => Promise<void>;
|
||||
})
|
||||
| null
|
||||
>(null);
|
||||
@@ -613,8 +723,8 @@ watch(activeTab, (tab) => {
|
||||
watch(
|
||||
[() => dateRange.value, taxRate, selectedPlatformSlug, selectedShopSlug],
|
||||
() => {
|
||||
invalidateDataTabs();
|
||||
void refreshActiveDataTab();
|
||||
softInvalidateDataTabs();
|
||||
void refreshActiveDataTab({ force: true });
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
@@ -622,6 +732,7 @@ watch(
|
||||
let darkObserver: MutationObserver | null = null;
|
||||
|
||||
onMounted(async () => {
|
||||
document.addEventListener('visibilitychange', onDocumentVisibilityChange);
|
||||
await loadTabData('finance');
|
||||
setTimeout(() => {
|
||||
void redrawActiveTabCharts();
|
||||
@@ -635,7 +746,21 @@ onMounted(async () => {
|
||||
});
|
||||
});
|
||||
|
||||
onActivated(() => {
|
||||
if (skipNextActivatedRefresh) {
|
||||
skipNextActivatedRefresh = false;
|
||||
return;
|
||||
}
|
||||
void maybeAutoRefreshOnReturn('activated');
|
||||
});
|
||||
|
||||
onDeactivated(() => {
|
||||
markPageLeft();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('visibilitychange', onDocumentVisibilityChange);
|
||||
clearRefreshDoneTimer();
|
||||
if (platformSearchTimer) clearTimeout(platformSearchTimer);
|
||||
if (shopSearchTimer) clearTimeout(shopSearchTimer);
|
||||
darkObserver?.disconnect();
|
||||
@@ -826,20 +951,30 @@ onUnmounted(() => {
|
||||
refreshing ? 'cursor-wait opacity-70' : 'cursor-pointer',
|
||||
]"
|
||||
role="button"
|
||||
title="刷新当前页数据"
|
||||
:title="refreshDone ? '已刷新' : '刷新当前页数据'"
|
||||
@click="handleManualRefresh"
|
||||
>
|
||||
<div
|
||||
:class="[toolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||
>
|
||||
<CheckIcon
|
||||
v-if="refreshDone && !refreshing"
|
||||
class="h-4 w-4 shrink-0 text-emerald-600 dark:text-emerald-400"
|
||||
/>
|
||||
<RefreshIcon
|
||||
v-else
|
||||
class="h-4 w-4 shrink-0"
|
||||
:class="{ 'animate-spin': refreshing }"
|
||||
/>
|
||||
<span
|
||||
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||
class="whitespace-nowrap text-xs font-bold"
|
||||
:class="
|
||||
refreshDone && !refreshing
|
||||
? 'text-emerald-600 dark:text-emerald-400'
|
||||
: 'text-slate-700 dark:text-slate-300'
|
||||
"
|
||||
>
|
||||
刷新
|
||||
{{ refreshing ? '刷新' : refreshDone ? '已刷新' : '刷新' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -849,7 +984,7 @@ onUnmounted(() => {
|
||||
<div class="workbench-page-body min-w-0">
|
||||
<Tabs v-model:active-key="activeTab" class="workbench-tabs">
|
||||
<Tabs.TabPane key="finance" tab="经营概览">
|
||||
<Spin :spinning="financeLoading">
|
||||
<Spin :spinning="financeLoading && !financeSlice">
|
||||
<WorkbenchFinanceTab
|
||||
ref="financeTabRef"
|
||||
:tax-rate="taxRate"
|
||||
@@ -862,7 +997,7 @@ onUnmounted(() => {
|
||||
</Spin>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="multi" tab="多维分析">
|
||||
<Spin :spinning="multiLoading">
|
||||
<Spin :spinning="multiLoading && !multiAnalysisData">
|
||||
<WorkbenchMultiTab
|
||||
ref="multiTabRef"
|
||||
:multi-analysis="multiPanel"
|
||||
@@ -870,7 +1005,7 @@ onUnmounted(() => {
|
||||
</Spin>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="salesRank" tab="销售额排行榜">
|
||||
<Spin :spinning="salesRankLoading">
|
||||
<Spin :spinning="salesRankLoading && !salesRankData">
|
||||
<WorkbenchSalesRankTab
|
||||
ref="salesRankTabRef"
|
||||
:sales-rank="salesRankPanel"
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
salesTaxColumnHint,
|
||||
} from '#/utils/overview-table-hints';
|
||||
|
||||
import AnimatedNumberText from '../../components/AnimatedNumberText.vue';
|
||||
import { formatYuanDetail, yuanToWanNum } from '../../utils/money';
|
||||
|
||||
defineOptions({ name: 'WorkbenchPeriodCompareTab' });
|
||||
@@ -300,11 +301,15 @@ function buildWorkbenchQuery(range: [dayjs.Dayjs, dayjs.Dayjs]): WorkbenchDTO.Qu
|
||||
return q;
|
||||
}
|
||||
|
||||
async function fetchSlices() {
|
||||
async function fetchSlices(_opts?: { silent?: boolean }) {
|
||||
if (props.activeTab !== 'periodCompare') {
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
const hasExisting = sliceA.value != null || sliceB.value != null;
|
||||
// 已有数据时静默刷新,避免 Spin 盖住图表
|
||||
if (!hasExisting) {
|
||||
loading.value = true;
|
||||
}
|
||||
try {
|
||||
const [a, b] = await Promise.all([
|
||||
getWorkbenchPeriodCompareSliceApi(buildWorkbenchQuery(periodA.value)),
|
||||
@@ -315,8 +320,10 @@ async function fetchSlices() {
|
||||
} catch (e: unknown) {
|
||||
const msg = e instanceof Error ? e.message : '区间对比数据加载失败';
|
||||
message.error(msg);
|
||||
sliceA.value = null;
|
||||
sliceB.value = null;
|
||||
if (!hasExisting) {
|
||||
sliceA.value = null;
|
||||
sliceB.value = null;
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -345,11 +352,10 @@ function formatMoney(n: number) {
|
||||
return `¥${n.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
}
|
||||
|
||||
function formatCell(m: CompareMetric, side: 'a' | 'b') {
|
||||
const v = side === 'a' ? m.valueA : m.valueB;
|
||||
function formatMetricValue(m: CompareMetric, v: number) {
|
||||
switch (m.format) {
|
||||
case 'int': {
|
||||
return v.toLocaleString('zh-CN');
|
||||
return Math.round(v).toLocaleString('zh-CN');
|
||||
}
|
||||
case 'money': {
|
||||
return formatMoney(v);
|
||||
@@ -366,6 +372,15 @@ function formatCell(m: CompareMetric, side: 'a' | 'b') {
|
||||
}
|
||||
}
|
||||
|
||||
function formatCell(m: CompareMetric, side: 'a' | 'b') {
|
||||
const v = side === 'a' ? m.valueA : m.valueB;
|
||||
return formatMetricValue(m, v);
|
||||
}
|
||||
|
||||
function metricValueFormatter(m: CompareMetric) {
|
||||
return (n: number) => formatMetricValue(m, n);
|
||||
}
|
||||
|
||||
function delta(m: CompareMetric) {
|
||||
return m.valueB - m.valueA;
|
||||
}
|
||||
@@ -487,6 +502,10 @@ function drawMoneyCompareChart() {
|
||||
const legendB = `区间 B`;
|
||||
|
||||
void renderMoneyBar({
|
||||
animation: true,
|
||||
animationDuration: 500,
|
||||
animationDurationUpdate: 650,
|
||||
animationEasingUpdate: 'cubicOut',
|
||||
title: {
|
||||
text: '金额类指标对比(万元)',
|
||||
left: 0,
|
||||
@@ -554,7 +573,7 @@ function drawMoneyCompareChart() {
|
||||
itemStyle: { color: t.barB, borderRadius: [0, 4, 4, 0] },
|
||||
},
|
||||
],
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
function drawGrowthCompareChart() {
|
||||
@@ -579,6 +598,10 @@ function drawGrowthCompareChart() {
|
||||
maxV = maxV <= 0 ? Math.max(0, maxV + pad) : maxV + pad;
|
||||
|
||||
void renderGrowthBar({
|
||||
animation: true,
|
||||
animationDuration: 500,
|
||||
animationDurationUpdate: 650,
|
||||
animationEasingUpdate: 'cubicOut',
|
||||
title: {
|
||||
text: '相对区间 A 的增幅(%)',
|
||||
left: 0,
|
||||
@@ -661,7 +684,7 @@ function drawGrowthCompareChart() {
|
||||
},
|
||||
},
|
||||
],
|
||||
} as never);
|
||||
} as never, false);
|
||||
}
|
||||
|
||||
async function redraw() {
|
||||
@@ -735,7 +758,7 @@ defineExpose({ redraw, refresh: fetchSlices });
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Spin :spinning="loading">
|
||||
<Spin :spinning="loading && !sliceA && !sliceB">
|
||||
<div
|
||||
class="border-t border-slate-100 px-3 py-4 dark:border-[hsl(240deg_3.7%_22%)] md:px-6"
|
||||
>
|
||||
@@ -808,10 +831,16 @@ defineExpose({ redraw, refresh: fetchSlices });
|
||||
</OverviewColumnHint>
|
||||
</td>
|
||||
<td class="px-4 py-3 font-mono text-xs font-bold tabular-nums text-slate-800 dark:text-slate-100">
|
||||
{{ formatCell(m, 'a') }}
|
||||
<AnimatedNumberText
|
||||
:value="m.valueA"
|
||||
:format="metricValueFormatter(m)"
|
||||
/>
|
||||
</td>
|
||||
<td class="px-4 py-3 font-mono text-xs font-bold tabular-nums text-slate-800 dark:text-slate-100">
|
||||
{{ formatCell(m, 'b') }}
|
||||
<AnimatedNumberText
|
||||
:value="m.valueB"
|
||||
:format="metricValueFormatter(m)"
|
||||
/>
|
||||
</td>
|
||||
<td
|
||||
class="border-l border-slate-100 px-4 py-3 font-mono text-xs tabular-nums dark:border-[hsl(240deg_3.7%_22%)]"
|
||||
|
||||
+30
-33
@@ -8,6 +8,8 @@ import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||
|
||||
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
|
||||
|
||||
import AnimatedMoneyCell from '../../../components/AnimatedMoneyCell.vue';
|
||||
import {
|
||||
salesTaxColumnHint,
|
||||
storeOverviewHints,
|
||||
@@ -59,11 +61,6 @@ const someCategoriesSelected = computed(() => {
|
||||
return props.selectedExportCategoryIds.length > 0;
|
||||
});
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
};
|
||||
|
||||
const cellMoney = (v: number | null | undefined) => formatNumberCell(v, formatAmount);
|
||||
const cellRoi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, (n) => n.toFixed(2));
|
||||
|
||||
@@ -271,33 +268,33 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
{{ cat.categoryName }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="p-6 font-black">{{ formatAmount(cat.salesAmount) }}</td>
|
||||
<td class="p-6 font-black text-amber-700 dark:text-amber-400">{{ formatAmount(cat.dealAmount) }}</td>
|
||||
<td class="p-6 font-black"><AnimatedMoneyCell :value="cat.salesAmount" /></td>
|
||||
<td class="p-6 font-black text-amber-700 dark:text-amber-400"><AnimatedMoneyCell :value="cat.dealAmount" /></td>
|
||||
<td class="p-6 font-medium">{{ formatIntCell(cat.orderCount) }}</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{ cellMoney(cat.averageOrderValue) }}
|
||||
<AnimatedMoneyCell :value="cat.averageOrderValue" />
|
||||
</td>
|
||||
<td class="p-6">{{ cellMoney(cat.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(cat.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(cat.otherCost) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="cat.productCost" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="cat.shippingCost" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="cat.otherCost" /></td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">
|
||||
{{ cellMoney(cat.orderCost) }}
|
||||
<AnimatedMoneyCell :value="cat.orderCost" />
|
||||
</td>
|
||||
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">
|
||||
{{ cellMoney(cat.refundAmount) }}
|
||||
<AnimatedMoneyCell :value="cat.refundAmount" />
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cellMoney(cat.salesTaxAmount) }}
|
||||
<AnimatedMoneyCell :value="cat.salesTaxAmount" />
|
||||
</td>
|
||||
<td class="p-6">{{ cellMoney(cat.totalPromotionFee) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="cat.totalPromotionFee" /></td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">
|
||||
{{ cellMoney(cat.brushFee) }}
|
||||
<AnimatedMoneyCell :value="cat.brushFee" />
|
||||
</td>
|
||||
<td class="p-6 font-bold text-emerald-700 dark:text-emerald-400">
|
||||
{{ cellMoney(cat.grossProfit) }}
|
||||
<AnimatedMoneyCell :value="cat.grossProfit" />
|
||||
</td>
|
||||
<td class="p-6 font-bold">
|
||||
{{ cellMoney(cat.totalProfitBeforeTax) }}
|
||||
<AnimatedMoneyCell :value="cat.totalProfitBeforeTax" />
|
||||
</td>
|
||||
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cat.feeRatio !== undefined ? formatFeeRatioPercent(cat.feeRatio) : '-' }}
|
||||
@@ -306,7 +303,7 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
{{ cellRoi(cat.roi) }}
|
||||
</td>
|
||||
<td class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%)] p-6 text-base font-black text-emerald-600 dark:text-emerald-300">
|
||||
{{ cellMoney(cat.profitAfterTax) }}
|
||||
<AnimatedMoneyCell :value="cat.profitAfterTax" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!categorySummary?.categories?.length">
|
||||
@@ -320,30 +317,30 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
|
||||
<td class="sticky-col bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] p-6 text-base">合计</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.salesAmount) }}</td>
|
||||
<td class="p-6 text-amber-700 dark:text-amber-400">{{ cellMoney(categorySummary?.total?.dealAmount) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="categorySummary?.total?.salesAmount" /></td>
|
||||
<td class="p-6 text-amber-700 dark:text-amber-400"><AnimatedMoneyCell :value="categorySummary?.total?.dealAmount" /></td>
|
||||
<td class="p-6">{{ formatIntCell(categorySummary?.total?.orderCount) }}</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(categorySummary?.total?.averageOrderValue) }}
|
||||
<AnimatedMoneyCell :value="categorySummary?.total?.averageOrderValue" />
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(categorySummary?.total?.orderCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(categorySummary?.total?.refundAmount) }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(categorySummary?.total?.salesTaxAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(categorySummary?.total?.brushFee) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="categorySummary?.total?.productCost" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="categorySummary?.total?.shippingCost" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="categorySummary?.total?.otherCost" /></td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300"><AnimatedMoneyCell :value="categorySummary?.total?.orderCost" /></td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400"><AnimatedMoneyCell :value="categorySummary?.total?.refundAmount" /></td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"><AnimatedMoneyCell :value="categorySummary?.total?.salesTaxAmount" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="categorySummary?.total?.totalPromotionFee" /></td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400"><AnimatedMoneyCell :value="categorySummary?.total?.brushFee" /></td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6 text-emerald-700 dark:text-emerald-400">{{ cellMoney(categorySummary?.total?.grossProfit) }}</td>
|
||||
<td class="p-6">{{ cellMoney(categorySummary?.total?.totalProfitBeforeTax) }}</td>
|
||||
<td class="p-6 text-emerald-700 dark:text-emerald-400"><AnimatedMoneyCell :value="categorySummary?.total?.grossProfit" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="categorySummary?.total?.totalProfitBeforeTax" /></td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ categorySummary?.total?.feeRatio !== undefined ? formatFeeRatioPercent(categorySummary?.total?.feeRatio) : '-' }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ cellRoi(categorySummary?.total?.roi) }}</td>
|
||||
<td
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(categorySummary?.total?.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-700 dark:text-emerald-300'"
|
||||
>{{ cellMoney(categorySummary?.total?.profitAfterTax) }}</td>
|
||||
><AnimatedMoneyCell :value="categorySummary?.total?.profitAfterTax" /></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
+5
-1
@@ -54,6 +54,10 @@ function drawPie() {
|
||||
const border = isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff';
|
||||
|
||||
renderPieChart({
|
||||
animation: true,
|
||||
animationDuration: 500,
|
||||
animationDurationUpdate: 650,
|
||||
animationEasingUpdate: 'cubicOut',
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff',
|
||||
@@ -107,7 +111,7 @@ function drawPie() {
|
||||
})),
|
||||
},
|
||||
],
|
||||
});
|
||||
}, false);
|
||||
} catch (error) {
|
||||
console.error('[WorkbenchFinancePlatformSalesPieChart] render failed:', error);
|
||||
}
|
||||
|
||||
+90
-23
@@ -8,6 +8,7 @@ import { Popover, Tooltip } from 'ant-design-vue';
|
||||
|
||||
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
|
||||
|
||||
import AnimatedNumberText from '../../../components/AnimatedNumberText.vue';
|
||||
import { formatYuanDetail, yuanToWanNum } from '../../../utils/money';
|
||||
import { getFinanceKpiHint } from '../constants/finance-kpi-hints';
|
||||
import {
|
||||
@@ -135,31 +136,83 @@ function compareRangeHint(start?: string | null, end?: string | null): string {
|
||||
return '对比区间未返回';
|
||||
}
|
||||
|
||||
/** 主数字:可滚动的数值源 + 单位/悬停文案 */
|
||||
function primaryAnim(kpi: WorkbenchVO.KpiItem): {
|
||||
value: number | null;
|
||||
format: (n: number) => string;
|
||||
unitText: string;
|
||||
hover: string;
|
||||
fallback: string;
|
||||
} {
|
||||
const ay = kpi.amountYuan;
|
||||
if (ay != null && Number.isFinite(ay)) {
|
||||
const hover = formatYuanDetail(ay);
|
||||
if (kpi.preferWanDisplay === true) {
|
||||
return {
|
||||
value: yuanToWanNum(ay),
|
||||
format: (n) => n.toFixed(2),
|
||||
unitText: '万',
|
||||
hover,
|
||||
fallback: '',
|
||||
};
|
||||
}
|
||||
// 有 amountYuan 但不按万展示(如客单价)
|
||||
return {
|
||||
value: ay,
|
||||
format: (n) =>
|
||||
n.toLocaleString('zh-CN', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}),
|
||||
unitText: kpi.unit?.trim() ?? '',
|
||||
hover,
|
||||
fallback: '',
|
||||
};
|
||||
}
|
||||
const num = typeof kpi.value === 'number' ? kpi.value : Number(kpi.value);
|
||||
if (Number.isFinite(num)) {
|
||||
const decimals =
|
||||
Number.isInteger(num) || Math.abs(num - Math.round(num)) < 1e-9 ? 0 : 2;
|
||||
return {
|
||||
value: num,
|
||||
format: (n) =>
|
||||
decimals === 0
|
||||
? Math.round(n).toLocaleString('zh-CN')
|
||||
: n.toLocaleString('zh-CN', {
|
||||
minimumFractionDigits: decimals,
|
||||
maximumFractionDigits: decimals,
|
||||
}),
|
||||
unitText: kpi.unit?.trim() ?? '',
|
||||
hover: '',
|
||||
fallback: '',
|
||||
};
|
||||
}
|
||||
return {
|
||||
value: null,
|
||||
format: () => '',
|
||||
unitText: kpi.unit?.trim() ?? '',
|
||||
hover: '',
|
||||
fallback: '-',
|
||||
};
|
||||
}
|
||||
|
||||
function primaryLine(kpi: WorkbenchVO.KpiItem): {
|
||||
display: string;
|
||||
unitText: string;
|
||||
hover: string;
|
||||
} {
|
||||
const ay = kpi.amountYuan;
|
||||
if (ay == null || !Number.isFinite(ay)) {
|
||||
const anim = primaryAnim(kpi);
|
||||
if (anim.value == null) {
|
||||
return {
|
||||
display: String(kpi.value ?? ''),
|
||||
unitText: kpi.unit?.trim() ?? '',
|
||||
hover: '',
|
||||
};
|
||||
}
|
||||
const hover = formatYuanDetail(ay);
|
||||
if (kpi.preferWanDisplay === true) {
|
||||
return {
|
||||
display: yuanToWanNum(ay).toFixed(2),
|
||||
unitText: '万',
|
||||
hover,
|
||||
display: anim.fallback,
|
||||
unitText: anim.unitText,
|
||||
hover: anim.hover,
|
||||
};
|
||||
}
|
||||
return {
|
||||
display: String(kpi.value ?? ''),
|
||||
unitText: kpi.unit?.trim() ?? '',
|
||||
hover,
|
||||
display: anim.format(anim.value),
|
||||
unitText: anim.unitText,
|
||||
hover: anim.hover,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -192,7 +245,7 @@ function onPickPrimary(cardId: FinanceKpiCardId, metricLabel: string) {
|
||||
}
|
||||
|
||||
function toneIconClass(tone: string): string {
|
||||
return FINANCE_TONE_ICON[tone] ?? FINANCE_TONE_ICON.blue;
|
||||
return FINANCE_TONE_ICON[tone] ?? FINANCE_TONE_ICON.blue ?? '';
|
||||
}
|
||||
|
||||
const emptyShellClass =
|
||||
@@ -307,26 +360,40 @@ const emptyShellClass =
|
||||
<template v-if="row.primaryKpi">
|
||||
<div class="mt-3 inline-flex max-w-full items-baseline gap-0.5 whitespace-nowrap">
|
||||
<Tooltip
|
||||
v-if="primaryLine(row.primaryKpi).hover"
|
||||
:title="primaryLine(row.primaryKpi).hover"
|
||||
v-if="primaryAnim(row.primaryKpi).hover"
|
||||
:title="primaryAnim(row.primaryKpi).hover"
|
||||
>
|
||||
<span
|
||||
class="cursor-default tabular-nums text-[26px] font-bold leading-none tracking-tight text-slate-800 dark:text-[hsl(0deg_0%_95%)]"
|
||||
>
|
||||
{{ primaryLine(row.primaryKpi).display }}
|
||||
<AnimatedNumberText
|
||||
v-if="primaryAnim(row.primaryKpi).value != null"
|
||||
:value="primaryAnim(row.primaryKpi).value"
|
||||
:format="primaryAnim(row.primaryKpi).format"
|
||||
/>
|
||||
<template v-else>
|
||||
{{ primaryAnim(row.primaryKpi).fallback }}
|
||||
</template>
|
||||
</span>
|
||||
</Tooltip>
|
||||
<span
|
||||
v-else
|
||||
class="tabular-nums text-[26px] font-bold leading-none tracking-tight text-slate-800 dark:text-[hsl(0deg_0%_95%)]"
|
||||
>
|
||||
{{ primaryLine(row.primaryKpi).display }}
|
||||
<AnimatedNumberText
|
||||
v-if="primaryAnim(row.primaryKpi).value != null"
|
||||
:value="primaryAnim(row.primaryKpi).value"
|
||||
:format="primaryAnim(row.primaryKpi).format"
|
||||
/>
|
||||
<template v-else>
|
||||
{{ primaryAnim(row.primaryKpi).fallback }}
|
||||
</template>
|
||||
</span>
|
||||
<span
|
||||
v-if="primaryLine(row.primaryKpi).unitText"
|
||||
v-if="primaryAnim(row.primaryKpi).unitText"
|
||||
class="text-sm font-semibold leading-none text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
{{ primaryLine(row.primaryKpi).unitText }}
|
||||
{{ primaryAnim(row.primaryKpi).unitText }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
+5
-1
@@ -100,6 +100,10 @@ function drawFinanceTrend() {
|
||||
const showDataZoom = props.trend.length > 14;
|
||||
|
||||
renderFinanceTrend({
|
||||
animation: true,
|
||||
animationDuration: 500,
|
||||
animationDurationUpdate: 650,
|
||||
animationEasingUpdate: 'cubicOut',
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'cross', crossStyle: { color: isDark ? '#475569' : '#94a3b8' } },
|
||||
@@ -360,7 +364,7 @@ function drawFinanceTrend() {
|
||||
z: 6,
|
||||
},
|
||||
],
|
||||
});
|
||||
}, false);
|
||||
} catch (error) {
|
||||
console.error('[WorkbenchFinanceTrendChart] render failed:', error);
|
||||
}
|
||||
|
||||
+32
-35
@@ -6,6 +6,8 @@ import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||
|
||||
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
|
||||
|
||||
import AnimatedMoneyCell from '../../../components/AnimatedMoneyCell.vue';
|
||||
import {
|
||||
salesTaxColumnHint,
|
||||
storeOverviewHints,
|
||||
@@ -46,11 +48,6 @@ const somePlatformsSelected = computed(() => {
|
||||
return props.selectedExportPlatformCodes.length > 0;
|
||||
});
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
};
|
||||
|
||||
const cellMoney = (v: number | null | undefined) => formatNumberCell(v, formatAmount);
|
||||
const cellRoi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, (n) => n.toFixed(2));
|
||||
|
||||
@@ -344,28 +341,28 @@ const sortedData = computed(() => {
|
||||
<!-- 目标 -->
|
||||
<td class="p-6 font-medium">{{ p.targetOrderCount.toLocaleString('zh-CN') }}</td>
|
||||
<td class="p-6 font-black text-blue-600 dark:text-blue-400">{{ formatPercentPlain(p.orderCountAchievementRate) }}</td>
|
||||
<td class="p-6 font-medium">{{ formatAmount(p.targetAmount) }}</td>
|
||||
<td class="p-6 font-medium"><AnimatedMoneyCell :value="p.targetAmount" /></td>
|
||||
<td class="p-6 font-black text-blue-600 dark:text-blue-400">{{ formatPercentPlain(p.salesAmountAchievementRate) }}</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6 font-black">{{ formatAmount(p.salesAmount) }}</td>
|
||||
<td class="p-6 font-black text-amber-700 dark:text-amber-400">{{ formatAmount(p.dealAmount) }}</td>
|
||||
<td class="p-6 font-black"><AnimatedMoneyCell :value="p.salesAmount" /></td>
|
||||
<td class="p-6 font-black text-amber-700 dark:text-amber-400"><AnimatedMoneyCell :value="p.dealAmount" /></td>
|
||||
<td class="p-6 font-medium">{{ p.orderCount.toLocaleString('zh-CN') }}</td>
|
||||
<td class="p-6 font-medium">{{ formatAmount(p.averageOrderValue) }}</td>
|
||||
<td class="p-6 font-medium"><AnimatedMoneyCell :value="p.averageOrderValue" /></td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ formatAmount(p.productCost) }}</td>
|
||||
<td class="p-6">{{ formatAmount(p.shippingCost) }}</td>
|
||||
<td class="p-6">{{ formatAmount(p.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ formatAmount(p.orderCost) }}</td>
|
||||
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">{{ formatAmount(p.refundAmount) }}</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatAmount(p.salesTaxAmount) }}</td>
|
||||
<td class="p-6">{{ formatAmount(p.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ formatAmount(p.brushFee) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="p.productCost" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="p.shippingCost" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="p.otherCost" /></td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300"><AnimatedMoneyCell :value="p.orderCost" /></td>
|
||||
<td class="p-6 font-bold text-rose-600 dark:text-rose-400"><AnimatedMoneyCell :value="p.refundAmount" /></td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]"><AnimatedMoneyCell :value="p.salesTaxAmount" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="p.totalPromotionFee" /></td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400"><AnimatedMoneyCell :value="p.brushFee" /></td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6 font-bold text-emerald-700 dark:text-emerald-400">
|
||||
{{ formatAmount(p.grossProfit) }}
|
||||
<AnimatedMoneyCell :value="p.grossProfit" />
|
||||
</td>
|
||||
<td class="p-6 font-bold" :class="p.totalProfitBeforeTax >= 0 ? 'text-slate-800 dark:text-[hsl(0deg_0%_95%)]' : 'text-rose-600 dark:text-rose-400'">
|
||||
{{ formatAmount(p.totalProfitBeforeTax) }}
|
||||
<AnimatedMoneyCell :value="p.totalProfitBeforeTax" />
|
||||
</td>
|
||||
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatFeeRatioPercent(p.feeRatio) }}</td>
|
||||
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">{{ p.roi.toFixed(2) }}</td>
|
||||
@@ -373,7 +370,7 @@ const sortedData = computed(() => {
|
||||
class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%)] p-6 text-base font-black"
|
||||
:class="p.profitAfterTax >= 0 ? 'text-emerald-600 dark:text-emerald-300' : 'text-rose-600 dark:text-rose-400'"
|
||||
>
|
||||
{{ formatAmount(p.profitAfterTax) }}
|
||||
<AnimatedMoneyCell :value="p.profitAfterTax" />
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -386,34 +383,34 @@ const sortedData = computed(() => {
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{ totalData.orderCountAchievementRate !== undefined ? formatPercentPlain(totalData.orderCountAchievementRate) : '-' }}
|
||||
</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.targetAmount) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="totalData.targetAmount" /></td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{ totalData.salesAmountAchievementRate !== undefined ? formatPercentPlain(totalData.salesAmountAchievementRate) : '-' }}
|
||||
</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ cellMoney(totalData.salesAmount) }}</td>
|
||||
<td class="p-6 text-amber-700 dark:text-amber-400">{{ cellMoney(totalData.dealAmount) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="totalData.salesAmount" /></td>
|
||||
<td class="p-6 text-amber-700 dark:text-amber-400"><AnimatedMoneyCell :value="totalData.dealAmount" /></td>
|
||||
<td class="p-6">{{ formatIntCell(totalData.orderCount) }}</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(totalData.averageOrderValue) }}
|
||||
<AnimatedMoneyCell :value="totalData.averageOrderValue" />
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ cellMoney(totalData.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(totalData.orderCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(totalData.refundAmount) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="totalData.productCost" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="totalData.shippingCost" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="totalData.otherCost" /></td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300"><AnimatedMoneyCell :value="totalData.orderCost" /></td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400"><AnimatedMoneyCell :value="totalData.refundAmount" /></td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cellMoney(totalData.salesTaxAmount) }}
|
||||
<AnimatedMoneyCell :value="totalData.salesTaxAmount" />
|
||||
</td>
|
||||
<td class="p-6">{{ cellMoney(totalData.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(totalData.brushFee) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="totalData.totalPromotionFee" /></td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400"><AnimatedMoneyCell :value="totalData.brushFee" /></td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6 text-emerald-700 dark:text-emerald-400">
|
||||
{{ cellMoney(totalData.grossProfit) }}
|
||||
<AnimatedMoneyCell :value="totalData.grossProfit" />
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(totalData.totalProfitBeforeTax) }}
|
||||
<AnimatedMoneyCell :value="totalData.totalProfitBeforeTax" />
|
||||
</td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ totalData.feeRatio !== undefined ? formatFeeRatioPercent(totalData.feeRatio) : '-' }}
|
||||
@@ -425,7 +422,7 @@ const sortedData = computed(() => {
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(totalData.profitAfterTax ?? 0) >= 0 ? 'text-emerald-700 dark:text-emerald-300' : 'text-rose-600 dark:text-rose-400'"
|
||||
>
|
||||
{{ cellMoney(totalData.profitAfterTax) }}
|
||||
<AnimatedMoneyCell :value="totalData.profitAfterTax" />
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
+32
-35
@@ -7,6 +7,8 @@ import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
|
||||
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
|
||||
|
||||
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
|
||||
|
||||
import AnimatedMoneyCell from '../../../components/AnimatedMoneyCell.vue';
|
||||
import {
|
||||
salesTaxColumnHint,
|
||||
storeOverviewHints,
|
||||
@@ -47,16 +49,11 @@ const someShopsSelected = computed(() => {
|
||||
return props.selectedExportShopIds.length > 0;
|
||||
});
|
||||
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
||||
};
|
||||
|
||||
const formatPercentPlain = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
const cellMoney = (v: number | null | undefined) => formatNumberCell(v, formatAmount);
|
||||
const cellRoi = (v: number | null | undefined) =>
|
||||
formatNumberCell(v, (n) => n.toFixed(2));
|
||||
</script>
|
||||
@@ -301,7 +298,7 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{ cellMoney(shop.targetAmount) }}
|
||||
<AnimatedMoneyCell :value="shop.targetAmount" />
|
||||
</td>
|
||||
<td class="p-6 font-black text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
@@ -312,48 +309,48 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6 font-black">
|
||||
{{ formatAmount(shop.salesAmount as number) }}
|
||||
<AnimatedMoneyCell :value="shop.salesAmount" />
|
||||
</td>
|
||||
<td class="p-6 font-black text-amber-700 dark:text-amber-400">
|
||||
{{ formatAmount(shop.dealAmount as number ) }}
|
||||
<AnimatedMoneyCell :value="shop.dealAmount" />
|
||||
</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{ formatIntCell(shop.orderCount) }}
|
||||
</td>
|
||||
<td class="p-6 font-medium">
|
||||
{{ cellMoney(shop.averageOrderValue) }}
|
||||
<AnimatedMoneyCell :value="shop.averageOrderValue" />
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">
|
||||
{{ cellMoney(shop.productCost) }}
|
||||
<AnimatedMoneyCell :value="shop.productCost" />
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(shop.shippingCost) }}
|
||||
<AnimatedMoneyCell :value="shop.shippingCost" />
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(shop.otherCost) }}
|
||||
<AnimatedMoneyCell :value="shop.otherCost" />
|
||||
</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">
|
||||
{{ cellMoney(shop.orderCost) }}
|
||||
<AnimatedMoneyCell :value="shop.orderCost" />
|
||||
</td>
|
||||
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">
|
||||
{{ cellMoney(shop.refundAmount) }}
|
||||
<AnimatedMoneyCell :value="shop.refundAmount" />
|
||||
</td>
|
||||
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{ cellMoney(shop.salesTaxAmount) }}
|
||||
<AnimatedMoneyCell :value="shop.salesTaxAmount" />
|
||||
</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(shop.totalPromotionFee) }}
|
||||
<AnimatedMoneyCell :value="shop.totalPromotionFee" />
|
||||
</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">
|
||||
{{ cellMoney(shop.brushFee) }}
|
||||
<AnimatedMoneyCell :value="shop.brushFee" />
|
||||
</td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6 font-bold text-emerald-700 dark:text-emerald-400">
|
||||
{{ cellMoney(shop.grossProfit) }}
|
||||
<AnimatedMoneyCell :value="shop.grossProfit" />
|
||||
</td>
|
||||
<td class="p-6 font-bold">
|
||||
{{ cellMoney(shop.totalProfitBeforeTax) }}
|
||||
<AnimatedMoneyCell :value="shop.totalProfitBeforeTax" />
|
||||
</td>
|
||||
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
{{
|
||||
@@ -366,7 +363,7 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
{{ cellRoi(shop.roi) }}
|
||||
</td>
|
||||
<td class="bg-emerald-50 dark:bg-[hsl(142deg_71.8%_29%)] p-6 text-base font-black text-emerald-600 dark:text-emerald-300">
|
||||
{{ cellMoney(shop.profitAfterTax) }}
|
||||
<AnimatedMoneyCell :value="shop.profitAfterTax" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!shopSummary?.shops?.length">
|
||||
@@ -393,7 +390,7 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.targetAmount) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="shopSummary?.total?.targetAmount" /></td>
|
||||
<td class="p-6 text-blue-600 dark:text-blue-400">
|
||||
{{
|
||||
shopSummary?.total?.salesAmountAchievementRate !== undefined
|
||||
@@ -402,30 +399,30 @@ const cellRoi = (v: number | null | undefined) =>
|
||||
}}
|
||||
</td>
|
||||
<!-- 规模 -->
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.salesAmount) }}</td>
|
||||
<td class="p-6 text-amber-700 dark:text-amber-400">{{ cellMoney(shopSummary?.total?.dealAmount) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="shopSummary?.total?.salesAmount" /></td>
|
||||
<td class="p-6 text-amber-700 dark:text-amber-400"><AnimatedMoneyCell :value="shopSummary?.total?.dealAmount" /></td>
|
||||
<td class="p-6">{{ formatIntCell(shopSummary?.total?.orderCount) }}</td>
|
||||
<td class="p-6">
|
||||
{{ cellMoney(shopSummary?.total?.averageOrderValue) }}
|
||||
<AnimatedMoneyCell :value="shopSummary?.total?.averageOrderValue" />
|
||||
</td>
|
||||
<!-- 成本 -->
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.productCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.shippingCost) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.otherCost) }}</td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cellMoney(shopSummary?.total?.orderCost) }}</td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400">{{ cellMoney(shopSummary?.total?.refundAmount) }}</td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ cellMoney(shopSummary?.total?.salesTaxAmount) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.totalPromotionFee) }}</td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cellMoney(shopSummary?.total?.brushFee) }}</td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="shopSummary?.total?.productCost" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="shopSummary?.total?.shippingCost" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="shopSummary?.total?.otherCost" /></td>
|
||||
<td class="p-6 font-bold text-orange-800 dark:text-orange-300"><AnimatedMoneyCell :value="shopSummary?.total?.orderCost" /></td>
|
||||
<td class="p-6 text-rose-600 dark:text-rose-400"><AnimatedMoneyCell :value="shopSummary?.total?.refundAmount" /></td>
|
||||
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"><AnimatedMoneyCell :value="shopSummary?.total?.salesTaxAmount" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="shopSummary?.total?.totalPromotionFee" /></td>
|
||||
<td class="p-6 text-orange-600 dark:text-orange-400"><AnimatedMoneyCell :value="shopSummary?.total?.brushFee" /></td>
|
||||
<!-- 盈利 -->
|
||||
<td class="p-6 text-emerald-700 dark:text-emerald-400">{{ cellMoney(shopSummary?.total?.grossProfit) }}</td>
|
||||
<td class="p-6">{{ cellMoney(shopSummary?.total?.totalProfitBeforeTax) }}</td>
|
||||
<td class="p-6 text-emerald-700 dark:text-emerald-400"><AnimatedMoneyCell :value="shopSummary?.total?.grossProfit" /></td>
|
||||
<td class="p-6"><AnimatedMoneyCell :value="shopSummary?.total?.totalProfitBeforeTax" /></td>
|
||||
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ shopSummary?.total?.feeRatio !== undefined ? formatFeeRatioPercent(shopSummary?.total?.feeRatio) : '-' }}</td>
|
||||
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ cellRoi(shopSummary?.total?.roi) }}</td>
|
||||
<td
|
||||
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
|
||||
:class="(shopSummary?.total?.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-700 dark:text-emerald-300'"
|
||||
>{{ cellMoney(shopSummary?.total?.profitAfterTax) }}</td>
|
||||
><AnimatedMoneyCell :value="shopSummary?.total?.profitAfterTax" /></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
+15
-3
@@ -95,6 +95,10 @@ const drawMultiBarChart = () => {
|
||||
const bottomPad = multiChartGridBottomPx(r.length, rotateLabels);
|
||||
|
||||
renderMultiBar({
|
||||
animation: true,
|
||||
animationDuration: 500,
|
||||
animationDurationUpdate: 650,
|
||||
animationEasingUpdate: 'cubicOut',
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff',
|
||||
@@ -176,7 +180,7 @@ const drawMultiBarChart = () => {
|
||||
itemStyle: { color: isDark ? '#fb7185' : '#e11d48' },
|
||||
},
|
||||
],
|
||||
});
|
||||
}, false);
|
||||
};
|
||||
|
||||
const drawMultiLineChart = () => {
|
||||
@@ -191,6 +195,10 @@ const drawMultiLineChart = () => {
|
||||
const bottomPad = multiChartGridBottomPx(r.length, rotateLabels);
|
||||
|
||||
renderMultiLine({
|
||||
animation: true,
|
||||
animationDuration: 500,
|
||||
animationDurationUpdate: 650,
|
||||
animationEasingUpdate: 'cubicOut',
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff',
|
||||
@@ -250,7 +258,7 @@ const drawMultiLineChart = () => {
|
||||
itemStyle: { color: isDark ? '#fbbf24' : '#d97706' },
|
||||
},
|
||||
],
|
||||
});
|
||||
}, false);
|
||||
};
|
||||
|
||||
const drawRankBarChart = () => {
|
||||
@@ -265,6 +273,10 @@ const drawRankBarChart = () => {
|
||||
);
|
||||
|
||||
renderRankBar({
|
||||
animation: true,
|
||||
animationDuration: 500,
|
||||
animationDurationUpdate: 650,
|
||||
animationEasingUpdate: 'cubicOut',
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: { type: 'shadow' },
|
||||
@@ -332,7 +344,7 @@ const drawRankBarChart = () => {
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}, false);
|
||||
};
|
||||
|
||||
const redraw = async () => {
|
||||
|
||||
Reference in New Issue
Block a user