1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
| import type { VbenFormSchema } from '#/adapter/form';
| import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
| import { CommonStatusEnum, DICT_TYPE } from '..\..\..\..\packages\constants\src';
| import { getDictOptions } from '..\..\..\..\packages\effects\hooks\src';
|
| import { z } from '#/adapter/form';
|
| /** 新增/修改的表单 */
| export function useFormSchema(): VbenFormSchema[] {
| return [
| {
| component: 'Input',
| fieldName: 'id',
| dependencies: {
| triggerFields: [''],
| show: () => false,
| },
| },
| {
| component: 'InputNumber',
| fieldName: 'day',
| label: '签到天数',
| help: '只允许设置 1-7,默认签到 7 天为一个周期',
| componentProps: {
| class: '!w-full',
| min: 1,
| max: 7,
| precision: 0,
| placeholder: '请输入签到天数',
| },
| rules: z.number().min(1).max(7, '签到天数必须在 1-7 之间'),
| },
| {
| component: 'InputNumber',
| fieldName: 'point',
| label: '获得积分',
| componentProps: {
| class: '!w-full',
| min: 0,
| precision: 0,
| placeholder: '请输入获得积分',
| },
| rules: z.number().min(0, '获得积分不能小于 0'),
| },
| {
| component: 'InputNumber',
| fieldName: 'experience',
| label: '奖励经验',
| componentProps: {
| class: '!w-full',
| min: 0,
| precision: 0,
| placeholder: '请输入奖励经验',
| },
| rules: z.number().min(0, '奖励经验不能小于 0'),
| },
| {
| fieldName: 'status',
| label: '状态',
| component: 'RadioGroup',
| componentProps: {
| options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
| buttonStyle: 'solid',
| optionType: 'button',
| },
| rules: z.number().default(CommonStatusEnum.ENABLE),
| },
| ];
| }
|
| /** 列表的字段 */
| export function useGridColumns(): VxeTableGridOptions['columns'] {
| return [
| {
| 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 },
| },
| },
| {
| title: '操作',
| width: 150,
| fixed: 'right',
| slots: { default: 'actions' },
| },
| ];
| }
|
|