feat: 会员积分

This commit is contained in:
xingyu4j
2025-05-28 20:59:02 +08:00
parent 0b3b5799ea
commit d1ae887eba
9 changed files with 402 additions and 25 deletions

View File

@@ -0,0 +1,87 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { DICT_TYPE, getDictOptions } from '#/utils';
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'nickname',
label: '用户',
component: 'Input',
},
{
fieldName: 'bizType',
label: '业务类型',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.MEMBER_POINT_BIZ_TYPE, 'number'),
},
},
{
fieldName: 'title',
label: '积分标题',
component: 'Input',
},
{
fieldName: 'createDate',
label: '获得时间',
component: 'DatePicker',
componentProps: {
type: 'daterange',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')],
},
},
];
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
return [
{
field: 'id',
title: '编号',
},
{
field: 'createTime',
title: '获得时间',
formatter: 'formatDateTime',
},
{
field: 'nickname',
title: '用户',
},
{
field: 'point',
title: '获得积分',
slots: { default: 'point' },
},
{
field: 'totalPoint',
title: '总积分',
},
{
field: 'title',
title: '标题',
},
{
field: 'description',
title: '描述',
},
{
field: 'bizId',
title: '业务编码',
},
{
field: 'bizType',
title: '业务类型',
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.MEMBER_POINT_BIZ_TYPE },
},
},
];
}

View File

@@ -1,34 +1,54 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MemberPointRecordApi } from '#/api/member/point/record';
import { Page } from '@vben/common-ui';
import { Button } from 'ant-design-vue';
import { Tag } from 'ant-design-vue';
import { DocAlert } from '#/components/doc-alert';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getRecordPage } from '#/api/member/point/record';
import { useGridColumns, useGridFormSchema } from './data';
const [Grid] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
},
gridOptions: {
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getRecordPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: { code: 'query' },
search: true,
},
} as VxeTableGridOptions<MemberPointRecordApi.Record>,
});
</script>
<template>
<Page>
<DocAlert
title="会员等级、积分、签到"
url="https://doc.iocoder.cn/member/level/"
/>
<Button
danger
type="link"
target="_blank"
href="https://github.com/yudaocode/yudao-ui-admin-vue3"
>
该功能支持 Vue3 + element-plus 版本
</Button>
<br />
<Button
type="link"
target="_blank"
href="https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/point/record/index"
>
可参考
https://github.com/yudaocode/yudao-ui-admin-vue3/blob/master/src/views/member/point/record/index
代码pull request 贡献给我们
</Button>
<Page auto-content-height>
<Grid table-title="积分记录列表">
<template #point="{ row }">
<Tag :color="row.point > 0 ? '#108ee9' : '#f50'">
{{ row.point > 0 ? `+${row.point}` : row.point }}
</Tag>
</template>
</Grid>
</Page>
</template>