feat: 新增商城模块,新增会员中心的会员详情的订单管理,售后管理,收藏记录,优惠券,推广用户的展示

This commit is contained in:
吃货
2025-07-06 08:49:22 +08:00
parent 280e79c55f
commit 4cc5d8bf92
115 changed files with 14819 additions and 206 deletions

View File

@@ -0,0 +1,262 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { formatDate } from '@vben/utils';
import { DICT_TYPE, getDictOptions } from '#/utils';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'id',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'name',
label: '活动名称',
component: 'Input',
componentProps: {
placeholder: '请输入活动名称',
},
rules: 'required',
},
{
fieldName: 'startTime',
label: '开始时间',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
placeholder: '请选择开始时间',
},
rules: 'required',
},
{
fieldName: 'endTime',
label: '结束时间',
component: 'DatePicker',
componentProps: {
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
placeholder: '请选择结束时间',
},
rules: 'required',
},
{
fieldName: 'bargainFirstPrice',
label: '砍价起始价格(元)',
component: 'InputNumber',
componentProps: {
min: 0,
precision: 2,
step: 0.01,
placeholder: '请输入砍价起始价格',
},
rules: 'required',
},
{
fieldName: 'bargainMinPrice',
label: '砍价底价(元)',
component: 'InputNumber',
componentProps: {
min: 0,
precision: 2,
step: 0.01,
placeholder: '请输入砍价底价',
},
rules: 'required',
},
{
fieldName: 'stock',
label: '活动库存',
component: 'InputNumber',
componentProps: {
min: 1,
placeholder: '请输入活动库存',
},
rules: 'required',
},
{
fieldName: 'helpMaxCount',
label: '助力人数',
component: 'InputNumber',
componentProps: {
min: 1,
placeholder: '请输入助力人数',
},
rules: 'required',
},
{
fieldName: 'bargainCount',
label: '砍价次数',
component: 'InputNumber',
componentProps: {
min: 1,
placeholder: '请输入砍价次数',
},
rules: 'required',
},
{
fieldName: 'totalLimitCount',
label: '购买限制',
component: 'InputNumber',
componentProps: {
min: 1,
placeholder: '请输入购买限制',
},
rules: 'required',
},
{
fieldName: 'randomMinPrice',
label: '最小砍价金额(元)',
component: 'InputNumber',
componentProps: {
min: 0,
precision: 2,
step: 0.01,
placeholder: '请输入最小砍价金额',
},
},
{
fieldName: 'randomMaxPrice',
label: '最大砍价金额(元)',
component: 'InputNumber',
componentProps: {
min: 0,
precision: 2,
step: 0.01,
placeholder: '请输入最大砍价金额',
},
},
];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'name',
label: '活动名称',
component: 'Input',
componentProps: {
placeholder: '请输入活动名称',
clearable: true,
},
},
{
fieldName: 'status',
label: '活动状态',
component: 'Select',
componentProps: {
placeholder: '请选择活动状态',
clearable: true,
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
},
},
];
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
field: 'id',
title: '活动编号',
minWidth: 80,
},
{
field: 'name',
title: '活动名称',
minWidth: 140,
},
{
field: 'activityTime',
title: '活动时间',
minWidth: 210,
formatter: ({ row }) => {
if (!row.startTime || !row.endTime) return '';
return `${formatDate(row.startTime, 'YYYY-MM-DD')} ~ ${formatDate(row.endTime, 'YYYY-MM-DD')}`;
},
},
{
field: 'picUrl',
title: '商品图片',
minWidth: 80,
cellRender: {
name: 'CellImage',
props: {
height: 40,
width: 40,
},
},
},
{
field: 'spuName',
title: '商品标题',
minWidth: 300,
},
{
field: 'bargainFirstPrice',
title: '起始价格',
minWidth: 100,
formatter: 'formatAmount2',
},
{
field: 'bargainMinPrice',
title: '砍价底价',
minWidth: 100,
formatter: 'formatAmount2',
},
{
field: 'recordUserCount',
title: '总砍价人数',
minWidth: 100,
},
{
field: 'recordSuccessUserCount',
title: '成功砍价人数',
minWidth: 110,
},
{
field: 'helpUserCount',
title: '助力人数',
minWidth: 100,
},
{
field: 'status',
title: '活动状态',
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS },
},
},
{
field: 'stock',
title: '库存',
minWidth: 80,
},
{
field: 'totalStock',
title: '总库存',
minWidth: 80,
},
{
field: 'createTime',
title: '创建时间',
width: 180,
formatter: 'formatDateTime',
},
{
title: '操作',
width: 150,
fixed: 'right',
slots: { default: 'actions' },
},
];
}

View File

