Repository navigation
Expand file tree
/
Copy pathCreateUser.ts
More file actions
240 lines (239 loc) · 6.18 KB
/
Copy pathCreateUser.ts
File metadata and controls
240 lines (239 loc) · 6.18 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import { FormConfig } from '@/types';
export const CreateUser: FormConfig = {
title: '创建用户',
description: '创建用户',
rowData: [
[
{
name: 'name',
className: 'w-1/2 shrink-0 mb-6',
properties: {
type: 'text',
label: '用户名',
placeholder: '请输入用户名'
},
defaultValue: '',
rules: {
required: '请输入用户名',
minLength: { value: 5, message: '用户名长度至少5位' },
maxLength: { value: 20, message: '用户名长度最多20位' },
pattern: { value: /^[a-zA-Z0-9_]/, message: '用户名格式不正确' }
}
},
{
name: 'avatar',
className: 'w-1/2 shrink-0 h-20',
properties: {
type: 'Avatar'
},
defaultValue: '',
rules: {
required: '头像地址不能为空'
}
},
{
name: 'role',
className: 'w-1/2 shrink-0',
defaultValue: 1,
properties: {
type: 'select',
label: '用户角色',
options: [
{ value: 0, title: '管理员' },
{ value: 1, title: '用户' }
]
}
}
],
[
{
name: 'password',
className: 'w-full',
properties: {
type: 'password',
label: '密码',
placeholder: '请输入密码'
},
defaultValue: '',
rules: {
required: '请输入密码',
minLength: { value: 6, message: '密码长度至少6位' },
maxLength: { value: 30, message: '密码长度最多30位' },
pattern: {
value: /^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[._~!@#$^&*])[A-Za-z0-9._~!@#$^&*]{6,30}$/,
message: '密码中必须包含字母、数字和特殊字符'
}
}
}
],
[
{
name: 'phone',
className: 'w-full',
properties: {
type: 'text',
label: '手机号',
placeholder: '请输入手机号'
},
defaultValue: '',
rules: {
required: '请输入手机号',
pattern: { value: /^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$/, message: '手机号格式不正确' }
}
}
],
[
{
name: 'email',
className: 'w-full',
properties: {
type: 'text',
label: '邮箱地址',
placeholder: '请输入邮箱地址'
},
defaultValue: '',
rules: {
required: '请输入邮箱地址',
pattern: { value: /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/, message: '邮箱地址格式不正确' }
}
}
],
[
{
name: 'cancel',
component: 'CancelButton',
className: 'w-1/2 px-2',
properties: {
buttonText: '取消'
}
},
{
name: 'submit-btn',
component: 'SubmitButton',
className: 'w-1/2 px-2',
properties: {
buttonText: ['创建中...', '创建']
}
}
]
]
};
export const UpdateUser: FormConfig = {
title: '更新用户',
description: '更新用户',
rowData: [
[
{
name: 'name',
className: 'w-1/2 shrink-0 mb-6',
properties: {
type: 'text',
label: '用户名',
placeholder: '请输入用户名'
},
defaultValue: '',
rules: {
required: '请输入用户名',
minLength: { value: 5, message: '用户名长度至少5位' },
maxLength: { value: 20, message: '用户名长度最多20位' },
pattern: { value: /^[a-zA-Z0-9_]/, message: '用户名格式不正确' }
}
},
{
name: 'avatar',
className: 'w-1/2 shrink-0 h-20',
properties: {
type: 'Avatar'
},
defaultValue: '',
rules: {
required: '头像地址不能为空'
}
},
{
name: 'role',
className: 'w-1/2 shrink-0',
defaultValue: 1,
properties: {
type: 'select',
label: '用户角色',
options: [
{ value: 0, title: '管理员' },
{ value: 1, title: '用户' }
]
}
}
],
[
{
name: 'password',
className: 'w-full',
properties: {
type: 'password',
label: '密码',
placeholder: '不输入内容则保持旧密码使用'
},
defaultValue: '',
rules: {
minLength: { value: 6, message: '密码长度至少6位' },
maxLength: { value: 30, message: '密码长度最多30位' },
pattern: {
value: /^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[._~!@#$^&*])[A-Za-z0-9._~!@#$^&*]{6,30}$/,
message: '密码中必须包含字母、数字和特殊字符'
}
}
}
],
[
{
name: 'phone',
className: 'w-full',
properties: {
type: 'text',
label: '手机号',
placeholder: '请输入手机号'
},
defaultValue: '',
rules: {
required: '请输入手机号',
pattern: { value: /^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0,5-9]))\d{8}$/, message: '手机号格式不正确' }
}
}
],
[
{
name: 'email',
className: 'w-full',
properties: {
type: 'text',
label: '邮箱地址',
placeholder: '请输入邮箱地址'
},
defaultValue: '',
rules: {
required: '请输入邮箱地址',
pattern: { value: /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/, message: '邮箱地址格式不正确' }
}
}
],
[
{
name: 'cancel',
component: 'CancelButton',
className: 'w-1/2 px-2',
properties: {
buttonText: '取消'
}
},
{
name: 'submit-btn',
component: 'SubmitButton',
className: 'w-1/2 px-2',
properties: {
buttonText: ['更新中...', '更新']
}
}
]
]
};
export default CreateUser;