account.data.ts 2.3 KB
Newer Older
1
import { getAllRoleList, isAccountExist } from '/@/api/demo/system';
V
Vben 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';

export const columns: BasicColumn[] = [
  {
    title: '用户名',
    dataIndex: 'account',
    width: 120,
  },
  {
    title: '昵称',
    dataIndex: 'nickname',
    width: 120,
  },
  {
    title: '邮箱',
    dataIndex: 'email',
19
    width: 120,
V
Vben 已提交
20 21
  },
  {
V
Vben 已提交
22 23
    title: '创建时间',
    dataIndex: 'createTime',
V
Vben 已提交
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
    width: 180,
  },
  {
    title: '角色',
    dataIndex: 'role',
    width: 200,
  },
  {
    title: '备注',
    dataIndex: 'remark',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'account',
    label: '用户名',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'nickname',
    label: '昵称',
    component: 'Input',
    colProps: { span: 8 },
  },
];

export const accountFormSchema: FormSchema[] = [
  {
    field: 'account',
    label: '用户名',
    component: 'Input',
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
    helpMessage: ['本字段演示异步验证', '不能输入带有admin的用户名'],
    rules: [
      {
        required: true,
        message: '请输入用户名',
      },
      {
        validator(_, value) {
          return new Promise((resolve, reject) => {
            isAccountExist(value)
              .then(() => resolve())
              .catch((err) => {
                reject(err.message || '验证失败');
              });
          });
        },
      },
    ],
V
Vben 已提交
75
  },
V
Vben 已提交
76 77 78 79 80
  {
    field: 'pwd',
    label: '密码',
    component: 'InputPassword',
    required: true,
81
    ifShow: false,
V
Vben 已提交
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
  },
  {
    label: '角色',
    field: 'role',
    component: 'ApiSelect',
    componentProps: {
      api: getAllRoleList,
      labelField: 'roleName',
      valueField: 'roleValue',
    },
    required: true,
  },
  {
    field: 'dept',
    label: '所属部门',
    component: 'TreeSelect',
    componentProps: {
99 100
      fieldNames: {
        label: 'deptName',
V
Vben 已提交
101 102 103 104 105 106 107
        key: 'id',
        value: 'id',
      },
      getPopupContainer: () => document.body,
    },
    required: true,
  },
V
Vben 已提交
108 109 110 111 112 113
  {
    field: 'nickname',
    label: '昵称',
    component: 'Input',
    required: true,
  },
V
Vben 已提交
114

V
Vben 已提交
115 116 117 118 119 120
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
    required: true,
  },
V
Vben 已提交
121

V
Vben 已提交
122 123 124 125 126 127
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
];