1
0
Files
gringotts/gringotts-frontend/pages/index/tab-user.js

83 lines
3.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import {
administratorOnly,
apiGet,
copyField,
crudCommonOptions,
mappingField,
operationField,
timeField,
userRoleMapping,
userStateMapping
} from '../../components/constants.js'
import {userCheckDialog, userDetailDialog} from "../../components/user/dialog-user-check.js";
import {userAdministratorRegisterDialog} from "../../components/user/dialog-user-register.js";
export function tabUser() {
return {
visibleOn: administratorOnly,
title: '用户管理',
icon: 'fa fa-user',
reload: true,
body: [
{
type: 'crud',
api: apiGet('${base}/user_management/list'),
...crudCommonOptions(),
headerToolbar: [
'reload',
{
type: 'action',
icon: 'fa fa-plus',
tooltip: '新增账号',
...userAdministratorRegisterDialog(),
},
],
columns: [
copyField(
'username',
'邮箱',
undefined,
undefined,
userDetailDialog(),
),
mappingField('role', '角色', userRoleMapping, 120),
mappingField('state', '账号状态', userStateMapping),
timeField('createdTime', '创建时间'),
timeField('lastLoginTime', '上次登陆时间'),
operationField('操作', undefined, [
{
visibleOn: "${state === 'CHECKING'}",
label: '审核',
icon: 'fa fa-fingerprint',
level: 'primary',
size: 'xs',
...userCheckDialog(),
},
{
visibleOn: "${state === 'NORMAL' && role !== 'ADMINISTRATOR'}",
label: '禁用',
icon: 'fa fa-ban',
level: 'danger',
size: 'xs',
confirmText: '确认禁用账号${username}',
confirmTitle: '禁用账号',
actionType: 'ajax',
api: apiGet('${base}/user_management/disable/${username}'),
},
{
visibleOn: "${state === 'DISABLED' && role !== 'ADMINISTRATOR'}",
label: '启用',
icon: 'fa fa-check',
level: 'success',
size: 'xs',
confirmText: '确认启用账号${username}',
confirmTitle: '启用账号',
actionType: 'ajax',
api: apiGet('${base}/user_management/enable/${username}'),
}
]),
]
}
]
}
}