From 1621388d9f3ed46a987772a5d0de066e4c9a114e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=9F=91=E8=9E=82?= Date: Tue, 12 May 2026 12:27:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cursor/rules/antd-spin-scrollable-layout.mdc | 13 + .../src/views/dashboard/workbench/data.ts | 95 ++++-- .../src/views/dashboard/workbench/index.vue | 301 ++++++++---------- .../product/components/ProductCard.vue | 94 +++++- .../src/views/ecommerce/product/index.vue | 1 + 5 files changed, 306 insertions(+), 198 deletions(-) create mode 100644 .cursor/rules/antd-spin-scrollable-layout.mdc diff --git a/.cursor/rules/antd-spin-scrollable-layout.mdc b/.cursor/rules/antd-spin-scrollable-layout.mdc new file mode 100644 index 00000000..66d07162 --- /dev/null +++ b/.cursor/rules/antd-spin-scrollable-layout.mdc @@ -0,0 +1,13 @@ +--- +description: Ant Design Vue Spin 与可滚动 flex/grid 布局的配合方式,避免列表无法滚动 +globs: ecom-dmb-frontend/apps/web-antd/**/*.vue +alwaysApply: false +--- + +# Spin 与侧栏/向导内滚动 + +- **不要用 `` 整块包住「可滚动列表」所在的主内容区**。`Spin` 会渲染 `ant-spin-nested-loading` / `ant-spin-container`,内层常见 `overflow: hidden` 或高度链断裂,导致子元素虽有 `overflow-y: auto` 但**滚轮/触控滚不动**。 +- **推荐**:加载态拆细——例如字段定义用独立 `ref`(如 `fieldDefsLoading`),只在列表上方或占位区放小号 `Spin`/文案;提交操作用按钮 `:loading` + `message.loading`,避免大 Spin 套滚动容器。 +- **布局**:侧栏/向导内滚动依赖整条 flex 链上的 **`min-h-0` / `minmax(0,1fr)`**,列表容器用 **`flex-1 min-h-0 overflow-y-auto`**;需要时可加 **`overscroll-behavior-y: contain`**(如 Tailwind `overscroll-y-contain`)减少滚动链冒泡到外层页面。 + +参考实现:`ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/order-import/components/ImportTaskWizard.vue`(订单导入向导)。 diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/data.ts b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/data.ts index 8fd17d7b..30830b77 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/data.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/data.ts @@ -118,35 +118,76 @@ export const COST_STRUCTURE_PIE_COLORS = [ '#14b8a6', ] as const; -export const FUNNEL_STEPS = [ - { name: 'GMV', value: 286.4 }, - { name: '实收金额', value: 271.8 }, - { name: '扣除成本', value: 220.4 }, - { name: '扣除广告', value: 170.0 }, - { name: '扣除佣金', value: 141.4 }, - { name: '扣除物流', value: 107.8 }, - { name: '毛利润', value: 68.2 }, - { name: '净利润', value: 38.9 }, -] as const; +/** 商品销量 TOP5(演示):件数、GMV、环比 */ +export type ProductSalesTopItem = { + rank: number; + name: string; + sales: number; + gmvWan: number; + momPct: number; + barColor: string; +}; -/** 漏斗图各层颜色(与 FUNNEL_STEPS 顺序一致) */ -export const FUNNEL_STAGE_COLORS = [ - '#ef4444', - '#f97316', - '#f59e0b', - '#eab308', - '#84cc16', - '#22c55e', - '#14b8a6', - '#10b981', -] as const; +export const PRODUCT_SALES_TOP5: ProductSalesTopItem[] = [ + { + rank: 1, + name: '316不锈钢保温杯-女款 500ml', + sales: 42_860, + gmvWan: 42.6, + momPct: 18.2, + barColor: '#f59e0b', + }, + { + rank: 2, + name: '大容量运动水壶 1.2L 吸管款', + sales: 31_240, + gmvWan: 28.9, + momPct: 9.6, + barColor: '#6366f1', + }, + { + rank: 3, + name: '玻璃内胆保温壶 2.5L 家用', + sales: 24_180, + gmvWan: 36.2, + momPct: -2.1, + barColor: '#10b981', + }, + { + rank: 4, + name: '儿童保温杯卡通款 350ml', + sales: 19_650, + gmvWan: 15.4, + momPct: 6.8, + barColor: '#a855f7', + }, + { + rank: 5, + name: '情侣对杯礼盒 限定包装', + sales: 15_920, + gmvWan: 22.7, + momPct: 14.0, + barColor: '#ec4899', + }, +]; -/** 近12月:柱=GMV(万),折线=净利率(%)— 与原型 HTML 一致 */ -export const MONTHLY_GMV_NET_RATE = { - months: ['4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月', '1月', '2月', '3月'], - gmvWan: [168, 194, 282, 156, 172, 188, 201, 486, 218, 183, 248, 286], - netRatePct: [12.3, 13.1, 11.8, 12.8, 13.4, 14.1, 13.9, 10.2, 13.8, 14.2, 14.8, 14.3], -} as const; +/** 平台销量 TOP5(演示):万件 + 占比 */ +export type PlatformSalesTopItem = { + rank: number; + label: string; + short: string; + salesWan: number; + sharePct: number; + color: string; +}; + +export const PLATFORM_SALES_TOP5: PlatformSalesTopItem[] = [ + { rank: 1, label: '拼多多', short: 'PDD', salesWan: 58.2, sharePct: 38.6, color: '#e02e24' }, + { rank: 2, label: '抖音电商', short: '抖店', salesWan: 36.4, sharePct: 24.1, color: '#fe2c55' }, + { rank: 3, label: '淘宝', short: 'TB', salesWan: 28.7, sharePct: 19.0, color: '#ff5000' }, + { rank: 4, label: '京东', short: 'JD', salesWan: 21.3, sharePct: 14.1, color: '#e3393c' }, + { rank: 5, label: '快手小店', short: 'KS', salesWan: 6.2, sharePct: 4.1, color: '#ff6600' }, +]; export const STORES = [ { diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/index.vue index 1b65f28c..7e562039 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/workbench/index.vue @@ -24,13 +24,12 @@ import { COST_STRUCTURE, COST_STRUCTURE_PIE_COLORS, FINANCE_KPIS, - FUNNEL_STAGE_COLORS, - FUNNEL_STEPS, GLOBAL_SUMMARY, GMV_TREND, - MONTHLY_GMV_NET_RATE, PLATFORM_OPTIONS, + PLATFORM_SALES_TOP5, PRODUCT_RANK, + PRODUCT_SALES_TOP5, PRODUCT_TIME_SEGMENTS, PROMO_TABLE, PROMO_TIMELINE, @@ -64,12 +63,6 @@ const platformSelectOptions = computed(() => const financeChartRef = ref(); const { renderEcharts: renderFinanceTrend } = useEcharts(financeChartRef); -const funnelChartRef = ref(); -const { renderEcharts: renderFunnelChart } = useEcharts(funnelChartRef); - -const monthlyChartRef = ref(); -const { renderEcharts: renderMonthlyChart } = useEcharts(monthlyChartRef); - const costPieChartRef = ref(); const { renderEcharts: renderCostPieChart } = useEcharts(costPieChartRef); @@ -93,6 +86,27 @@ const costTotal = computed(() => COST_STRUCTURE.reduce((a, x) => a + x.value, 0), ); +const productSalesTopMax = computed(() => + Math.max(...PRODUCT_SALES_TOP5.map((x) => x.sales), 1), +); + +const platformSalesTopMax = computed(() => + Math.max(...PLATFORM_SALES_TOP5.map((x) => x.salesWan), 0.01), +); + +const rankMedalClass = (rank: number) => { + if (rank === 1) { + return 'bg-gradient-to-br from-amber-400 to-orange-600 text-white shadow-md shadow-amber-500/30'; + } + if (rank === 2) { + return 'bg-gradient-to-br from-slate-300 to-slate-500 text-slate-900 dark:from-slate-500 dark:to-slate-700 dark:text-white'; + } + if (rank === 3) { + return 'bg-gradient-to-br from-amber-700 to-orange-900 text-amber-100'; + } + return 'bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-300'; +}; + const keywordColumnsSimple = [ { title: '关键词', dataIndex: 'keyword', key: 'keyword', ellipsis: true }, { title: '曝光量', dataIndex: 'impression', key: 'impression' }, @@ -224,138 +238,6 @@ const drawFinanceTrend = () => { }); }; -const drawFunnel = () => { - if (!funnelChartRef.value) return; - const isDark = document.documentElement.classList.contains('dark'); - const border = isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff'; - - renderFunnelChart({ - tooltip: { - trigger: 'item', - backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff', - textStyle: { color: isDark ? 'hsl(0deg 0% 95%)' : '#0f172a' }, - formatter: '{b}: {c} 万元', - }, - series: [ - { - type: 'funnel', - left: '6%', - width: '88%', - top: 16, - bottom: 8, - minSize: '8%', - maxSize: '100%', - sort: 'descending', - gap: 2, - label: { - show: true, - position: 'inside', - formatter: '{b}\n{c}万', - color: '#fff', - fontSize: 11, - fontWeight: 700, - }, - labelLine: { show: false }, - itemStyle: { - borderColor: border, - borderWidth: 2, - }, - data: FUNNEL_STEPS.map((s, i) => ({ - name: s.name, - value: s.value, - itemStyle: { - color: FUNNEL_STAGE_COLORS[i] ?? '#6366f1', - }, - })), - }, - ], - }); -}; - -const drawMonthlyGmvNetRate = () => { - if (!monthlyChartRef.value) return; - const isDark = document.documentElement.classList.contains('dark'); - const axisLabel = isDark ? 'hsl(240deg 5% 64.9%)' : '#64748b'; - const split = isDark ? 'hsl(240deg 3.7% 22%)' : '#f1f5f9'; - - renderMonthlyChart({ - tooltip: { - trigger: 'axis', - backgroundColor: isDark ? 'hsl(222.34deg 10.43% 12.27%)' : '#fff', - textStyle: { color: isDark ? 'hsl(0deg 0% 95%)' : '#0f172a' }, - }, - legend: { - top: 0, - textStyle: { color: axisLabel }, - data: ['月GMV(万)', '净利率(%)'], - }, - grid: { left: '3%', right: '3%', bottom: '3%', top: 48, containLabel: true }, - xAxis: { - type: 'category', - data: [...MONTHLY_GMV_NET_RATE.months], - axisLine: { lineStyle: { color: split } }, - axisLabel: { color: axisLabel, fontSize: 11 }, - }, - yAxis: [ - { - type: 'value', - name: 'GMV(万)', - nameTextStyle: { color: axisLabel }, - splitLine: { lineStyle: { type: 'dashed', color: split } }, - axisLabel: { color: axisLabel }, - }, - { - type: 'value', - name: '净利率%', - min: 8, - max: 20, - position: 'right', - nameTextStyle: { color: axisLabel }, - axisLabel: { - color: axisLabel, - formatter: '{value}%', - }, - splitLine: { show: false }, - }, - ], - series: [ - { - name: '月GMV(万)', - type: 'bar', - data: [...MONTHLY_GMV_NET_RATE.gmvWan], - barMaxWidth: 22, - itemStyle: { - color: { - type: 'linear', - x: 0, - y: 0, - x2: 0, - y2: 1, - colorStops: [ - { offset: 0, color: '#6366f1' }, - { offset: 1, color: 'rgba(99, 102, 241, 0.35)' }, - ], - }, - }, - markPoint: { - data: [{ type: 'max', name: '峰值' }], - itemStyle: { color: '#f59e0b' }, - }, - }, - { - name: '净利率(%)', - type: 'line', - yAxisIndex: 1, - smooth: true, - symbolSize: 6, - data: [...MONTHLY_GMV_NET_RATE.netRatePct], - lineStyle: { width: 2.5, color: '#10b981' }, - itemStyle: { color: '#10b981' }, - }, - ], - }); -}; - const drawCostPie = () => { if (!costPieChartRef.value) return; const isDark = document.documentElement.classList.contains('dark'); @@ -425,8 +307,6 @@ const rerenderFinanceCharts = async () => { await nextTick(); drawFinanceTrend(); drawCostPie(); - drawFunnel(); - drawMonthlyGmvNetRate(); }; watch(activeTab, (k) => { @@ -645,27 +525,124 @@ const panelCardClass = -
-

