mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 17:49:19 +08:00
feat(工作台): 经营概览饼图展示各平台实际销售额占比
- 接口 finance.costStructure 改为 platformSalesShare,按平台聚合实际销售额及占比 - 饼图标题与交互改为「各平台实际销售额分布」,前端类型 PieSlice - 汇总表组件 ShopComparisonTable/CategoryComparisonTable 重命名为 ShopSummaryTable/CategorySummaryTable
This commit is contained in:
@@ -28,7 +28,7 @@ import WorkbenchSalesRankTab from './tabs/sales-rank/index.vue';
|
||||
defineOptions({ name: 'PddWorkbench' });
|
||||
|
||||
const EMPTY_WORKBENCH: WorkbenchVO.Info = {
|
||||
finance: { kpis: [], gmvTrend: [], costStructure: [] },
|
||||
finance: { kpis: [], gmvTrend: [], platformSalesShare: [] },
|
||||
multiAnalysis: {
|
||||
platform: [],
|
||||
shop: [],
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ import {
|
||||
storeOverviewHints,
|
||||
} from '#/utils/overview-table-hints';
|
||||
|
||||
defineOptions({ name: 'WorkbenchCategoryComparisonTable' });
|
||||
defineOptions({ name: 'WorkbenchCategorySummaryTable' });
|
||||
|
||||
const JumpIcon = createIconifyIcon('tdesign:jump');
|
||||
|
||||
+42
-25
@@ -8,36 +8,43 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
import { formatWanShort, formatYuanDetail } from '../../../utils/money';
|
||||
|
||||
defineOptions({ name: 'WorkbenchFinanceCostPieChart' });
|
||||
defineOptions({ name: 'WorkbenchFinancePlatformSalesPieChart' });
|
||||
|
||||
const props = defineProps<{
|
||||
costStructure: WorkbenchVO.CostSlice[];
|
||||
platformSalesShare: WorkbenchVO.PieSlice[];
|
||||
}>();
|
||||
|
||||
const SLICE_COLOR_BY_NAME: Record<string, string> = {
|
||||
商品成本: '#2563eb',
|
||||
物流费用: '#d97706',
|
||||
其他成本: '#94a3b8',
|
||||
推广费: '#e11d48',
|
||||
刷单费: '#ea580c',
|
||||
税费: '#94a3b8',
|
||||
净利润: '#059669',
|
||||
};
|
||||
const PLATFORM_PIE_COLORS = [
|
||||
'#2563eb',
|
||||
'#d97706',
|
||||
'#059669',
|
||||
'#e11d48',
|
||||
'#6366f1',
|
||||
'#14b8a6',
|
||||
'#8b5cf6',
|
||||
'#f59e0b',
|
||||
'#64748b',
|
||||
'#ec4899',
|
||||
];
|
||||
|
||||
const chartOverviewShell =
|
||||
'overflow-hidden rounded-2xl border border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-white/90 dark:bg-[hsl(222.34deg_10.43%_12.27%)] shadow-[0_4px_12px_rgba(0,0,0,0.03)] dark:shadow-none backdrop-blur-[10px]';
|
||||
|
||||
const costPieChartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts: renderCostPieChart } = useEcharts(costPieChartRef);
|
||||
const pieChartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts: renderPieChart } = useEcharts(pieChartRef);
|
||||
|
||||
function drawCostPie() {
|
||||
if (!costPieChartRef.value) return;
|
||||
function colorForIndex(index: number): string {
|
||||
return PLATFORM_PIE_COLORS[index % PLATFORM_PIE_COLORS.length] ?? '#6366f1';
|
||||
}
|
||||
|
||||
function drawPie() {
|
||||
if (!pieChartRef.value) return;
|
||||
const isDark = document.documentElement.classList.contains('dark');
|
||||
const labelColor = isDark ? 'hsl(0deg 0% 95%)' : '#334155';
|
||||
const legendColor = isDark ? 'hsl(240deg 5% 64.9%)' : '#64748b';
|
||||
const border = isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff';
|
||||
|
||||
renderCostPieChart({
|
||||
renderPieChart({
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff',
|
||||
@@ -45,8 +52,9 @@ function drawCostPie() {
|
||||
formatter: (params: any) => {
|
||||
const name = String(params.name ?? '');
|
||||
const val = Number(params.value ?? 0);
|
||||
const row = props.costStructure.find((r) => r.name === name);
|
||||
const pctText = row?.pct != null ? `${row.pct}%(占销售额)` : '';
|
||||
const row = props.platformSalesShare.find((r) => r.name === name);
|
||||
const pctText =
|
||||
row?.pct != null ? `${row.pct}%(占实际销售额)` : '';
|
||||
return `${name}<br/>约 ${formatWanShort(val)}<br/>${formatYuanDetail(val)}<br/>${pctText}`;
|
||||
},
|
||||
},
|
||||
@@ -81,11 +89,11 @@ function drawCostPie() {
|
||||
length2: 8,
|
||||
lineStyle: { color: isDark ? 'hsl(240deg 3.7% 35%)' : '#cbd5e1' },
|
||||
},
|
||||
data: props.costStructure.map((row) => ({
|
||||
data: props.platformSalesShare.map((row, index) => ({
|
||||
name: row.name,
|
||||
value: row.value ?? 0,
|
||||
itemStyle: {
|
||||
color: SLICE_COLOR_BY_NAME[row.name] ?? '#6366f1',
|
||||
color: colorForIndex(index),
|
||||
},
|
||||
})),
|
||||
},
|
||||
@@ -95,7 +103,7 @@ function drawCostPie() {
|
||||
|
||||
async function redraw() {
|
||||
await nextTick();
|
||||
drawCostPie();
|
||||
drawPie();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -103,7 +111,7 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.costStructure,
|
||||
() => props.platformSalesShare,
|
||||
() => {
|
||||
void redraw();
|
||||
},
|
||||
@@ -121,12 +129,21 @@ defineExpose({ redraw });
|
||||
<h3
|
||||
class="text-xl font-black text-slate-800 dark:text-[hsl(0deg_0%_95%)]"
|
||||
>
|
||||
成本结构(占销售额 %)
|
||||
各平台实际销售额分布
|
||||
</h3>
|
||||
<p class="mt-1 text-xs font-bold text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
占当前筛选条件下实际销售额合计的比例
|
||||
</p>
|
||||
</div>
|
||||
<div class="px-6 py-5 md:px-8 md:py-6">
|
||||
<div class="h-[280px] w-full">
|
||||
<EchartsUI ref="costPieChartRef" />
|
||||
<div
|
||||
v-if="!platformSalesShare.length"
|
||||
class="flex h-[280px] items-center justify-center text-sm font-bold text-slate-400"
|
||||
>
|
||||
暂无销售额数据
|
||||
</div>
|
||||
<div v-else class="h-[280px] w-full">
|
||||
<EchartsUI ref="pieChartRef" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+5
-5
@@ -8,9 +8,9 @@ import { message, Segmented } from 'ant-design-vue';
|
||||
|
||||
import { exportByPost } from '#/utils/export';
|
||||
|
||||
import CategoryComparisonTable from './CategoryComparisonTable.vue';
|
||||
import CategorySummaryTable from './CategorySummaryTable.vue';
|
||||
import PlatformSummaryCard from './PlatformSummaryCard.vue';
|
||||
import ShopComparisonTable from './ShopComparisonTable.vue';
|
||||
import ShopSummaryTable from './ShopSummaryTable.vue';
|
||||
|
||||
defineOptions({ name: 'WorkbenchOverviewTables' });
|
||||
|
||||
@@ -184,7 +184,7 @@ async function handleProductExport() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ShopComparisonTable
|
||||
<ShopSummaryTable
|
||||
v-if="activeMode === 'shop'"
|
||||
heading-title="各店铺多维度经营明细汇总"
|
||||
:shop-summary="shopSummary ?? undefined"
|
||||
@@ -210,7 +210,7 @@ async function handleProductExport() {
|
||||
@export="handlePlatformExport"
|
||||
/>
|
||||
|
||||
<CategoryComparisonTable
|
||||
<CategorySummaryTable
|
||||
v-if="activeMode === 'category'"
|
||||
heading-title="各品类多维度经营明细汇总"
|
||||
heading-subtitle="与全店概览同款表格"
|
||||
@@ -223,7 +223,7 @@ async function handleProductExport() {
|
||||
@export="handleCategoryExport"
|
||||
/>
|
||||
|
||||
<CategoryComparisonTable
|
||||
<CategorySummaryTable
|
||||
v-if="activeMode === 'product'"
|
||||
heading-title="各商品多维度经营明细汇总"
|
||||
heading-subtitle="列结构与品类表一致;数据与全店概览商品维度同源;点击商品名可跳转商品概览"
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import {
|
||||
|
||||
const JumpIcon = createIconifyIcon('tdesign:jump');
|
||||
|
||||
defineOptions({ name: 'WorkbenchShopComparisonTable' });
|
||||
defineOptions({ name: 'WorkbenchShopSummaryTable' });
|
||||
|
||||
interface Props {
|
||||
shopSummary?: CompanyOverviewVO.ShopOverview;
|
||||
+1
-1
@@ -85,7 +85,7 @@ defineExpose({ redraw });
|
||||
/>
|
||||
<FinanceCostPieChart
|
||||
ref="costPieRef"
|
||||
:cost-structure="finance.costStructure"
|
||||
:platform-sales-share="finance.platformSalesShare"
|
||||
/>
|
||||
</div>
|
||||
<OverviewTables
|
||||
|
||||
Reference in New Issue
Block a user