feat:【antd】【ele】【member 会员】level 迁移 antd
This commit is contained in:
@@ -5,31 +5,39 @@ import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'name',
|
||||
label: '等级名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入等级名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
fieldName: 'level',
|
||||
label: '等级',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
min: 0,
|
||||
precision: 0,
|
||||
placeholder: '请输入等级',
|
||||
controlsPosition: 'right',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'experience',
|
||||
@@ -38,7 +46,10 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
componentProps: {
|
||||
min: 0,
|
||||
precision: 0,
|
||||
placeholder: '请输入升级经验',
|
||||
controlsPosition: 'right',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'discountPercent',
|
||||
@@ -48,17 +59,20 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||
min: 0,
|
||||
max: 100,
|
||||
precision: 0,
|
||||
placeholder: '请输入享受折扣',
|
||||
controlsPosition: 'right',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'ImageUpload',
|
||||
fieldName: 'icon',
|
||||
label: '等级图标',
|
||||
component: 'ImageUpload',
|
||||
},
|
||||
{
|
||||
component: 'ImageUpload',
|
||||
fieldName: 'backgroundUrl',
|
||||
label: '等级背景图',
|
||||
label: '背景图',
|
||||
component: 'ImageUpload',
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
@@ -81,16 +95,30 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||
fieldName: 'name',
|
||||
label: '等级名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入等级名称',
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择状态',
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -99,11 +127,13 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'id',
|
||||
title: '编号',
|
||||
title: '等级编号',
|
||||
minWidth: 80,
|
||||
},
|
||||
{
|
||||
field: 'icon',
|
||||
title: '等级图标',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellImage',
|
||||
},
|
||||
@@ -111,6 +141,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'backgroundUrl',
|
||||
title: '等级背景图',
|
||||
minWidth: 120,
|
||||
cellRender: {
|
||||
name: 'CellImage',
|
||||
},
|
||||
@@ -118,22 +149,27 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'name',
|
||||
title: '等级名称',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'level',
|
||||
title: '等级',
|
||||
minWidth: 80,
|
||||
},
|
||||
{
|
||||
field: 'experience',
|
||||
title: '升级经验',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'discountPercent',
|
||||
title: '享受折扣(%)',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
minWidth: 80,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.COMMON_STATUS },
|
||||
@@ -142,11 +178,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 130,
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MemberLevelApi } from '#/api/member/level';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
@@ -19,7 +19,7 @@ const [FormModal, formModalApi] = useVbenModal({
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function onRefresh() {
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
@@ -41,10 +41,8 @@ async function handleDelete(row: MemberLevelApi.Level) {
|
||||
});
|
||||
try {
|
||||
await deleteLevel(row.id as number);
|
||||
message.success({
|
||||
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
|
||||
});
|
||||
onRefresh();
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
@@ -63,7 +61,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async (_params, formValues) => {
|
||||
query: async (_, formValues) => {
|
||||
return await getLevelList({
|
||||
...formValues,
|
||||
});
|
||||
@@ -72,6 +70,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
@@ -83,7 +82,12 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="onRefresh" />
|
||||
<DocAlert
|
||||
title="会员等级、积分、签到"
|
||||
url="https://doc.iocoder.cn/member/level/"
|
||||
/>
|
||||
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid table-title="等级列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
|
||||
@@ -26,8 +26,8 @@ const [Form, formApi] = useVbenForm({
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
formItemClass: 'col-span-1',
|
||||
labelWidth: 110,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useFormSchema(),
|
||||
@@ -76,7 +76,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal class="w-2/5" :title="getTitle">
|
||||
<Modal :title="getTitle" class="w-1/2">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user