Blame view

src/views/demo/system/password/pwd.data.ts 1007 Bytes
Vben authored
1
2
3
import { FormSchema } from '/@/components/Form';

export const formSchema: FormSchema[] = [
sanmu authored
4
5
6
7
8
9
  // {
  //   field: 'passwordOld',
  //   label: '当前密码',
  //   component: 'InputPassword',
  //   required: true,
  // },
Vben authored
10
  {
sanmu authored
11
    field: 'password',
Vben authored
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
    label: '新密码',
    component: 'StrengthMeter',
    componentProps: {
      placeholder: '新密码',
    },
    rules: [
      {
        required: true,
        message: '请输入新密码',
      },
    ],
  },
  {
    field: 'confirmPassword',
    label: '确认密码',
    component: 'InputPassword',

    dynamicRules: ({ values }) => {
      return [
        {
          required: true,
          validator: (_, value) => {
            if (!value) {
35
              return Promise.reject('密码不能为空');
Vben authored
36
            }
sanmu authored
37
            if (value !== values.password) {
Vben authored
38
39
40
41
42
43
44
45
46
              return Promise.reject('两次输入的密码不一致!');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
];