fix(ecom): 移除推广费前端的platform相关代码

- types.dto.ts/vo.ts 移除 platformId / platformName
- PromotionFeeFormModal.vue 移除平台选择器和相关逻辑
- index.vue 移除平台筛选列和接口调用
- PromotionFeeCard.vue 移除平台筛选和列展示
This commit is contained in:
小蟑螂
2026-05-06 02:22:27 +08:00
parent 7bcf97fcc3
commit 8c64f33c48
5 changed files with 18 additions and 190 deletions
@@ -9,8 +9,6 @@ export namespace PromotionFeeDTO {
shopId?: number; shopId?: number;
/** 推广费类型ID */ /** 推广费类型ID */
feeTypeId?: number; feeTypeId?: number;
/** 平台ID */
platformId?: number;
/** 商品ID(可选) */ /** 商品ID(可选) */
productId?: number; productId?: number;
/** 推广费发生日期开始 */ /** 推广费发生日期开始 */
@@ -25,8 +23,6 @@ export namespace PromotionFeeDTO {
shopId: number; shopId: number;
/** 推广费类型ID */ /** 推广费类型ID */
feeTypeId: number; feeTypeId: number;
/** 平台ID */
platformId?: number;
/** 商品ID(可选,关联到具体商品) */ /** 商品ID(可选,关联到具体商品) */
productId?: number; productId?: number;
/** 推广活动名称 */ /** 推广活动名称 */
@@ -47,8 +43,6 @@ export namespace PromotionFeeDTO {
shopId: number; shopId: number;
/** 推广费类型ID */ /** 推广费类型ID */
feeTypeId: number; feeTypeId: number;
/** 平台ID */
platformId?: number;
/** 商品ID(可选,关联到具体商品) */ /** 商品ID(可选,关联到具体商品) */
productId?: number; productId?: number;
/** 推广活动名称 */ /** 推广活动名称 */
@@ -17,10 +17,6 @@ export namespace PromotionFeeVO {
feeTypeId: number; feeTypeId: number;
/** 推广费类型名称 */ /** 推广费类型名称 */
feeTypeName?: string; feeTypeName?: string;
/** 平台ID */
platformId?: number;
/** 平台名称 */
platformName?: string;
/** 商品ID(可选) */ /** 商品ID(可选) */
productId?: number; productId?: number;
/** 推广活动名称 */ /** 推广活动名称 */
@@ -27,7 +27,6 @@ import {
updatePromotionFeeApi, updatePromotionFeeApi,
} from '#/api/ecommerce/promotion-fee'; } from '#/api/ecommerce/promotion-fee';
import { getActivePromotionFeeTypeListApi } from '#/api/ecommerce/promotion-fee-type'; import { getActivePromotionFeeTypeListApi } from '#/api/ecommerce/promotion-fee-type';
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
import { getProductPageApi } from '#/api/ecommerce/product'; import { getProductPageApi } from '#/api/ecommerce/product';
import { getShopPageApi } from '#/api/ecommerce/shop'; import { getShopPageApi } from '#/api/ecommerce/shop';
@@ -74,7 +73,6 @@ const isEdit = ref(false);
const formData = ref<PromotionFeeDTO.Create>({ const formData = ref<PromotionFeeDTO.Create>({
shopId: undefined as any, shopId: undefined as any,
feeTypeId: undefined as any, feeTypeId: undefined as any,
platformId: undefined,
productId: undefined, productId: undefined,
campaignName: '', campaignName: '',
feeAmount: undefined as any, feeAmount: undefined as any,
@@ -91,10 +89,6 @@ const rules = {
feeDate: [{ required: true, message: '请选择发生日期', trigger: 'change' }], feeDate: [{ required: true, message: '请选择发生日期', trigger: 'change' }],
} as any; } as any;
// 平台选项(动态加载)
const platformList = ref<{ label: string; value: number }[]>([]);
const platformListLoading = ref(false);
// 店铺列表 // 店铺列表
const shopList = ref<ShopVO.Info[]>([]); const shopList = ref<ShopVO.Info[]>([]);
const shopListLoading = ref(false); const shopListLoading = ref(false);
@@ -119,7 +113,6 @@ watch(
formData.value = { formData.value = {
shopId: props.promotionFeeData.shopId, shopId: props.promotionFeeData.shopId,
feeTypeId: props.promotionFeeData.feeTypeId, feeTypeId: props.promotionFeeData.feeTypeId,
platformId: props.promotionFeeData.platformId,
productId: props.promotionFeeData.productId, productId: props.promotionFeeData.productId,
campaignName: props.promotionFeeData.campaignName || '', campaignName: props.promotionFeeData.campaignName || '',
feeAmount: props.promotionFeeData.feeAmount, feeAmount: props.promotionFeeData.feeAmount,
@@ -166,21 +159,6 @@ const loadFeeTypeList = async () => {
} }
}; };
const loadPlatformList = async () => {
platformListLoading.value = true;
try {
const list = await getActivePlatformsApi();
platformList.value = list.map((p) => ({
label: p.platformName,
value: p.id,
}));
} catch (error) {
console.error('加载平台列表失败:', error);
} finally {
platformListLoading.value = false;
}
};
const loadProductList = async () => { const loadProductList = async () => {
productListLoading.value = true; productListLoading.value = true;
try { try {
@@ -201,7 +179,6 @@ const resetFormData = () => {
formData.value = { formData.value = {
shopId: undefined as any, shopId: undefined as any,
feeTypeId: undefined as any, feeTypeId: undefined as any,
platformId: undefined,
productId: undefined, productId: undefined,
campaignName: '', campaignName: '',
feeAmount: undefined as any, feeAmount: undefined as any,
@@ -242,7 +219,6 @@ const handleCancel = () => {
onMounted(() => { onMounted(() => {
loadShopList(); loadShopList();
loadFeeTypeList(); loadFeeTypeList();
loadPlatformList();
loadProductList(); loadProductList();
}); });
</script> </script>
@@ -288,23 +264,6 @@ onMounted(() => {
</Select> </Select>
</Form.Item> </Form.Item>
<Form.Item label="平台" name="platformId">
<Select
v-model:value="formData.platformId"
placeholder="请选择平台"
:loading="platformListLoading"
allow-clear
>
<Select.Option
v-for="option in platformList"
:key="option.value"
:value="option.value"
>
{{ option.label }}
</Select.Option>
</Select>
</Form.Item>
<Form.Item label="商品(可选)" name="productId"> <Form.Item label="商品(可选)" name="productId">
<Select <Select
v-model:value="formData.productId" v-model:value="formData.productId"
@@ -11,7 +11,7 @@ import { computed, ref } from 'vue';
import { Page } from '@vben/common-ui'; import { Page } from '@vben/common-ui';
import { createIconifyIcon } from '@vben/icons'; import { createIconifyIcon } from '@vben/icons';
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue'; import { Button, message, Popconfirm, Space } from 'ant-design-vue';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { import {
@@ -19,32 +19,23 @@ import {
getPromotionFeePageApi, getPromotionFeePageApi,
} from '#/api/ecommerce/promotion-fee'; } from '#/api/ecommerce/promotion-fee';
import { getShopPageApi } from '#/api/ecommerce/shop/apis'; import { getShopPageApi } from '#/api/ecommerce/shop/apis';
import { getActivePlatformsApi } from '#/api/ecommerce/platform/apis';
import { getAllPromotionFeeTypeListApi } from '#/api/ecommerce/promotion-fee-type/apis'; import { getAllPromotionFeeTypeListApi } from '#/api/ecommerce/promotion-fee-type/apis';
import PromotionFeeFormModal from './components/PromotionFeeFormModal.vue'; import PromotionFeeFormModal from './components/PromotionFeeFormModal.vue';
defineOptions({ name: 'PromotionFeeManagement' }); defineOptions({ name: 'PromotionFeeManagement' });
// 创建图标组件
const PlusIcon = createIconifyIcon('lucide:plus'); const PlusIcon = createIconifyIcon('lucide:plus');
// 响应式数据
const loading = ref(false); const loading = ref(false);
const formModalVisible = ref(false); const formModalVisible = ref(false);
const currentPromotionFeeData = ref<null | PromotionFeeVO.Info>(null); const currentPromotionFeeData = ref<null | PromotionFeeVO.Info>(null);
// 店铺选择器(懒加载) // 店铺选择器(首次触发时加载)
const shopOptions = ref<{ label: string; value: number }[]>([]); const shopOptions = ref<{ label: string; value: number }[]>([]);
const shopLoading = ref(false); const shopLoading = ref(false);
const shopFetched = ref(false); const shopFetched = ref(false);
// 推广费类型选择器(懒加载)
const feeTypeOptions = ref<{ label: string; value: number }[]>([]);
const feeTypeLoading = ref(false);
const feeTypeFetched = ref(false);
// 获取店铺列表(首次触发时加载)
async function fetchShopOptions() { async function fetchShopOptions() {
if (shopFetched.value || shopLoading.value) return; if (shopFetched.value || shopLoading.value) return;
shopLoading.value = true; shopLoading.value = true;
@@ -62,7 +53,11 @@ async function fetchShopOptions() {
} }
} }
// 获取推广费类型列表(首次触发时加载) // 推广费类型选择器(首次触发时加载)
const feeTypeOptions = ref<{ label: string; value: number }[]>([]);
const feeTypeLoading = ref(false);
const feeTypeFetched = ref(false);
async function fetchFeeTypeOptions() { async function fetchFeeTypeOptions() {
if (feeTypeFetched.value || feeTypeLoading.value) return; if (feeTypeFetched.value || feeTypeLoading.value) return;
feeTypeLoading.value = true; feeTypeLoading.value = true;
@@ -84,26 +79,10 @@ async function fetchFeeTypeOptions() {
const searchForm = ref({ const searchForm = ref({
shopId: undefined as number | undefined, shopId: undefined as number | undefined,
feeTypeId: undefined as number | undefined, feeTypeId: undefined as number | undefined,
platformId: undefined as number | undefined,
feeDateStart: undefined as string | undefined, feeDateStart: undefined as string | undefined,
feeDateEnd: undefined as string | undefined, feeDateEnd: undefined as string | undefined,
}); });
// 平台选项(动态加载)
const platformOptions = ref<{ label: string; value: number }[]>([]);
const loadPlatformOptions = async () => {
try {
const list = await getActivePlatformsApi();
platformOptions.value = list.map((p) => ({
label: p.platformName,
value: p.id,
}));
} catch (e) {
console.error('加载平台列表失败', e);
}
};
loadPlatformOptions();
// VbenVxeGrid 表格配置 // VbenVxeGrid 表格配置
const gridOptions: VxeGridProps<any> = { const gridOptions: VxeGridProps<any> = {
columns: [ columns: [
@@ -130,11 +109,6 @@ const gridOptions: VxeGridProps<any> = {
minWidth: 'auto', minWidth: 'auto',
showOverflow: 'tooltip' as const, showOverflow: 'tooltip' as const,
}, },
{
title: '平台',
minWidth: 'auto',
slots: { default: 'platform' },
},
{ {
field: 'campaignName', field: 'campaignName',
title: '推广活动', title: '推广活动',
@@ -193,7 +167,6 @@ const gridOptions: VxeGridProps<any> = {
| 'Total' | 'Total'
)[], )[],
}, },
// 配置远程加载
proxyConfig: { proxyConfig: {
ajax: { ajax: {
query: async ({ page }) => { query: async ({ page }) => {
@@ -205,23 +178,16 @@ const gridOptions: VxeGridProps<any> = {
filters: { filters: {
shopId: searchForm.value.shopId || undefined, shopId: searchForm.value.shopId || undefined,
feeTypeId: searchForm.value.feeTypeId || undefined, feeTypeId: searchForm.value.feeTypeId || undefined,
platformId: searchForm.value.platformId || undefined,
feeDateStart: searchForm.value.feeDateStart || undefined, feeDateStart: searchForm.value.feeDateStart || undefined,
feeDateEnd: searchForm.value.feeDateEnd || undefined, feeDateEnd: searchForm.value.feeDateEnd || undefined,
}, },
}; };
const data = await getPromotionFeePageApi(params); const data = await getPromotionFeePageApi(params);
return { return { items: data.records, total: data.total };
items: data.records,
total: data.total,
};
} catch (error) { } catch (error) {
console.error('获取推广费记录列表失败:', error); console.error('获取推广费记录列表失败:', error);
message.error('获取推广费记录列表失败'); message.error('获取推广费记录列表失败');
return { return { items: [], total: 0 };
items: [],
total: 0,
};
} finally { } finally {
loading.value = false; loading.value = false;
} }
@@ -270,17 +236,6 @@ const formOptions = computed(() => ({
fieldName: 'feeTypeId', fieldName: 'feeTypeId',
label: '推广费类型', label: '推广费类型',
}, },
{
component: 'Select',
componentProps: {
placeholder: '请选择平台',
options: platformOptions,
allowClear: true,
onChange: () => gridReloadRef.value?.(),
},
fieldName: 'platformId',
label: '平台',
},
{ {
component: 'DatePicker', component: 'DatePicker',
componentProps: { componentProps: {
@@ -307,14 +262,10 @@ const formOptions = computed(() => ({
collapsedRows: 1, collapsedRows: 1,
})); }));
// 刷新表格数据
function refreshTable() { function refreshTable() {
if (gridApi) { gridApi?.reload();
gridApi.reload();
}
} }
// 创建 VbenVxeGrid 实例
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
gridOptions, gridOptions,
formOptions: formOptions.value, formOptions: formOptions.value,
@@ -323,20 +274,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
}); });
gridReloadRef.value = () => gridApi.reload(); gridReloadRef.value = () => gridApi.reload();
// 处理新增
const handleAdd = () => { const handleAdd = () => {
currentPromotionFeeData.value = null; currentPromotionFeeData.value = null;
formModalVisible.value = true; formModalVisible.value = true;
}; };
// 处理编辑
const handleEdit = (record: PromotionFeeVO.Info) => { const handleEdit = (record: PromotionFeeVO.Info) => {
currentPromotionFeeData.value = record; currentPromotionFeeData.value = record;
formModalVisible.value = true; formModalVisible.value = true;
}; };
// 处理删除 async function handleDelete(id: number) {
const handleDelete = async (id: number) => {
try { try {
await deletePromotionFeeApi(id); await deletePromotionFeeApi(id);
message.success('删除成功'); message.success('删除成功');
@@ -344,51 +292,20 @@ const handleDelete = async (id: number) => {
} catch { } catch {
message.error('删除失败'); message.error('删除失败');
} }
}; }
// 处理表单成功
const handleFormSuccess = () => { const handleFormSuccess = () => {
refreshTable(); refreshTable();
}; };
// 格式化金额 const formatAmount = (amount: number) => `¥${amount.toFixed(2)}`;
const formatAmount = (amount: number) => {
return `¥${amount.toFixed(2)}`;
};
// 获取平台标签颜色
const getPlatformColor = (platformName: string | undefined) => {
switch (platformName) {
case '京东': {
return 'red';
}
case '天猫': {
return 'purple';
}
case '快手': {
return 'cyan';
}
case '抖音': {
return 'blue';
}
case '拼多多': {
return 'green';
}
case '淘宝': {
return 'orange';
}
default: {
return 'default';
}
}
};
</script> </script>
<template> <template>
<Page title="推广费管理" auto-content-height> <Page title="推广费管理" auto-content-height>
<template #description> <template #description>
<div class="text-foreground/80 mt-2"> <div class="text-foreground/80 mt-2">
管理店铺推广费用记录,支持按店铺、类型、平台等维度查询和统计 管理店铺推广费用记录,支持按店铺、类型等维度查询和统计
</div> </div>
</template> </template>
@@ -401,33 +318,21 @@ const getPlatformColor = (platformName: string | undefined) => {
</Space> </Space>
</template> </template>
<!-- 数据表格 -->
<Grid :loading="loading"> <Grid :loading="loading">
<!-- 工具栏工具 -->
<template #toolbar-tools> <template #toolbar-tools>
<Space> <Space>
<span class="text-gray-500"> <span class="text-gray-500">
支持按店铺、类型、平台等维度查询推广费记录 支持按店铺、类型等维度查询推广费记录
</span> </span>
</Space> </Space>
</template> </template>
<!-- 平台列 -->
<template #platform="{ row }: { row: any }">
<Tag v-if="row.platformName" :color="getPlatformColor(row.platformName)">
{{ row.platformName }}
</Tag>
<span v-else class="text-gray-400">-</span>
</template>
<!-- 推广费金额列 -->
<template #feeAmount="{ row }: { row: any }"> <template #feeAmount="{ row }: { row: any }">
<span class="font-medium text-red-600"> <span class="font-medium text-red-600">
{{ formatAmount(row.feeAmount) }} {{ formatAmount(row.feeAmount) }}
</span> </span>
</template> </template>
<!-- 操作列 -->
<template #action="{ row }: { row: any }"> <template #action="{ row }: { row: any }">
<Space> <Space>
<Button size="small" @click="handleEdit(row)"> 编辑 </Button> <Button size="small" @click="handleEdit(row)"> 编辑 </Button>
@@ -441,7 +346,6 @@ const getPlatformColor = (platformName: string | undefined) => {
</template> </template>
</Grid> </Grid>
<!-- 表单弹窗 -->
<PromotionFeeFormModal <PromotionFeeFormModal
v-model:open="formModalVisible" v-model:open="formModalVisible"
:promotion-fee-data="currentPromotionFeeData" :promotion-fee-data="currentPromotionFeeData"
@@ -4,7 +4,7 @@ import type { PromotionFeeDTO, PromotionFeeVO } from '#/api/ecommerce/promotion-
import type { ShopVO } from '#/api/ecommerce/shop/types'; import type { ShopVO } from '#/api/ecommerce/shop/types';
import type { PageQueryDTO } from '#/types/common'; import type { PageQueryDTO } from '#/types/common';
import { Button, DatePicker, Popconfirm, Select, Space } from 'ant-design-vue'; import { Button, DatePicker, Popconfirm, Space } from 'ant-design-vue';
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { createIconifyIcon } from '@vben/icons'; import { createIconifyIcon } from '@vben/icons';
@@ -13,7 +13,6 @@ import {
deletePromotionFeeApi, deletePromotionFeeApi,
getPromotionFeePageApi, getPromotionFeePageApi,
} from '#/api/ecommerce/promotion-fee'; } from '#/api/ecommerce/promotion-fee';
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
import PromotionFeeFormModal from '#/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue'; import PromotionFeeFormModal from '#/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue';
@@ -31,24 +30,10 @@ const kpi = computed(() => props.data);
const gridReloadRef = ref<(() => void) | null>(null); const gridReloadRef = ref<(() => void) | null>(null);
const searchForm = ref({ const searchForm = ref({
platformId: undefined as number | undefined,
feeDateStart: undefined as string | undefined, feeDateStart: undefined as string | undefined,
feeDateEnd: undefined as string | undefined, feeDateEnd: undefined as string | undefined,
}); });
// 平台选项(动态加载)
const platformList = ref<{ label: string; value: number }[]>([]);
const loadPlatformList = async () => {
try {
const list = await getActivePlatformsApi();
platformList.value = list.map((p) => ({ label: p.platformName, value: p.id }));
} catch (e) {
console.error('加载平台列表失败', e);
}
};
loadPlatformList();
const modalVisible = ref(false); const modalVisible = ref(false);
const editingData = ref<PromotionFeeVO.Info | undefined>(); const editingData = ref<PromotionFeeVO.Info | undefined>();
@@ -56,7 +41,6 @@ const gridOptions: VxeGridProps<any> = {
columns: [ columns: [
{ type: 'seq', title: '序号', width: 60 }, { type: 'seq', title: '序号', width: 60 },
{ field: 'productId', title: '商品ID', width: 90 }, { field: 'productId', title: '商品ID', width: 90 },
{ field: 'platformName', title: '平台', width: 90 },
{ field: 'campaignName', title: '活动名称', minWidth: 140 }, { field: 'campaignName', title: '活动名称', minWidth: 140 },
{ {
field: 'feeAmount', title: '费用金额', width: 130, field: 'feeAmount', title: '费用金额', width: 130,
@@ -85,7 +69,6 @@ const gridOptions: VxeGridProps<any> = {
pageSize: page.pageSize, pageSize: page.pageSize,
filters: { filters: {
shopId: props.shopId || undefined, shopId: props.shopId || undefined,
platformId: searchForm.value.platformId,
feeDateStart: searchForm.value.feeDateStart, feeDateStart: searchForm.value.feeDateStart,
feeDateEnd: searchForm.value.feeDateEnd, feeDateEnd: searchForm.value.feeDateEnd,
}, },
@@ -122,21 +105,13 @@ async function handleDelete(id: number) {
<template> <template>
<div class="rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm dark:border-[hsl(222.34deg_10.43%_16%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]"> <div class="rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm dark:border-[hsl(222.34deg_10.43%_16%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]">
<!-- 标题栏 + 筛选区(单行) --> <!-- 标题栏 + 筛选区 -->
<div class="flex items-center justify-between gap-3 border-b border-slate-100 px-6 py-3 dark:border-[hsl(222.34deg_10.43%_16%)]"> <div class="flex items-center justify-between gap-3 border-b border-slate-100 px-6 py-3 dark:border-[hsl(222.34deg_10.43%_16%)]">
<h3 class="flex shrink-0 items-center gap-2 text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]"> <h3 class="flex shrink-0 items-center gap-2 text-base font-semibold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
<CoinsIcon class="h-4 w-4" /> <CoinsIcon class="h-4 w-4" />
<span>推广费</span> <span>推广费</span>
</h3> </h3>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<Select
v-model:value="searchForm.platformId"
placeholder="平台"
class="!w-28"
allow-clear
:options="platformList"
@change="() => gridReloadRef?.()"
/>
<DatePicker <DatePicker
v-model:value="searchForm.feeDateStart" v-model:value="searchForm.feeDateStart"
placeholder="开始日期" placeholder="开始日期"