- 利润漏斗(万元) -

-

- 从 GMV 到净利润全链路拆解 -

-
- +
+
+
+
+

+ 商品销量 TOP5 +

+

+ 近30天 · 按销量件数 · 含 GMV 与环比(演示) +

+
+
+
    +
  • +
    +
    + {{ row.rank }} +
    +
    +
    +

    + {{ row.name }} +

    + + {{ row.sales.toLocaleString() }} + 件 + +
    +
    + GMV {{ row.gmvWan }} 万 + + 环比 {{ row.momPct >= 0 ? '+' : '' }}{{ row.momPct }}% + +
    +
    +
    +
    +
    +
    +
  • +
-
-
-

- 月度 GMV & 净利率环比 -

-

- 柱=月 GMV(万),折线=净利率(%)· 近12月 -

-
- +
+
+
+

+ 平台销量 TOP5 +

+

+ 全店铺聚合 · 销量(万件)与占比(演示) +

+
+
+
    +
  • +
    + {{ p.rank }} +
    +
    + {{ p.short }} +
    +
    +
    + + {{ p.label }} + + + {{ p.salesWan }}万件 + +
    +
    +
    +
    +
    + + {{ p.sharePct }}% + +
    +
    +
  • +
diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/components/ProductCard.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/components/ProductCard.vue index 6e1b852d..cd0b5405 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/components/ProductCard.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/components/ProductCard.vue @@ -15,6 +15,7 @@ import { Input, InputNumber, message, + Pagination, Popconfirm, Tooltip, TreeSelect, @@ -69,6 +70,8 @@ interface Emits { (e: 'delete', product: ProductVO.Info): void; (e: 'updated', product: ProductVO.Info): void; (e: 'editing-change', editing: boolean): void; + /** 规格分页等导致卡片高度变化时,通知父级刷新瀑布流 */ + (e: 'layout-change'): void; } const handleDelete = (product: ProductVO.Info) => { @@ -241,6 +244,48 @@ const displaySpecs = computed(() => { return props.product.specs || []; }); +/** 规格表格每页条数 */ +const SPECS_PAGE_SIZE = 5; +const specsCurrentPage = ref(1); + +const specsTotalPages = computed(() => + Math.max(1, Math.ceil(displaySpecs.value.length / SPECS_PAGE_SIZE)), +); + +const pagedSpecsWithIndex = computed(() => { + const list = displaySpecs.value; + const start = (specsCurrentPage.value - 1) * SPECS_PAGE_SIZE; + return list.slice(start, start + SPECS_PAGE_SIZE).map((spec, i) => ({ + spec, + globalIndex: start + i, + })); +}); + +watch( + () => displaySpecs.value.length, + () => { + const last = specsTotalPages.value; + if (specsCurrentPage.value > last) { + specsCurrentPage.value = last; + } + }, +); + +watch( + () => props.product.id, + () => { + specsCurrentPage.value = 1; + }, +); + +watch( + specsCurrentPage, + () => { + emit('layout-change'); + }, + { flush: 'post' }, +); + const formatCost = (val?: number) => `¥${(val ?? 0).toFixed(2)}`; function addSpec() { @@ -253,6 +298,8 @@ function addSpec() { shippingCost: 0, specCode: '', }); + const len = draft.value.specs.length; + specsCurrentPage.value = Math.ceil(len / SPECS_PAGE_SIZE); (emit as (event: string, ...args: unknown[]) => void)('editing-change'); } @@ -514,24 +561,31 @@ const saveEdit = async () => { 操作
{{ spec.specCode || '未填写' }} - + {{ spec.name || '-' }}