diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue index 7133755d..8ae47a76 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/CategorySummaryTable.vue @@ -16,7 +16,9 @@ import { storeOverviewHints, } from '#/utils/overview-table-hints'; +import { useOverviewTableColumnPrefs } from '../composables/useOverviewTableColumnPrefs'; import { FINANCE_PANEL_SHELL } from '../constants/finance-ui'; +import OverviewTableColumnSettings from './OverviewTableColumnSettings.vue'; defineOptions({ name: 'WorkbenchCategorySummaryTable' }); @@ -33,6 +35,7 @@ interface Props { firstColumnLabel?: string; /** 为 true 时首列名称可点击跳转商品概览(categoryId 即商品 ID) */ productNavigate?: boolean; + columnPrefsKey?: 'category' | 'product'; } interface Emits { @@ -49,10 +52,26 @@ const props = withDefaults(defineProps(), { headingSubtitle: '包含:规模、成本及最终损益所有维度', firstColumnLabel: '品类', productNavigate: false, + columnPrefsKey: 'category', }); const emit = defineEmits(); +const { + visibleIds, + isVisible, + groupColspan, + metricColCount, + applyVisible, + resetToDefault, +} = useOverviewTableColumnPrefs( + props.columnPrefsKey as 'category' | 'product', +); + +const emptyColspan = computed( + () => (props.categoryExportMode ? 2 : 1) + metricColCount.value, +); + const allCategoriesSelected = computed(() => { const total = props.categorySummary?.categories?.length || 0; return total > 0 && props.selectedExportCategoryIds.length === total; @@ -80,6 +99,13 @@ const cellRoi = (v: number | null | undefined) => {{ props.headingSubtitle }}

+
+
+
@@ -148,92 +175,128 @@ const cellRoi = (v: number | null | undefined) => {{ props.firstColumnLabel }} 经营规模维度 成本费用维度 盈利分析维度 - + 成交金额 - + 净销售额 - + 成交单量 - + 净销售单量 - + 成交量 - + 净销量 - + 成交客单价 - + 净销售客单价 - + 商品成本 - + 运费 - + 其他成本 - + 订单成本 - + 退款金额 - + {{ (taxRate * 100).toFixed(0) }}%税额 - + 推广费 - + 刷单费 - + 毛利 - + 税前净利 - + 费比% - + ROI - + 税后净利 @@ -283,50 +346,68 @@ const cellRoi = (v: number | null | undefined) => {{ cat.categoryName }} - - - {{ formatIntCell(cat.dealOrderCount) }} - {{ formatIntCell(cat.salesOrderCount) }} - {{ formatIntCell(cat.dealQuantitySum) }} - {{ formatIntCell(cat.salesQuantitySum) }} - - + + + {{ formatIntCell(cat.dealOrderCount) }} + {{ formatIntCell(cat.salesOrderCount) }} + {{ formatIntCell(cat.dealQuantitySum) }} + {{ formatIntCell(cat.salesQuantitySum) }} + + - - - - + + + + - + - + - - + + - + - + - + {{ cat.feeRatio !== undefined ? formatFeeRatioPercent(cat.feeRatio) : '-' }} - + {{ cellRoi(cat.roi) }} - + - + 暂无数据 @@ -336,31 +417,32 @@ const cellRoi = (v: number | null | undefined) => 合计 - - - {{ formatIntCell(categorySummary?.total?.dealOrderCount) }} - {{ formatIntCell(categorySummary?.total?.salesOrderCount) }} - {{ formatIntCell(categorySummary?.total?.dealQuantitySum) }} - {{ formatIntCell(categorySummary?.total?.salesQuantitySum) }} - - + + + {{ formatIntCell(categorySummary?.total?.dealOrderCount) }} + {{ formatIntCell(categorySummary?.total?.salesOrderCount) }} + {{ formatIntCell(categorySummary?.total?.dealQuantitySum) }} + {{ formatIntCell(categorySummary?.total?.salesQuantitySum) }} + + - - - - - - - - + + + + + + + + - - - {{ categorySummary?.total?.feeRatio !== undefined ? formatFeeRatioPercent(categorySummary?.total?.feeRatio) : '-' }} - {{ cellRoi(categorySummary?.total?.roi) }} + + + {{ categorySummary?.total?.feeRatio !== undefined ? formatFeeRatioPercent(categorySummary?.total?.feeRatio) : '-' }} + {{ cellRoi(categorySummary?.total?.roi) }} diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/OverviewTableColumnSettings.vue b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/OverviewTableColumnSettings.vue new file mode 100644 index 00000000..11e9da74 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/OverviewTableColumnSettings.vue @@ -0,0 +1,180 @@ + + + diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/OverviewTables.vue b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/OverviewTables.vue index fb098f91..1dd64ef2 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/OverviewTables.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/OverviewTables.vue @@ -223,6 +223,7 @@ async function handleProductExport() { (), { }); const emit = defineEmits(); +const { + visibleIds, + isVisible, + groupColspan, + metricColCount, + applyVisible, + resetToDefault, +} = useOverviewTableColumnPrefs('platform'); + +const emptyColspan = computed( + () => (props.platformExportMode ? 2 : 1) + metricColCount.value, +); + const allPlatformsSelected = computed(() => { const total = platformData.value.length; return total > 0 && props.selectedExportPlatformCodes.length === total; @@ -126,6 +141,13 @@ const sortedData = computed(() => { {{ props.headingSubtitle }}

+
+
+
@@ -201,28 +224,32 @@ const sortedData = computed(() => { 目标达成维度 经营规模维度 成本费用维度 盈利分析维度 @@ -230,94 +257,169 @@ const sortedData = computed(() => { - + 目标单量 - + 单量达成率 - + 目标额 - + 销售达成率 - + 成交金额 - + 净销售额 - + 成交单量 - + 净销售单量 - + 成交量 - + 净销量 - + 成交客单价 - + 净销售客单价 - + 商品成本 - + 运费 - + 其他成本 - + 订单成本 - + 退款金额 - + {{ taxRateNum.toFixed(0) }}%税额 - + 推广费 - + 刷单费 - + 毛利 - + 税前净利 - + 费比% - + ROI - + 税后净利 @@ -358,38 +460,46 @@ const sortedData = computed(() => { - {{ p.targetOrderCount.toLocaleString('zh-CN') }} - {{ formatPercentPlain(p.orderCountAchievementRate) }} - - {{ formatPercentPlain(p.salesAmountAchievementRate) }} + {{ p.targetOrderCount.toLocaleString('zh-CN') }} + {{ formatPercentPlain(p.orderCountAchievementRate) }} + + {{ formatPercentPlain(p.salesAmountAchievementRate) }} - - - {{ formatIntCell(p.dealOrderCount) }} - {{ formatIntCell(p.salesOrderCount) }} - {{ formatIntCell(p.dealQuantitySum) }} - {{ formatIntCell(p.salesQuantitySum) }} - - + + + {{ formatIntCell(p.dealOrderCount) }} + {{ formatIntCell(p.salesOrderCount) }} + {{ formatIntCell(p.dealQuantitySum) }} + {{ formatIntCell(p.salesQuantitySum) }} + + - - - - - - - - + + + + + + + + - + - + - {{ formatFeeRatioPercent(p.feeRatio) }} - {{ p.roi.toFixed(2) }} + {{ formatFeeRatioPercent(p.feeRatio) }} + {{ p.roi.toFixed(2) }} @@ -402,52 +512,53 @@ const sortedData = computed(() => { 合计 - {{ formatIntCell(totalData.targetOrderCount) }} - + {{ formatIntCell(totalData.targetOrderCount) }} + {{ totalData.orderCountAchievementRate !== undefined ? formatPercentPlain(totalData.orderCountAchievementRate) : '-' }} - - + + {{ totalData.salesAmountAchievementRate !== undefined ? formatPercentPlain(totalData.salesAmountAchievementRate) : '-' }} - - - {{ formatIntCell(totalData.dealOrderCount) }} - {{ formatIntCell(totalData.salesOrderCount) }} - {{ formatIntCell(totalData.dealQuantitySum) }} - {{ formatIntCell(totalData.salesQuantitySum) }} - + + + {{ formatIntCell(totalData.dealOrderCount) }} + {{ formatIntCell(totalData.salesOrderCount) }} + {{ formatIntCell(totalData.dealQuantitySum) }} + {{ formatIntCell(totalData.salesQuantitySum) }} + - + - - - - - - + + + + + + - - + + - + - + - + {{ totalData.feeRatio !== undefined ? formatFeeRatioPercent(totalData.feeRatio) : '-' }} - + {{ cellRoi(totalData.roi) }} @@ -457,7 +568,7 @@ const sortedData = computed(() => { - 暂无数据 + 暂无数据 diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/ShopSummaryTable.vue b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/ShopSummaryTable.vue index f9980c8b..4ad2e7f7 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/ShopSummaryTable.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/components/ShopSummaryTable.vue @@ -15,7 +15,9 @@ import { storeOverviewHints, } from '#/utils/overview-table-hints'; +import { useOverviewTableColumnPrefs } from '../composables/useOverviewTableColumnPrefs'; import { FINANCE_PANEL_SHELL } from '../constants/finance-ui'; +import OverviewTableColumnSettings from './OverviewTableColumnSettings.vue'; defineOptions({ name: 'WorkbenchShopSummaryTable' }); @@ -42,6 +44,19 @@ const props = withDefaults(defineProps(), { }); const emit = defineEmits(); +const { + visibleIds, + isVisible, + groupColspan, + metricColCount, + applyVisible, + resetToDefault, +} = useOverviewTableColumnPrefs('shop'); + +const emptyColspan = computed( + () => (props.shopExportMode ? 2 : 1) + metricColCount.value, +); + const allShopsSelected = computed(() => { const total = props.shopSummary?.shops?.length || 0; return total > 0 && props.selectedExportShopIds.length === total; @@ -72,6 +87,13 @@ const cellRoi = (v: number | null | undefined) => {{ props.headingSubtitle }}

+
+
+
@@ -146,25 +169,29 @@ const cellRoi = (v: number | null | undefined) => 店铺 目标达成维度 经营规模维度 成本费用维度 盈利分析维度 @@ -172,94 +199,136 @@ const cellRoi = (v: number | null | undefined) => - + 目标单量 - + 单量达成率 - + 目标额 - + 销售达成率 - + 成交金额 - + 净销售额 - + 成交单量 - + 净销售单量 - + 成交量 - + 净销量 - + 成交客单价 - + 净销售客单价 - + 商品成本 - + 运费 - + 其他成本 - + 订单成本 - + 退款金额 - + {{ (taxRate * 100).toFixed(0) }}%税额 - + 推广费 - + 刷单费 - + 毛利 - + 税前净利 - + 费比% - + ROI - + 税后净利 @@ -302,20 +371,26 @@ const cellRoi = (v: number | null | undefined) => - + {{ formatIntCell(shop.targetOrderCount) }} - + {{ shop.orderCountAchievementRate !== undefined ? formatPercentPlain(shop.orderCountAchievementRate) : '-' }} - + - + {{ shop.salesAmountAchievementRate !== undefined ? formatPercentPlain(shop.salesAmountAchievementRate) @@ -323,78 +398,105 @@ const cellRoi = (v: number | null | undefined) => }} - + - + - + {{ formatIntCell(shop.dealOrderCount) }} - + {{ formatIntCell(shop.salesOrderCount) }} - + {{ formatIntCell(shop.dealQuantitySum) }} - + {{ formatIntCell(shop.salesQuantitySum) }} - + - + - + - + - + - + - + - + - + - + - + - + - + {{ shop.feeRatio !== undefined ? formatFeeRatioPercent(shop.feeRatio) : '-' }} - + {{ cellRoi(shop.roi) }} - + - + 暂无数据 @@ -409,16 +511,16 @@ const cellRoi = (v: number | null | undefined) => 合计 - {{ formatIntCell(shopSummary?.total?.targetOrderCount) }} - + {{ formatIntCell(shopSummary?.total?.targetOrderCount) }} + {{ shopSummary?.total?.orderCountAchievementRate !== undefined ? formatPercentPlain(shopSummary?.total?.orderCountAchievementRate) : '-' }} - - + + {{ shopSummary?.total?.salesAmountAchievementRate !== undefined ? formatPercentPlain(shopSummary?.total?.salesAmountAchievementRate) @@ -426,33 +528,34 @@ const cellRoi = (v: number | null | undefined) => }} - - - {{ formatIntCell(shopSummary?.total?.dealOrderCount) }} - {{ formatIntCell(shopSummary?.total?.salesOrderCount) }} - {{ formatIntCell(shopSummary?.total?.dealQuantitySum) }} - {{ formatIntCell(shopSummary?.total?.salesQuantitySum) }} - + + + {{ formatIntCell(shopSummary?.total?.dealOrderCount) }} + {{ formatIntCell(shopSummary?.total?.salesOrderCount) }} + {{ formatIntCell(shopSummary?.total?.dealQuantitySum) }} + {{ formatIntCell(shopSummary?.total?.salesQuantitySum) }} + - + - - - - - - - - + + + + + + + + - - - {{ shopSummary?.total?.feeRatio !== undefined ? formatFeeRatioPercent(shopSummary?.total?.feeRatio) : '-' }} - {{ cellRoi(shopSummary?.total?.roi) }} + + + {{ shopSummary?.total?.feeRatio !== undefined ? formatFeeRatioPercent(shopSummary?.total?.feeRatio) : '-' }} + {{ cellRoi(shopSummary?.total?.roi) }} diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/composables/useOverviewTableColumnPrefs.ts b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/composables/useOverviewTableColumnPrefs.ts new file mode 100644 index 00000000..dcdb71f9 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/composables/useOverviewTableColumnPrefs.ts @@ -0,0 +1,95 @@ +import { computed, ref } from 'vue'; + +import type { + OverviewColGroupId, + OverviewColumnId, + OverviewTableKey, +} from '../constants/overview-table-columns'; +import { + columnsForTable, + defaultVisibleIds, + OVERVIEW_TABLE_COLUMN_PREFS_KEY, +} from '../constants/overview-table-columns'; + +type PrefsMap = Partial>; + +function normalizeIds( + tableKey: OverviewTableKey, + raw: string[] | undefined, +): OverviewColumnId[] { + const allowed = new Set(columnsForTable(tableKey).map((c) => c.id)); + const picked = (raw ?? []).filter((id): id is OverviewColumnId => + allowed.has(id as OverviewColumnId), + ); + return picked.length > 0 ? picked : defaultVisibleIds(tableKey); +} + +function loadAll(): PrefsMap { + try { + const raw = localStorage.getItem(OVERVIEW_TABLE_COLUMN_PREFS_KEY); + if (!raw) return {}; + const parsed = JSON.parse(raw) as PrefsMap; + return parsed && typeof parsed === 'object' ? parsed : {}; + } catch { + return {}; + } +} + +function saveAll(map: PrefsMap) { + localStorage.setItem(OVERVIEW_TABLE_COLUMN_PREFS_KEY, JSON.stringify(map)); +} + +/** + * 经营概览单表列显隐偏好(localStorage,按 shop/platform/category/product 分键)。 + */ +export function useOverviewTableColumnPrefs(tableKey: OverviewTableKey) { + const visibleIds = ref( + normalizeIds(tableKey, loadAll()[tableKey]), + ); + + const visibleSet = computed(() => new Set(visibleIds.value)); + + function isVisible(id: OverviewColumnId): boolean { + return visibleSet.value.has(id); + } + + function groupColspan(group: OverviewColGroupId): number { + return columnsForTable(tableKey).filter( + (c) => c.group === group && visibleSet.value.has(c.id), + ).length; + } + + /** 指标列数量(不含首列/导出勾选列) */ + const metricColCount = computed(() => visibleIds.value.length); + + function persist(ids: OverviewColumnId[]) { + visibleIds.value = ids; + const all = loadAll(); + all[tableKey] = ids; + saveAll(all); + } + + function applyVisible(ids: string[]) { + const next = normalizeIds(tableKey, ids); + if (next.length === 0) { + persist(defaultVisibleIds(tableKey)); + return; + } + // 保持目录顺序 + const order = columnsForTable(tableKey).map((c) => c.id); + persist(order.filter((id) => next.includes(id))); + } + + function resetToDefault() { + persist(defaultVisibleIds(tableKey)); + } + + return { + visibleIds, + isVisible, + groupColspan, + metricColCount, + applyVisible, + resetToDefault, + }; +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/constants/overview-table-columns.ts b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/constants/overview-table-columns.ts new file mode 100644 index 00000000..cb63ae00 --- /dev/null +++ b/ecom-dmb-frontend/apps/web-antd/src/views/bi/workbench/tabs/finance/constants/overview-table-columns.ts @@ -0,0 +1,107 @@ +/** 经营概览底部四表:可配置列目录(首列维度名固定不可隐藏) */ + +export type OverviewTableKey = 'shop' | 'platform' | 'category' | 'product'; + +export type OverviewColGroupId = 'target' | 'scale' | 'cost' | 'profit'; + +export type OverviewColumnId = + | 'targetOrderCount' + | 'orderCountAchievementRate' + | 'targetAmount' + | 'salesAmountAchievementRate' + | 'dealAmount' + | 'salesAmount' + | 'dealOrderCount' + | 'salesOrderCount' + | 'dealQuantitySum' + | 'salesQuantitySum' + | 'dealAverageOrderValue' + | 'salesAverageOrderValue' + | 'productCost' + | 'shippingCost' + | 'otherCost' + | 'orderCost' + | 'refundAmount' + | 'salesTaxAmount' + | 'totalPromotionFee' + | 'brushFee' + | 'grossProfit' + | 'totalProfitBeforeTax' + | 'feeRatio' + | 'roi' + | 'profitAfterTax'; + +export type OverviewColumnDef = { + id: OverviewColumnId; + label: string; + group: OverviewColGroupId; +}; + +export type OverviewColGroupDef = { + id: OverviewColGroupId; + label: string; + /** 表头分组着色用 */ + tone: 'target' | 'scale' | 'cost' | 'profit'; +}; + +export const OVERVIEW_COL_GROUPS: OverviewColGroupDef[] = [ + { id: 'target', label: '目标达成维度', tone: 'target' }, + { id: 'scale', label: '经营规模维度', tone: 'scale' }, + { id: 'cost', label: '成本费用维度', tone: 'cost' }, + { id: 'profit', label: '盈利分析维度', tone: 'profit' }, +]; + +/** 全量指标列(店铺/平台含目标;品类/商品不含) */ +export const OVERVIEW_COLUMNS: OverviewColumnDef[] = [ + { id: 'targetOrderCount', label: '目标单量', group: 'target' }, + { id: 'orderCountAchievementRate', label: '单量达成率', group: 'target' }, + { id: 'targetAmount', label: '目标额', group: 'target' }, + { id: 'salesAmountAchievementRate', label: '销售达成率', group: 'target' }, + { id: 'dealAmount', label: '成交金额', group: 'scale' }, + { id: 'salesAmount', label: '净销售额', group: 'scale' }, + { id: 'dealOrderCount', label: '成交单量', group: 'scale' }, + { id: 'salesOrderCount', label: '净销售单量', group: 'scale' }, + { id: 'dealQuantitySum', label: '成交量', group: 'scale' }, + { id: 'salesQuantitySum', label: '净销量', group: 'scale' }, + { id: 'dealAverageOrderValue', label: '成交客单价', group: 'scale' }, + { id: 'salesAverageOrderValue', label: '净销售客单价', group: 'scale' }, + { id: 'productCost', label: '商品成本', group: 'cost' }, + { id: 'shippingCost', label: '运费', group: 'cost' }, + { id: 'otherCost', label: '其他成本', group: 'cost' }, + { id: 'orderCost', label: '订单成本', group: 'cost' }, + { id: 'refundAmount', label: '退款金额', group: 'cost' }, + { id: 'salesTaxAmount', label: '税额', group: 'cost' }, + { id: 'totalPromotionFee', label: '推广费', group: 'cost' }, + { id: 'brushFee', label: '刷单费', group: 'cost' }, + { id: 'grossProfit', label: '毛利', group: 'profit' }, + { id: 'totalProfitBeforeTax', label: '税前净利', group: 'profit' }, + { id: 'feeRatio', label: '费比%', group: 'profit' }, + { id: 'roi', label: 'ROI', group: 'profit' }, + { id: 'profitAfterTax', label: '税后净利', group: 'profit' }, +]; + +const TARGET_IDS = new Set( + OVERVIEW_COLUMNS.filter((c) => c.group === 'target').map((c) => c.id), +); + +/** 某张表可用的列(品类/商品无目标列) */ +export function columnsForTable(tableKey: OverviewTableKey): OverviewColumnDef[] { + if (tableKey === 'category' || tableKey === 'product') { + return OVERVIEW_COLUMNS.filter((c) => !TARGET_IDS.has(c.id)); + } + return [...OVERVIEW_COLUMNS]; +} + +export function defaultVisibleIds(tableKey: OverviewTableKey): OverviewColumnId[] { + return columnsForTable(tableKey).map((c) => c.id); +} + +export function groupsForTable(tableKey: OverviewTableKey): OverviewColGroupDef[] { + if (tableKey === 'category' || tableKey === 'product') { + return OVERVIEW_COL_GROUPS.filter((g) => g.id !== 'target'); + } + return [...OVERVIEW_COL_GROUPS]; +} + +export const OVERVIEW_TABLE_COLUMN_PREFS_KEY = + 'bi.workbench.overviewTableColumns.v1';