@@ -0,0 +1,173 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MallBargainActivityApi } from '#/api/mall/promotion/bargain/bargainActivity';
import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { ElLoading, ElMessage } from 'element-plus';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
closeBargainActivity,
deleteBargainActivity,
getBargainActivityPage,
} from '#/api/mall/promotion/bargain/bargainActivity';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
import Form from './modules/form.vue';
defineOptions({ name: 'PromotionBargainActivity' });
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
destroyOnClose: true,
});
/** 刷新表格 */
function onRefresh() {
gridApi.query();
}
/** 创建砍价活动 */
function handleCreate() {
formModalApi.setData(null).open();
}
/** 编辑砍价活动 */
function handleEdit(row: MallBargainActivityApi.BargainActivity) {
formModalApi.setData(row).open();
}
/** 关闭砍价活动 */
async function handleClose(row: MallBargainActivityApi.BargainActivity) {
try {
await confirm({
content: '确认关闭该砍价活动吗?',
});
} catch {
return;
}
const loadingInstance = ElLoading.service({
text: '确认关闭该砍价活动吗?',
fullscreen: true,
});
try {
await closeBargainActivity(row.id as number);
ElMessage.success('关闭成功');
onRefresh();
} finally {
loadingInstance.close();
}
}
/** 删除砍价活动 */
async function handleDelete(row: MallBargainActivityApi.BargainActivity) {
const loadingInstance = ElLoading.service({
text: $t('ui.actionMessage.deleting', [row.name]),
fullscreen: true,
});
try {
await deleteBargainActivity(row.id as number);
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.name]));
onRefresh();
} finally {
loadingInstance.close();
}
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
},
gridOptions: {
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getBargainActivityPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: { code: 'query' },
search: true,
},
} as VxeTableGridOptions<MallBargainActivityApi.BargainActivity>,
});
</script>
<template>
<Page auto-content-height>
<template #doc>
<DocAlert
title="【营销】砍价活动"
url="https://doc.iocoder.cn/mall/promotion-bargain/"
/>
</template>
<FormModal @success="onRefresh" />
<Grid table-title="砍价活动列表">
<template #toolbar-tools>
<TableAction
:actions="[
{
label: $t('ui.actionTitle.create', ['砍价活动']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['promotion:bargain-activity:create'],
onClick: handleCreate,
},
]"
/>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'primary',
link: true,
icon: ACTION_ICON.EDIT,
auth: ['promotion:bargain-activity:update'],
onClick: handleEdit.bind(null, row),
},
{
label: '关闭',
type: 'danger',
link: true,
icon: ACTION_ICON.DELETE,
auth: ['promotion:bargain-activity:close'],
ifShow: row.status === 0,
onClick: handleClose.bind(null, row),
},
{
label: $t('common.delete'),
type: 'danger',
link: true,
icon: ACTION_ICON.DELETE,
auth: ['promotion:bargain-activity:delete'],
ifShow: row.status !== 0,
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,92 @@
<script lang="ts" setup>
import type { MallBargainActivityApi } from '#/api/mall/promotion/bargain/bargainActivity';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { ElMessage } from 'element-plus';
import { useVbenForm } from '#/adapter/form';
import {
createBargainActivity,
getBargainActivity,
updateBargainActivity,
} from '#/api/mall/promotion/bargain/bargainActivity';
import { $t } from '#/locales';
import { useFormSchema } from '../data';
defineOptions({ name: 'PromotionBargainActivityForm' });
const emit = defineEmits(['success']);
const formData = ref<MallBargainActivityApi.BargainActivity>();
const getTitle = computed(() => {
return formData.value?.id
? $t('ui.actionTitle.edit', ['砍价活动'])
: $t('ui.actionTitle.create', ['砍价活动']);
});
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
class: 'w-full',
},
formItemClass: 'col-span-2',
labelWidth: 120,
},
layout: 'horizontal',
schema: useFormSchema(),
showDefaultActions: false,
});
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) {
return;
}
modalApi.lock();
// 提交表单
const data =
(await formApi.getValues()) as MallBargainActivityApi.BargainActivity;
try {
await (formData.value?.id
? updateBargainActivity(data)
: createBargainActivity(data));
// 关闭并提示
await modalApi.close();
emit('success');
ElMessage.success($t('ui.actionMessage.operationSuccess'));
} finally {
modalApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
return;
}
// 加载数据
const data = modalApi.getData<MallBargainActivityApi.BargainActivity>();
if (!data || !data.id) {
return;
}
modalApi.lock();
try {
formData.value = await getBargainActivity(data.id as number);
// 设置到 values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal class="w-2/5" :title="getTitle">
<Form class="mx-4" />
</Modal>
</template>

View File

@@ -0,0 +1,161 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'status',
label: '砍价状态',
component: 'Select',
componentProps: {
placeholder: '请选择砍价状态',
clearable: true,
options: getDictOptions(
DICT_TYPE.PROMOTION_BARGAIN_RECORD_STATUS,
'number',
),
},
},
{
fieldName: 'createTime',
label: '创建时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
clearable: true,
},
},
];
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
field: 'id',
title: '编号',
minWidth: 50,
},
{
field: 'avatar',
title: '用户头像',
minWidth: 120,
cellRender: {
name: 'CellImage',
props: {
height: 40,
width: 40,
shape: 'circle',
},
},
},
{
field: 'nickname',
title: '用户昵称',
minWidth: 100,
},
{
field: 'createTime',
title: '发起时间',
width: 180,
formatter: 'formatDateTime',
},
{
field: 'activity.name',
title: '砍价活动',
minWidth: 150,
},
{
field: 'activity.bargainMinPrice',
title: '最低价',
minWidth: 100,
formatter: 'formatAmount2',
},
{
field: 'bargainPrice',
title: '当前价',
minWidth: 100,
formatter: 'formatAmount2',
},
{
field: 'activity.helpMaxCount',
title: '总砍价次数',
minWidth: 100,
},
{
field: 'helpCount',
title: '剩余砍价次数',
minWidth: 100,
},
{
field: 'status',
title: '砍价状态',
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.PROMOTION_BARGAIN_RECORD_STATUS },
},
},
{
field: 'endTime',
title: '结束时间',
minWidth: 180,
formatter: 'formatDateTime',
},
{
field: 'orderId',
title: '订单编号',
minWidth: 100,
},
{
title: '操作',
width: 100,
fixed: 'right',
slots: { default: 'actions' },
},
];
}
/** 助力列表表格列配置 */
export function useHelpGridColumns(): VxeTableGridOptions['columns'] {
return [
{
field: 'userId',
title: '用户编号',
minWidth: 80,
},
{
field: 'avatar',
title: '用户头像',
minWidth: 80,
cellRender: {
name: 'CellImage',
props: {
height: 40,
width: 40,
shape: 'circle',
},
},
},
{
field: 'nickname',
title: '用户昵称',
minWidth: 100,
},
{
field: 'reducePrice',
title: '砍价金额',
minWidth: 100,
formatter: 'formatAmount2',
},
{
field: 'createTime',
title: '助力时间',
width: 180,
formatter: 'formatDateTime',
},
];
}

