feat:【antd】【ele】【member 会员】signin 迁移 ele

This commit is contained in:
YunaiV
2025-10-07 11:04:07 +08:00
parent 8d34744deb
commit 9e89cdbced
8 changed files with 57 additions and 38 deletions

View File

@@ -6,16 +6,6 @@ import { getDictOptions } from '@vben/hooks';
import { z } from '#/adapter/form'; import { z } from '#/adapter/form';
/** 奖励验证函数 */
const awardValidator = (value: number, formData: any, field: string) => {
const point = formData.point || 0;
const experience = formData.experience || 0;
if (point === 0 && experience === 0) {
return '奖励积分与奖励经验至少配置一个';
}
return true;
};
/** 新增/修改的表单 */ /** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] { export function useFormSchema(): VbenFormSchema[] {
return [ return [
@@ -38,7 +28,7 @@ export function useFormSchema(): VbenFormSchema[] {
precision: 0, precision: 0,
placeholder: '请输入签到天数', placeholder: '请输入签到天数',
}, },
rules: z.number().min(1).max(7, '签到天数必须在1-7之间'), rules: z.number().min(1).max(7, '签到天数必须在 1-7 之间'),
}, },
{ {
component: 'InputNumber', component: 'InputNumber',
@@ -49,9 +39,7 @@ export function useFormSchema(): VbenFormSchema[] {
precision: 0, precision: 0,
placeholder: '请输入获得积分', placeholder: '请输入获得积分',
}, },
rules: z.number().min(0, '获得积分不能小于0').refine(awardValidator, { rules: z.number().min(0, '获得积分不能小于 0'),
message: '奖励积分与奖励经验至少配置一个',
}),
}, },
{ {
component: 'InputNumber', component: 'InputNumber',
@@ -62,9 +50,7 @@ export function useFormSchema(): VbenFormSchema[] {
precision: 0, precision: 0,
placeholder: '请输入奖励经验', placeholder: '请输入奖励经验',
}, },
rules: z.number().min(0, '奖励经验不能小于0').refine(awardValidator, { rules: z.number().min(0, '奖励经验不能小于 0'),
message: '奖励积分与奖励经验至少配置一个',
}),
}, },
{ {
fieldName: 'status', fieldName: 'status',

View File

@@ -44,9 +44,7 @@ async function handleDelete(row: MemberSignInConfigApi.SignInConfig) {
}); });
try { try {
await deleteSignInConfig(row.id as number); await deleteSignInConfig(row.id as number);
message.success({ message.success($t('ui.actionMessage.deleteSuccess'));
content: $t('ui.actionMessage.deleteSuccess'),
});
handleRefresh(); handleRefresh();
} finally { } finally {
hideLoading(); hideLoading();

View File

@@ -34,7 +34,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'RangePicker', component: 'RangePicker',
componentProps: { componentProps: {
...getRangePickerDefaultProps(), ...getRangePickerDefaultProps(),
placeholder: ['开始日期', '结束日期'], allowClear: true,
}, },
}, },
]; ];

View File

@@ -26,7 +26,11 @@ export function useFormSchema(): VbenFormSchema[] {
min: 1, min: 1,
max: 7, max: 7,
precision: 0, precision: 0,
placeholder: '请输入签到天数',
controlsPosition: 'right',
class: '!w-full',
}, },
rules: z.number().min(1).max(7, '签到天数必须在 1-7 之间'),
}, },
{ {
component: 'InputNumber', component: 'InputNumber',
@@ -35,7 +39,11 @@ export function useFormSchema(): VbenFormSchema[] {
componentProps: { componentProps: {
min: 0, min: 0,
precision: 0, precision: 0,
placeholder: '请输入获得积分',
controlsPosition: 'right',
class: '!w-full',
}, },
rules: z.number().min(0, '获得积分不能小于 0'),
}, },
{ {
component: 'InputNumber', component: 'InputNumber',
@@ -44,7 +52,11 @@ export function useFormSchema(): VbenFormSchema[] {
componentProps: { componentProps: {
min: 0, min: 0,
precision: 0, precision: 0,
placeholder: '请输入奖励经验',
controlsPosition: 'right',
class: '!w-full',
}, },
rules: z.number().min(0, '奖励经验不能小于 0'),
}, },
{ {
fieldName: 'status', fieldName: 'status',
@@ -63,39 +75,34 @@ export function useFormSchema(): VbenFormSchema[] {
/** 列表的字段 */ /** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] { export function useGridColumns(): VxeTableGridOptions['columns'] {
return [ return [
{
field: 'id',
title: '编号',
},
{ {
field: 'day', field: 'day',
title: '签到天数', title: '签到天数',
minWidth: 120,
formatter: ({ cellValue }) => ['第', cellValue, '天'].join(' '), formatter: ({ cellValue }) => ['第', cellValue, '天'].join(' '),
}, },
{ {
field: 'point', field: 'point',
title: '获得积分', title: '获得积分',
minWidth: 120,
}, },
{ {
field: 'experience', field: 'experience',
title: '奖励经验', title: '奖励经验',
minWidth: 120,
}, },
{ {
field: 'status', field: 'status',
title: '状态', title: '状态',
minWidth: 100,
cellRender: { cellRender: {
name: 'CellDict', name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS }, props: { type: DICT_TYPE.COMMON_STATUS },
}, },
}, },
{
field: 'createTime',
title: '创建时间',
formatter: 'formatDateTime',
},
{ {
title: '操作', title: '操作',
width: 130, width: 150,
fixed: 'right', fixed: 'right',
slots: { default: 'actions' }, slots: { default: 'actions' },
}, },

View File

@@ -2,7 +2,7 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MemberSignInConfigApi } from '#/api/member/signin/config'; import type { MemberSignInConfigApi } from '#/api/member/signin/config';
import { Page, useVbenModal } from '@vben/common-ui'; import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { ElLoading, ElMessage } from 'element-plus'; import { ElLoading, ElMessage } from 'element-plus';
@@ -22,7 +22,7 @@ const [FormModal, formModalApi] = useVbenModal({
}); });
/** 刷新表格 */ /** 刷新表格 */
function onRefresh() { function handleRefresh() {
gridApi.query(); gridApi.query();
} }
@@ -44,7 +44,7 @@ async function handleDelete(row: MemberSignInConfigApi.SignInConfig) {
try { try {
await deleteSignInConfig(row.id as number); await deleteSignInConfig(row.id as number);
ElMessage.success($t('ui.actionMessage.deleteSuccess')); ElMessage.success($t('ui.actionMessage.deleteSuccess'));
onRefresh(); handleRefresh();
} finally { } finally {
loadingInstance.close(); loadingInstance.close();
} }
@@ -67,6 +67,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,
@@ -78,7 +79,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
<template> <template>
<Page auto-content-height> <Page auto-content-height>
<FormModal @success="onRefresh" /> <template #doc>
<DocAlert
title="会员等级、积分、签到"
url="https://doc.iocoder.cn/member/level/"
/>
</template>
<FormModal @success="handleRefresh" />
<Grid table-title="签到配置列表"> <Grid table-title="签到配置列表">
<template #toolbar-tools> <template #toolbar-tools>
<TableAction <TableAction
@@ -111,7 +119,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
icon: ACTION_ICON.DELETE, icon: ACTION_ICON.DELETE,
auth: ['point:sign-in-config:delete'], auth: ['point:sign-in-config:delete'],
popConfirm: { popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.name]), title: $t('ui.actionMessage.deleteConfirm', [row.day]),
confirm: handleDelete.bind(null, row), confirm: handleDelete.bind(null, row),
}, },
}, },

