1
0

feat(web): 增加一些amis结构的工具函数

This commit is contained in:
2024-12-01 11:17:44 +08:00
parent 4dcc10f2f7
commit b072b83f80
6 changed files with 224 additions and 268 deletions

View File

@@ -4,6 +4,8 @@ import {
copyField,
crudCommonOptions,
mappingField,
operationField,
timeField,
userRoleMapping,
userStateMapping
} from '../../components/constants.js'
@@ -31,81 +33,49 @@ export function tabUser() {
},
],
columns: [
{
name: 'username',
label: '邮箱',
...copyField(
'username',
undefined,
undefined,
userDetailDialog(),
)
},
{
label: '角色',
width: 120,
align: 'center',
...mappingField('role', userRoleMapping)
},
{
label: '账号状态',
width: 80,
align: 'center',
...mappingField('state', userStateMapping)
},
{
label: '创建时间',
width: 150,
align: 'center',
type: 'tpl',
tpl: "${IF(createdTime, DATETOSTR(createdTime), '-')}"
},
{
label: '上次登陆时间',
width: 150,
align: 'center',
type: 'tpl',
tpl: "${IF(lastLoginTime, DATETOSTR(lastLoginTime), '-')}"
},
{
label: '操作',
width: 100,
type: 'operation',
fixed: 'right',
className: 'nowrap',
buttons: [
{
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}'),
}
]
},
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}'),
}
]),
]
}
]