View File

@@ -0,0 +1,84 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MallBargainRecordApi } from '#/api/mall/promotion/bargain/bargainRecord';
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getBargainRecordPage } from '#/api/mall/promotion/bargain/bargainRecord';
import { useGridColumns, useGridFormSchema } from './data';
import HelpListModal from './modules/list.vue';
defineOptions({ name: 'PromotionBargainRecord' });
const [HelpListModalApi, helpListModalApi] = useVbenModal({
connectedComponent: HelpListModal,
destroyOnClose: true,
});
/** 查看助力详情 */
function handleViewHelp(row: MallBargainRecordApi.BargainRecord) {
helpListModalApi.setData({ recordId: row.id }).open();
}
const [Grid] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
},
gridOptions: {
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getBargainRecordPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: { code: 'query' },
search: true,
},
} as VxeTableGridOptions<MallBargainRecordApi.BargainRecord>,
});
</script>
<template>
<Page auto-content-height>
<template #doc>
<DocAlert
title="【营销】砍价活动"
url="https://doc.iocoder.cn/mall/promotion-bargain/"
/>
</template>
<HelpListModalApi />
<Grid table-title="砍价记录列表">
<template #actions="{ row }">
<TableAction
:actions="[
{
label: '助力',
type: 'primary',
link: true,
icon: ACTION_ICON.VIEW,
auth: ['promotion:bargain-help:query'],
onClick: handleViewHelp.bind(null, row),
},
]"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,67 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MallBargainHelpApi } from '#/api/mall/promotion/bargain/bargainHelp';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getBargainHelpPage } from '#/api/mall/promotion/bargain/bargainHelp';
import { useHelpGridColumns } from '../data';
/** 助力列表 */
defineOptions({ name: 'BargainRecordListDialog' });
const recordId = ref<number>();
const getTitle = computed(() => {
return `助力列表 - 记录${recordId.value || ''}`;
});
const [Modal, modalApi] = useVbenModal({
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
recordId.value = undefined;
return;
}
// 获取传入的记录ID
const data = modalApi.getData<{ recordId: number }>();
if (data?.recordId) {
recordId.value = data.recordId;
}
},
});
const [Grid] = useVbenVxeGrid({
gridOptions: {
columns: useHelpGridColumns(),
height: 600,
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }) => {
return await getBargainHelpPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
recordId: recordId.value,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: { code: 'query' },
},
} as VxeTableGridOptions<MallBargainHelpApi.BargainHelp>,
});
</script>
<template>
<Modal class="w-2/5" :title="getTitle">
<Grid class="mx-4" />
</Modal>
</template>