View File

@@ -31,7 +31,7 @@ const [Form, formApi] = useVbenForm({
class: 'w-full', class: 'w-full',
}, },
formItemClass: 'col-span-2', formItemClass: 'col-span-2',
labelWidth: 80, labelWidth: 90,
}, },
layout: 'horizontal', layout: 'horizontal',
schema: useFormSchema(), schema: useFormSchema(),

View File

@@ -14,11 +14,19 @@ export function useGridFormSchema(): VbenFormSchema[] {
fieldName: 'nickname', fieldName: 'nickname',
label: '签到用户', label: '签到用户',
component: 'Input', component: 'Input',
componentProps: {
placeholder: '请输入签到用户',
clearable: true,
},
}, },
{ {
fieldName: 'day', fieldName: 'day',
label: '签到天数', label: '签到天数',
component: 'Input', component: 'Input',
componentProps: {
placeholder: '请输入签到天数',
clearable: true,
},
}, },
{ {
fieldName: 'createTime', fieldName: 'createTime',
@@ -38,19 +46,23 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'id', field: 'id',
title: '编号', title: '编号',
minWidth: 100,
}, },
{ {
field: 'nickname', field: 'nickname',
title: '签到用户', title: '签到用户',
minWidth: 150,
}, },
{ {
field: 'day', field: 'day',
title: '签到天数', title: '签到天数',
minWidth: 120,
formatter: ({ cellValue }) => ['第', cellValue, '天'].join(' '), formatter: ({ cellValue }) => ['第', cellValue, '天'].join(' '),
}, },
{ {
field: 'point', field: 'point',
title: '获得积分', title: '获得积分',
minWidth: 120,
slots: { slots: {
default: ({ row }) => { default: ({ row }) => {
return h( return h(
@@ -67,6 +79,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'createTime', field: 'createTime',
title: '签到时间', title: '签到时间',
minWidth: 180,
formatter: 'formatDateTime', formatter: 'formatDateTime',
}, },
]; ];

View File

@@ -2,7 +2,7 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MemberSignInRecordApi } from '#/api/member/signin/record'; import type { MemberSignInRecordApi } from '#/api/member/signin/record';
import { Page } from '@vben/common-ui'; import { DocAlert, Page } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table'; import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getSignInRecordPage } from '#/api/member/signin/record'; import { getSignInRecordPage } from '#/api/member/signin/record';
@@ -30,6 +30,7 @@ const [Grid] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,
@@ -41,6 +42,12 @@ const [Grid] = useVbenVxeGrid({
<template> <template>
<Page auto-content-height> <Page auto-content-height>
<template #doc>
<DocAlert
title="会员等级、积分、签到"
url="https://doc.iocoder.cn/member/level/"
/>
</template>
<Grid table-title="签到记录列表" /> <Grid table-title="签到记录列表" />
</Page> </Page>
</template> </template>