pwd.data.ts
1.75 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
import { FormSchema } from '/@/components/Form';
import { InputRegExp } from '/@/enums/regexpEnum';
export const formSchema: FormSchema[] = [
{
field: 'passwordOld',
label: '当前密码',
component: 'InputPassword',
componentProps: {
placeholder: '请输入当前密码',
},
required: true,
},
{
field: 'passwordNew',
label: '新密码',
component: 'InputPassword',
componentProps({ formModel, formActionType }) {
return {
placeholder: '请输入新密码',
onInput({ target }) {
const { value } = target;
const { confirmPassword } = formModel;
if (value === confirmPassword) {
formActionType.clearValidate('confirmPassword');
}
},
};
},
rules: [
{
required: true,
message: '请输入新密码',
},
],
},
{
field: 'confirmPassword',
label: '确认密码',
component: 'InputPassword',
componentProps: {
placeholder: '请输入确认密码',
},
dynamicRules: ({ values }) => {
return [
{
required: true,
validator: (_, value) => {
if (!value) {
return Promise.reject('密码不能为空');
}
if (value !== values.passwordNew) {
return Promise.reject('两次输入的密码不一致!');
}
const pwdRegex = new RegExp(InputRegExp.PASSWORD_INPUT);
if (!pwdRegex.test(value)) {
return Promise.reject(
'密码中必须包含大小写 字母、数字、特称字符,至少8个字符,最多30个字符'
);
}
return Promise.resolve();
},
},
];
},
},
];