fix: 修复店铺概览和商品概览

This commit is contained in:
2026-08-14 20:39:13 +08:00
parent 65a3c2b444
commit e39d34700e
21 changed files with 217 additions and 37 deletions
@@ -0,0 +1,15 @@
-- 电商目录与店铺/商品概览:/ecom → /ec,组件路径对齐 views/ec
UPDATE `sys_menu`
SET `path` = '/ec'
WHERE `name` = '电商页面'
AND `path` IN ('/ecom', '/ecommerce');
UPDATE `sys_menu`
SET `path` = 'shop/overview/:id',
`component` = '/ec/shop/overview/index'
WHERE `name` = '店铺概览';
UPDATE `sys_menu`
SET `path` = 'product/overview/:id',
`component` = '/ec/product/overview/index'
WHERE `name` = '商品概览';
@@ -330,7 +330,7 @@ SELECT 11000, NULL, 0, '组织管理', '组织管理', '/organization', '', '',
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '组织管理');
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
SELECT 12000, NULL, 0, '电商页面', '电商页面', '/ecom', '', '', 'lucide:store', 'catalog', 0, 1, 0, 13
SELECT 12000, NULL, 0, '电商页面', '电商页面', '/ec', '', '', 'lucide:store', 'catalog', 0, 1, 0, 13
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '电商页面');
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
@@ -442,11 +442,11 @@ SELECT 11005, (SELECT id FROM `sys_menu` WHERE `name` = '组织管理' LIMIT 1),
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '职位权限分配');
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
SELECT 12001, (SELECT id FROM `sys_menu` WHERE `name` = '电商页面' LIMIT 1), 0, '店铺概览', '店铺概览', 'shop/overview/:id', '/ecommerce/shop/overview/index', '', 'gravity-ui:chart-line', 'embedded', 0, 1, 1, 0
SELECT 12001, (SELECT id FROM `sys_menu` WHERE `name` = '电商页面' LIMIT 1), 0, '店铺概览', '店铺概览', 'shop/overview/:id', '/ec/shop/overview/index', '', 'gravity-ui:chart-line', 'embedded', 0, 1, 1, 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '店铺概览');
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
SELECT 12002, (SELECT id FROM `sys_menu` WHERE `name` = '电商页面' LIMIT 1), 0, '商品概览', '商品概览', 'product/overview/:id', '/ecommerce/product/overview/index', '', 'lets-icons:chart', 'embedded', 0, 1, 1, 1
SELECT 12002, (SELECT id FROM `sys_menu` WHERE `name` = '电商页面' LIMIT 1), 0, '商品概览', '商品概览', 'product/overview/:id', '/ec/product/overview/index', '', 'lets-icons:chart', 'embedded', 0, 1, 1, 1
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `name` = '商品概览');
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
@@ -0,0 +1 @@
export * from './types';
@@ -0,0 +1 @@
export type { CompanyOverviewVO } from './types.vo';
@@ -0,0 +1,166 @@
/**
* 全店铺概览 / 工作台汇总表 VO(对齐后端 CompanyOverviewVO)
* @see top.xyquan.ecomdmbbackend.modules.bi.overview.model.vo.CompanyOverviewVO
*/
export namespace CompanyOverviewVO {
/** 全店总销售额 */
export interface Overview {
totalSalesAmount?: number;
/** 较上月同期增长百分比 */
monthOverMonthGrowth?: number;
totalOrderCount?: number;
totalPromotionFee?: number;
/** 平均费比(推广费/销售额,小数如 0.05) */
averageFeeRatio?: number;
totalNetProfitAfterTax?: number;
totalTaxAmount?: number;
shopSalesRatios?: ShopSalesRatio[];
shopEfficiencyQuadrants?: ShopEfficiencyQuadrant[];
salesAmountTrend?: TrendData;
orderCountTrend?: TrendData;
shopSummary?: ShopOverview;
categorySummary?: CategoryOverview;
platformSummary?: PlatformOverview;
totalROI?: number;
totalProfitAfterTax?: number;
totalTargetOrderCount?: number;
totalTargetAmount?: number;
orderCountAchievementRate?: number;
salesAmountAchievementRate?: number;
}
export interface TrendData {
total?: number;
dailyDataList?: TrendDataItem[];
}
export interface TrendDataItem {
/** yyyy-MM-dd */
date?: string;
value?: number;
}
export interface ShopSalesRatio {
shopId?: number;
shopName?: string;
salesAmount?: number;
/** 占比百分比 */
ratio?: number;
}
export interface ShopEfficiencyQuadrant {
shopId?: number;
shopName?: string;
roi?: number;
netProfit?: number;
/** 1–4 象限 */
quadrant?: number;
}
/** 平台维度概览 */
export interface PlatformOverview {
total?: PlatformSummary;
platforms?: PlatformSummary[];
}
/** 多店铺概览 */
export interface ShopOverview {
total?: ShopSummary;
shops?: ShopSummary[];
}
/** 多品类概览(商品表复用同一结构;categoryId 存商品 ID) */
export interface CategoryOverview {
total?: CategorySummary;
categories?: CategorySummary[];
}
/** 工作台底部四张汇总表 */
export interface WorkbenchTableBundle {
shopTable?: ShopOverview;
platformTable?: PlatformOverview;
categoryTable?: CategoryOverview;
productTable?: CategoryOverview;
}
/** 店铺汇总行 */
export interface ShopSummary {
shopId?: number;
shopName?: string;
platform?: string;
targetOrderCount?: number;
orderCountAchievementRate?: number;
targetAmount?: number;
salesAmountAchievementRate?: number;
salesAmount?: number;
/** 成交金额(全订单状态商家实收合计) */
dealAmount?: number;
orderCount?: number;
averageOrderValue?: number;
productCost?: number;
shippingCost?: number;
otherCost?: number;
/** 订单成本(商品成本+运费+其他成本,不含推广费、刷单费) */
orderCost?: number;
refundAmount?: number;
totalPromotionFee?: number;
brushFee?: number;
/** 费比(推广费/销售额,小数) */
feeRatio?: number;
grossProfit?: number;
totalProfitBeforeTax?: number;
salesTaxAmount?: number;
profitAfterTax?: number;
roi?: number;
}
/** 品类/商品汇总行 */
export interface CategorySummary {
categoryId?: number | null;
categoryName?: string;
salesAmount?: number;
dealAmount?: number;
orderCount?: number;
averageOrderValue?: number;
productCost?: number;
shippingCost?: number;
otherCost?: number;
orderCost?: number;
refundAmount?: number;
totalPromotionFee?: number;
brushFee?: number;
feeRatio?: number;
grossProfit?: number;
totalProfitBeforeTax?: number;
salesTaxAmount?: number;
profitAfterTax?: number;
roi?: number;
}
/** 平台维度汇总行 */
export interface PlatformSummary {
platformCode?: string;
platformName?: string;
targetOrderCount?: number;
orderCountAchievementRate?: number;
targetAmount?: number;
salesAmountAchievementRate?: number;
salesAmount?: number;
dealAmount?: number;
orderCount?: number;
averageOrderValue?: number;
productCost?: number;
shippingCost?: number;
otherCost?: number;
orderCost?: number;
refundAmount?: number;
totalPromotionFee?: number;
brushFee?: number;
feeRatio?: number;
grossProfit?: number;
totalProfitBeforeTax?: number;
salesTaxAmount?: number;
roi?: number;
profitAfterTax?: number;
}
}
@@ -1,7 +1,7 @@
/**
* 工作台聚合 VO(与后端 Workbench*VO 对齐)
*/
import type { CompanyOverviewVO } from '#/api/ec/store-overview/types';
import type { CompanyOverviewVO } from '#/api/bi/overview';
export namespace WorkbenchVO {
export interface DimRow {
@@ -504,7 +504,7 @@ const activeTab = ref('finance');
function handleShopNavigate(shopId: number) {
router.push({
path: `/ecom/shop/overview/${shopId}`,
path: `/ec/shop/overview/${shopId}`,
query: buildOverviewRouteQuery(dateRange.value),
});
}
@@ -512,7 +512,7 @@ function handleShopNavigate(shopId: number) {
function handleProductNavigate(productId: number) {
const shopId = parseSelectedShopId();
router.push({
path: `/ecom/product/overview/${productId}`,
path: `/ec/product/overview/${productId}`,
query: buildOverviewRouteQuery(
dateRange.value,
shopId != null && Number.isFinite(shopId) && shopId > 0
@@ -11,7 +11,7 @@ import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { getWorkbenchPeriodCompareSliceApi } from '#/api/bi/workbench/apis';
import type { WorkbenchDTO, WorkbenchVO } from '#/api/bi/workbench/types';
import type { CompanyOverviewVO } from '#/api/ec/store-overview/types';
import type { CompanyOverviewVO } from '#/api/bi/overview';
import OverviewColumnHint from '#/components/overview/OverviewColumnHint.vue';
import { normalizeOverviewRangePickerChange } from '#/utils/overview-date-range';
import {
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { CompanyOverviewVO } from '#/api/ec/store-overview';
import type { CompanyOverviewVO } from '#/api/bi/overview';
import { createIconifyIcon } from '@vben/icons';
import { computed } from 'vue';
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { ref } from 'vue';
import type { CompanyOverviewVO } from '#/api/ec/store-overview';
import type { CompanyOverviewVO } from '#/api/bi/overview';
import type { WorkbenchDTO } from '#/api/bi/workbench/types';
import { message, Segmented } from 'ant-design-vue';
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { computed, ref } from 'vue';
import type { CompanyOverviewVO } from '#/api/ec/store-overview';
import type { CompanyOverviewVO } from '#/api/bi/overview';
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
import { formatIntCell, formatNumberCell } from '#/utils/overview-table-cells';
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { CompanyOverviewVO } from '#/api/ec/store-overview';
import type { CompanyOverviewVO } from '#/api/bi/overview';
import { createIconifyIcon } from '@vben/icons';
import { computed } from 'vue';
@@ -130,10 +130,7 @@ const cellRoi = (v: number | null | undefined) =>
@change="
(e) => {
if ((e.target as HTMLInputElement).checked) {
emit(
'update:selectedExportShopIds',
shopSummary?.shops?.map((s) => s.shopId) || [],
);
emit('update:selectedExportShopIds', (shopSummary?.shops?.map((s) => s.shopId) || []).filter((id): id is number => id !== undefined));
} else {
emit('update:selectedExportShopIds', []);
}
@@ -281,7 +278,7 @@ const cellRoi = (v: number | null | undefined) =>
const newIds = checked
? [...selectedExportShopIds, shop.shopId]
: selectedExportShopIds.filter((id) => id !== shop.shopId);
emit('update:selectedExportShopIds', newIds);
emit('update:selectedExportShopIds', newIds.filter((id): id is number => id !== undefined));
}
"
/>
@@ -292,7 +289,7 @@ const cellRoi = (v: number | null | undefined) =>
>
<span
class="inline-flex cursor-pointer items-center gap-1 rounded-full bg-blue-50 dark:bg-blue-900/30 px-3 py-1 text-sm font-bold text-blue-600 dark:text-blue-400 transition-colors hover:text-blue-300 hover:underline"
@click="emit('navigate', shop.shopId)"
@click="emit('navigate', shop.shopId as number)"
>
{{ shop.shopName }}
<JumpIcon class="text-xs" />
@@ -321,10 +318,10 @@ const cellRoi = (v: number | null | undefined) =>
</td>
<!-- 规模 -->
<td class="p-6 font-black">
{{ formatAmount(shop.salesAmount) }}
{{ formatAmount(shop.salesAmount as number) }}
</td>
<td class="p-6 font-black text-amber-700 dark:text-amber-400">
{{ formatAmount(shop.dealAmount) }}
{{ formatAmount(shop.dealAmount as number ) }}
</td>
<td class="p-6 font-medium">
{{ formatIntCell(shop.orderCount) }}
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import type { WorkbenchDTO, WorkbenchVO } from '#/api/bi/workbench/types';
import type { CompanyOverviewVO } from '#/api/ec/store-overview';
import type { CompanyOverviewVO } from '#/api/bi/overview';
import { computed, nextTick, ref } from 'vue';
@@ -1,4 +1,4 @@
import type { CompanyOverviewVO } from '#/api/ec/store-overview';
import type { CompanyOverviewVO } from '#/api/bi/overview';
import type { WorkbenchVO } from '#/api/bi/workbench/types';
function yuanField(v?: number | null): number {
@@ -39,7 +39,7 @@ function aggregateShopTotal(
const orderCount = sum('orderCount') || 1;
const totalPromotionFee = sum('totalPromotionFee');
const averageOrderValue = salesAmount / orderCount;
const feeRatio = salesAmount ? (totalPromotionFee / salesAmount) * 100 : 0;
const feeRatio = salesAmount ? totalPromotionFee / salesAmount : 0;
return {
shopId: 0,
shopName: '合计',
@@ -110,7 +110,7 @@ function aggregateCategoryTotal(
const orderCount = sum('orderCount') || 1;
const totalPromotionFee = sum('totalPromotionFee');
const averageOrderValue = salesAmount / orderCount;
const feeRatio = salesAmount ? (totalPromotionFee / salesAmount) * 100 : 0;
const feeRatio = salesAmount ? totalPromotionFee / salesAmount : 0;
return {
categoryName: '合计',
salesAmount,
@@ -174,7 +174,7 @@ function aggregatePlatformTotal(
const orderCount = sum('orderCount') || 1;
const totalPromotionFee = sum('totalPromotionFee');
const averageOrderValue = salesAmount / orderCount;
const feeRatio = salesAmount ? (totalPromotionFee / salesAmount) * 100 : 0;
const feeRatio = salesAmount ? totalPromotionFee / salesAmount : 0;
return {
platformCode: '',
platformName: '合计',
@@ -626,7 +626,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
gridReloadRef.value = () => gridApi.reload();
function goToShopDetail(shopId: number) {
router.push(`/ecom/shop/overview/${shopId}`);
router.push(`/ec/shop/overview/${shopId}`);
}
function openDetail(row: OrderVO.Info) {
@@ -117,7 +117,7 @@ function open(record: ProductVO.Info) {
/** 跳转经营统计 */
function goOverview() {
if (!product.value) return;
router.push(`/ecom/product/overview/${product.value.id}`);
router.push(`/ec/product/overview/${product.value.id}`);
modalApi.close();
}
@@ -22,8 +22,8 @@ import dayjs from 'dayjs';
import { getCategoryTreeApi } from '#/api/ec/product/category';
import { createProductApi, updateProductApi } from '#/api/ec/product';
import { uploadFileToOss } from '#/utils/oss-upload';
import CategoryFormModal from '#/views/ecommerce/config/category-config/components/CategoryFormModal.vue';
import ProductCostSyncToOrdersModal from '#/views/ecommerce/product/components/ProductCostSyncToOrdersModal.vue';
import CategoryFormModal from '#/views/ec/product/category/components/CategoryFormModal.vue';
import ProductCostSyncToOrdersModal from '#/views/ec/product/components/ProductCostSyncToOrdersModal.vue';
interface Emits {
(e: 'success'): void;
@@ -287,7 +287,7 @@ function openProductDetail(record: ProductVO.Info) {
}
function goToOverview(record: ProductVO.Info) {
router.push(`/ecom/product/overview/${record.id}`);
router.push(`/ec/product/overview/${record.id}`);
}
async function handleDelete(record: ProductVO.Info) {
@@ -36,7 +36,7 @@ const SHOP_PAGE_SIZE = 20;
/** 当前是否为商品概览路由(keep-alive 下勿用其它页的 params.id 请求商品接口) */
const isProductOverviewRoute = () =>
/\/ecom\/product\/overview\/[^/]+\/?$/.test(route.path);
/\/ec\/product\/overview\/[^/]+\/?$/.test(route.path);
// 商品ID(从路由参数获取)
const productId = computed(() => {
@@ -274,7 +274,7 @@ function handleShopChange(nextShopId: number | undefined) {
products.value = [];
productSearchKeyword.value = '';
router.replace({
path: `/ecom/product/overview/${productId.value}`,
path: `/ec/product/overview/${productId.value}`,
query: buildOverviewRouteQuery(
dateRange.value,
nextShopId != null && nextShopId > 0 ? { shopId: nextShopId } : undefined,
@@ -332,7 +332,7 @@ function handleProductChange(nextProductId: number) {
if (!nextProductId || nextProductId === productId.value) return;
lastRequestKey.value = '';
router.push({
path: `/ecom/product/overview/${nextProductId}`,
path: `/ec/product/overview/${nextProductId}`,
query: buildProductOverviewQuery(),
});
}
@@ -54,7 +54,7 @@ function goToProductOverview(productId: number) {
if (dateQ) {
router.push({
path: `/ecom/product/overview/${productId}`,
path: `/ec/product/overview/${productId}`,
query: buildOverviewRouteQuery(
[dayjs(dateQ.startDate), dayjs(dateQ.endDate)],
shopId != null ? { shopId } : undefined,
@@ -65,13 +65,13 @@ function goToProductOverview(productId: number) {
if (shopId != null) {
router.push({
path: `/ecom/product/overview/${productId}`,
path: `/ec/product/overview/${productId}`,
query: { shopId: String(shopId) },
});
return;
}
router.push({ path: `/ecom/product/overview/${productId}` });
router.push({ path: `/ec/product/overview/${productId}` });
}
</script>
@@ -47,7 +47,7 @@ let shopSearchTimer: ReturnType<typeof setTimeout> | undefined;
/** 当前是否为店铺概览路由(keep-alive 下 route.params.id 会随其它标签变化,不可仅凭 id 请求) */
const isShopOverviewRoute = () =>
/\/ecom\/shop\/overview\/[^/]+\/?$/.test(route.path);
/\/ec\/shop\/overview\/[^/]+\/?$/.test(route.path);
// 店铺ID(从路由参数获取)
const shopId = computed(() => {
@@ -237,7 +237,7 @@ function handleShopChange(nextShopId: number) {
if (!nextShopId || nextShopId === shopId.value) return;
lastRequestKey.value = '';
router.push({
path: `/ecom/shop/overview/${nextShopId}`,
path: `/ec/shop/overview/${nextShopId}`,
query: buildOverviewRouteQuery(dateRange.value),
});
}