2024-01-13 10:56:48 +08:00
|
|
|
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: '昵称',
|
2024-02-07 09:24:07 +08:00
|
|
|
dataIndex: 'name',
|
2024-01-13 10:56:48 +08:00
|
|
|
width: 120,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '创建时间',
|
|
|
|
|
dataIndex: 'createTime',
|
|
|
|
|
width: 180,
|
|
|
|
|
},
|
2024-04-03 13:48:11 +08:00
|
|
|
// {
|
|
|
|
|
// title: '所属部门',
|
|
|
|
|
// dataIndex: 'organizations',
|
|
|
|
|
// // customRender: ({ value }) => {
|
|
|
|
|
// // return deptMap[value];
|
|
|
|
|
// // },
|
|
|
|
|
// },
|
2024-01-13 10:56:48 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const searchFormSchema: FormSchema[] = [
|
|
|
|
|
{
|
2024-04-03 13:48:11 +08:00
|
|
|
field: 'key',
|
|
|
|
|
label: '关键字',
|
2024-01-13 10:56:48 +08:00
|
|
|
component: 'Input',
|
|
|
|
|
colProps: { span: 8 },
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export const accountFormSchema: FormSchema[] = [
|
2024-02-07 09:24:07 +08:00
|
|
|
{
|
|
|
|
|
field: 'id',
|
|
|
|
|
label: '姓名',
|
|
|
|
|
component: 'Input',
|
|
|
|
|
required: true,
|
|
|
|
|
ifShow:false
|
|
|
|
|
},
|
2024-01-13 10:56:48 +08:00
|
|
|
{
|
|
|
|
|
field: 'account',
|
2024-02-07 09:24:07 +08:00
|
|
|
label: '账号',
|
2024-01-13 10:56:48 +08:00
|
|
|
component: 'Input',
|
2024-02-07 09:24:07 +08:00
|
|
|
// helpMessage: ['本字段演示异步验证', '不能输入带有admin的账号'],
|
2024-01-13 10:56:48 +08:00
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
2024-02-07 09:24:07 +08:00
|
|
|
message: '请输入账号',
|
2024-01-13 10:56:48 +08:00
|
|
|
},
|
2024-02-07 09:24:07 +08:00
|
|
|
// {
|
|
|
|
|
// trigger: 'blur',
|
|
|
|
|
// validator(_, value) {
|
|
|
|
|
// return new Promise((resolve, reject) => {
|
|
|
|
|
// if (!value) return resolve();
|
|
|
|
|
// isAccountExist(value)
|
|
|
|
|
// .then(resolve)
|
|
|
|
|
// .catch((err) => {
|
|
|
|
|
// reject(err.message || '验证失败');
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// },
|
|
|
|
|
// },
|
2024-01-13 10:56:48 +08:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-02-07 09:24:07 +08:00
|
|
|
field: 'name',
|
|
|
|
|
label: '姓名',
|
|
|
|
|
component: 'Input',
|
2024-01-13 10:56:48 +08:00
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-02-07 09:24:07 +08:00
|
|
|
field: 'password',
|
|
|
|
|
label: '密码',
|
|
|
|
|
component: 'InputPassword',
|
2024-01-13 10:56:48 +08:00
|
|
|
},
|
|
|
|
|
{
|
2024-02-07 09:24:07 +08:00
|
|
|
field: 'status',
|
|
|
|
|
label: '状态',
|
|
|
|
|
component: 'RadioButtonGroup',
|
|
|
|
|
defaultValue: 0,
|
2024-01-13 10:56:48 +08:00
|
|
|
componentProps: {
|
2024-02-07 09:24:07 +08:00
|
|
|
options: [
|
|
|
|
|
{ label: '启用', value: 0},
|
|
|
|
|
{ label: '停用', value: 1 },
|
|
|
|
|
],
|
2024-01-13 10:56:48 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|