mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 11:49:20 +08:00
feat: 新增电商平台管理模块(ec_platform),店铺表platform改为外键
后端: - 新增 ec_platform 表 + 10条初始平台数据(淘宝/京东/拼多多/抖音等) - ec_shop 表 platform varchar → platform_id bigint 外键 - 新增 Platform 模块:PO/VO/DTO/Mapper/Service/Controller - 修复 ShopServiceImpl/CompanyOverviewServiceImpl/ExportServiceImpl 中 platform 字段引用 前端: - 新增平台管理页面(列表 + 表单弹窗) - 路由注册 /data/platform - 店铺管理:平台选择改为下拉,字段 platform 字符串 → platformId 外键 - 同步更新 ShopVO/ShopDTO 类型定义 数据库: - V20260422__add_ec_platform.sql 迁移文件
This commit is contained in:
+24
-12
@@ -9,6 +9,7 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
import { Button, Form, Input, message, Select } from 'ant-design-vue';
|
||||
|
||||
import { createShopApi, updateShopApi } from '#/api/ecommerce/shop';
|
||||
import { getActivePlatformsApi } from '#/api/ecommerce/platform';
|
||||
import { uploadFileToOss } from '#/utils/oss-upload';
|
||||
|
||||
interface Emits {
|
||||
@@ -46,17 +47,26 @@ const imageLoadError = ref(false); // 图片加载错误状态
|
||||
// 表单数据
|
||||
const formData = ref({
|
||||
name: '',
|
||||
platform: '',
|
||||
platformId: undefined as number | undefined,
|
||||
logoImageId: undefined as number | undefined,
|
||||
});
|
||||
|
||||
// 平台选项
|
||||
const platformOptions = [
|
||||
{ label: '淘宝', value: '淘宝' },
|
||||
{ label: '京东', value: '京东' },
|
||||
{ label: '拼多多', value: '拼多多' },
|
||||
{ label: '天猫', value: '天猫' },
|
||||
];
|
||||
// 平台选项(动态加载)
|
||||
const platformOptions = ref<{ label: string; value: number }[]>([]);
|
||||
|
||||
|
||||
// 加载平台列表
|
||||
async function fetchPlatformOptions() {
|
||||
try {
|
||||
const data = await getActivePlatformsApi();
|
||||
platformOptions.value = data.map((p: any) => ({
|
||||
label: p.platformName,
|
||||
value: p.id,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('获取平台列表失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 模态框标题
|
||||
const modalTitle = computed(() => (isEdit.value ? '编辑店铺' : '添加店铺'));
|
||||
@@ -75,7 +85,7 @@ function initFormData() {
|
||||
// 编辑模式
|
||||
formData.value = {
|
||||
name: currentShopData.value.name || '',
|
||||
platform: currentShopData.value.platform || '',
|
||||
platformId: currentShopData.value.platformId,
|
||||
logoImageId: undefined,
|
||||
};
|
||||
|
||||
@@ -85,7 +95,7 @@ function initFormData() {
|
||||
// 创建模式 - 如果有传入的shopData,则使用它来初始化表单
|
||||
formData.value = {
|
||||
name: currentShopData.value?.name || '',
|
||||
platform: currentShopData.value?.platform || '',
|
||||
platformId: currentShopData.value?.platformId,
|
||||
logoImageId: undefined,
|
||||
};
|
||||
originalLogoUrl.value = currentShopData.value?.logo || '';
|
||||
@@ -102,6 +112,8 @@ function resetForm() {
|
||||
newLogoFile.value = null;
|
||||
originalLogoUrl.value = '';
|
||||
imageLoadError.value = false;
|
||||
// 加载平台选项
|
||||
fetchPlatformOptions();
|
||||
}
|
||||
|
||||
// 处理提交
|
||||
@@ -366,9 +378,9 @@ onUnmounted(() => {
|
||||
<Input v-model:value="formData.name" placeholder="请输入店铺名称" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="平台" name="platform">
|
||||
<Form.Item label="平台" name="platformId">
|
||||
<Select
|
||||
v-model:value="formData.platform"
|
||||
v-model:value="formData.platformId"
|
||||
placeholder="请选择平台"
|
||||
:options="platformOptions"
|
||||
allow-clear
|
||||
|
||||
@@ -30,18 +30,13 @@ const shopFormModalRef = ref();
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
name: '',
|
||||
platform: undefined as string | undefined,
|
||||
platformId: undefined as number | undefined,
|
||||
});
|
||||
|
||||
// 表单数据(已移至ShopFormModal组件)
|
||||
|
||||
// 平台选项
|
||||
const platformOptions = [
|
||||
{ label: '淘宝', value: '淘宝' },
|
||||
{ label: '京东', value: '京东' },
|
||||
{ label: '拼多多', value: '拼多多' },
|
||||
{ label: '天猫', value: '天猫' },
|
||||
];
|
||||
// 平台选项(动态加载)
|
||||
const platformOptions = ref<{ label: string; value: number }[]>([]);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
@@ -65,10 +60,10 @@ const gridOptions: VxeGridProps<any> = {
|
||||
slots: { default: 'name' },
|
||||
},
|
||||
{
|
||||
field: 'platform',
|
||||
field: 'platformName',
|
||||
title: '平台',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
minWidth: 120,
|
||||
showOverflow: true,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
@@ -133,7 +128,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
name: searchForm.value.name || undefined,
|
||||
platform: searchForm.value.platform,
|
||||
platformId: searchForm.value.platformId,
|
||||
},
|
||||
};
|
||||
const data = await getShopPageApi(params);
|
||||
@@ -175,9 +170,12 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择平台',
|
||||
options: platformOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.platformId = val;
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'platform',
|
||||
fieldName: 'platformId',
|
||||
label: '平台',
|
||||
},
|
||||
],
|
||||
@@ -195,6 +193,20 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
|
||||
// 加载平台选项
|
||||
async function fetchPlatformOptions() {
|
||||
try {
|
||||
const data = await getActivePlatformsApi();
|
||||
platformOptions.value = data.map((p: any) => ({
|
||||
label: p.platformName,
|
||||
value: p.id,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('获取平台列表失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
if (gridApi) {
|
||||
|
||||
Reference in New Issue
Block a user