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';
/** 奖励验证函数 */
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[] {
return [
@@ -38,7 +28,7 @@ export function useFormSchema(): VbenFormSchema[] {
precision: 0,
placeholder: '请输入签到天数',
},
rules: z.number().min(1).max(7, '签到天数必须在1-7之间'),
rules: z.number().min(1).max(7, '签到天数必须在 1-7 之间'),
},
{
component: 'InputNumber',
@@ -49,9 +39,7 @@ export function useFormSchema(): VbenFormSchema[] {
precision: 0,
placeholder: '请输入获得积分',
},
rules: z.number().min(0, '获得积分不能小于0').refine(awardValidator, {
message: '奖励积分与奖励经验至少配置一个',
}),
rules: z.number().min(0, '获得积分不能小于 0'),
},
{
component: 'InputNumber',
@@ -62,9 +50,7 @@ export function useFormSchema(): VbenFormSchema[] {
precision: 0,
placeholder: '请输入奖励经验',
},
rules: z.number().min(0, '奖励经验不能小于0').refine(awardValidator, {
message: '奖励积分与奖励经验至少配置一个',
}),
rules: z.number().min(0, '奖励经验不能小于 0'),
},
{
fieldName: 'status',

View File

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

View File

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

View File

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

View File

@@ -2,7 +2,7 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
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';
@@ -22,7 +22,7 @@ const [FormModal, formModalApi] = useVbenModal({
});
/** 刷新表格 */
function onRefresh() {
function handleRefresh() {
gridApi.query();
}
@@ -44,7 +44,7 @@ async function handleDelete(row: MemberSignInConfigApi.SignInConfig) {
try {
await deleteSignInConfig(row.id as number);
ElMessage.success($t('ui.actionMessage.deleteSuccess'));
onRefresh();
handleRefresh();
} finally {
loadingInstance.close();
}
@@ -67,6 +67,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
@@ -78,7 +79,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
<template>
<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="签到配置列表">
<template #toolbar-tools>
<TableAction
@@ -111,7 +119,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
icon: ACTION_ICON.DELETE,
auth: ['point:sign-in-config:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
title: $t('ui.actionMessage.deleteConfirm', [row.day]),
confirm: handleDelete.bind(null, row),
},
},

View File

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

View File

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

View File

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