import { getAllRoleList, isAccountExist } from '@/api/demo/system'; import { BasicColumn, FormSchema } from '@/components/Table'; /** * transform mock data * { * 0: '华东分部', * '0-0': '华东分部-研发部' * '0-1': '华东分部-市场部', * ... * } */ export const deptMap = (() => { const pDept = ['华东分部', '华南分部', '西北分部']; const cDept = ['研发部', '市场部', '商务部', '财务部']; return pDept.reduce((map, p, pIdx) => { map[pIdx] = p; cDept.forEach((c, cIndex) => (map[`${pIdx}-${cIndex}`] = `${p}-${c}`)); return map; }, {}); })(); export const columns: BasicColumn[] = [ { title: '用户名', dataIndex: 'account', width: 120, }, { title: '昵称', dataIndex: 'name', width: 120, }, { title: '创建时间', dataIndex: 'createTime', width: 180, }, // { // title: '所属部门', // dataIndex: 'organizations', // // customRender: ({ value }) => { // // return deptMap[value]; // // }, // }, ]; export const searchFormSchema: FormSchema[] = [ { field: 'key', label: '关键字', component: 'Input', colProps: { span: 8 }, }, ]; export const accountFormSchema: FormSchema[] = [ { field: 'id', label: '姓名', component: 'Input', required: true, ifShow:false }, { field: 'account', label: '账号', component: 'Input', // helpMessage: ['本字段演示异步验证', '不能输入带有admin的账号'], rules: [ { required: true, message: '请输入账号', }, // { // trigger: 'blur', // validator(_, value) { // return new Promise((resolve, reject) => { // if (!value) return resolve(); // isAccountExist(value) // .then(resolve) // .catch((err) => { // reject(err.message || '验证失败'); // }); // }); // }, // }, ], }, { field: 'name', label: '姓名', component: 'Input', required: true, }, { field: 'password', label: '密码', component: 'InputPassword', }, { field: 'status', label: '状态', component: 'RadioButtonGroup', defaultValue: 0, componentProps: { options: [ { label: '启用', value: 0}, { label: '停用', value: 1 }, ], }, }, ];