feat(web): 增加一些amis结构的工具函数
This commit is contained in:
@@ -104,7 +104,14 @@ export function inputFileFormItemCommonOptions(accept = '*', maxSize = size5MB)
|
||||
}
|
||||
}
|
||||
|
||||
export function copyField(field, tips = '复制', ignoreLength = 0, extra = undefined) {
|
||||
/**
|
||||
* @param {string} field
|
||||
* @param {string} label
|
||||
* @param {string} tips
|
||||
* @param {number} ignoreLength
|
||||
* @param {{}} extra
|
||||
*/
|
||||
export function copyField(field, label, tips = '复制', ignoreLength = 0, extra = undefined) {
|
||||
let tpl = ignoreLength === 0 ? `\${${field}}` : `\${TRUNCATE(${field}, ${ignoreLength})}`
|
||||
let content = extra
|
||||
? {
|
||||
@@ -121,6 +128,7 @@ export function copyField(field, tips = '复制', ignoreLength = 0, extra = unde
|
||||
tpl: tpl,
|
||||
}
|
||||
return {
|
||||
name: field,
|
||||
type: 'wrapper',
|
||||
size: 'none',
|
||||
body: [
|
||||
@@ -139,7 +147,44 @@ export function copyField(field, tips = '复制', ignoreLength = 0, extra = unde
|
||||
}
|
||||
}
|
||||
|
||||
export function mappingField(field, mapping) {
|
||||
/**
|
||||
* @param {string} label
|
||||
* @param {number} width
|
||||
* @param {Array} buttons
|
||||
*/
|
||||
export function operationField(label, width = 100, buttons = []) {
|
||||
return {
|
||||
label: label,
|
||||
width: width,
|
||||
type: 'operation',
|
||||
fixed: 'right',
|
||||
className: 'nowrap',
|
||||
buttons: buttons,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} field
|
||||
* @param {string} label
|
||||
* @param {number} width
|
||||
*/
|
||||
export function timeField(field, label, width = 150) {
|
||||
return {
|
||||
label: label,
|
||||
width: width,
|
||||
align: 'center',
|
||||
type: 'tpl',
|
||||
tpl: `\${IF(${field}, DATETOSTR(${field}), '-')}`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} field
|
||||
* @param {string} label
|
||||
* @param {[{label: *, value: *, color: string}]} mapping
|
||||
* @param {number} width
|
||||
*/
|
||||
export function mappingField(field, label, mapping, width = 80) {
|
||||
let mapData = {
|
||||
'*': `<span class='label bg-gray-300'>\${${field}}</span>`,
|
||||
}
|
||||
@@ -147,8 +192,11 @@ export function mappingField(field, mapping) {
|
||||
mapData[item['value']] = `<span class='label ${item['color']}'>${item['label']}</span>`
|
||||
})
|
||||
return {
|
||||
label: label,
|
||||
type: 'mapping',
|
||||
width: width,
|
||||
value: `\${${field}}`,
|
||||
align: 'center',
|
||||
map: mapData,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,22 +16,8 @@ const dialogBody = [
|
||||
{
|
||||
type: 'group',
|
||||
body: [
|
||||
{
|
||||
type: 'control',
|
||||
name: 'role',
|
||||
label: '角色',
|
||||
body: [
|
||||
mappingField('role', userRoleMapping),
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'control',
|
||||
name: 'state',
|
||||
label: '账号状态',
|
||||
body: [
|
||||
mappingField('state', userStateMapping)
|
||||
]
|
||||
},
|
||||
mappingField('role', '角色', userRoleMapping),
|
||||
mappingField('state', '账号状态', userStateMapping),
|
||||
]
|
||||
},
|
||||
...formCreatedUserAndModifiedUser(),
|
||||
|
||||
@@ -4,7 +4,8 @@ import {
|
||||
checkOverMapping,
|
||||
checkTypeMapping,
|
||||
crudCommonOptions,
|
||||
mappingField
|
||||
mappingField,
|
||||
operationField
|
||||
} from "../../components/constants.js";
|
||||
import {permissionDetailDialog} from "../../components/permission/dialog-permission.js";
|
||||
|
||||
@@ -27,25 +28,9 @@ export function tabCheck() {
|
||||
name: 'description',
|
||||
label: '描述',
|
||||
},
|
||||
{
|
||||
label: '类型',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
...mappingField('type', checkTypeMapping)
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
...mappingField('over', checkOverMapping)
|
||||
},
|
||||
{
|
||||
label: '操作',
|
||||
width: 100,
|
||||
type: 'operation',
|
||||
fixed: 'right',
|
||||
className: 'nowrap',
|
||||
buttons: [
|
||||
mappingField('type', '类型', checkTypeMapping),
|
||||
mappingField('over', '状态', checkOverMapping),
|
||||
operationField('操作', undefined, [
|
||||
{
|
||||
visibleOn: '${!over}',
|
||||
type: 'action',
|
||||
@@ -69,8 +54,7 @@ export function tabCheck() {
|
||||
]
|
||||
),
|
||||
},
|
||||
]
|
||||
}
|
||||
]),
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
confirmationStateMapping,
|
||||
crudCommonOptions,
|
||||
mappingField,
|
||||
operationField,
|
||||
timeField,
|
||||
userOnly
|
||||
} from "../../components/constants.js";
|
||||
|
||||
@@ -38,26 +40,9 @@ export function resourceList() {
|
||||
label: '描述',
|
||||
name: 'description',
|
||||
},
|
||||
{
|
||||
label: '确权状态',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
...mappingField('confirmationState', confirmationStateMapping)
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
width: 150,
|
||||
align: 'center',
|
||||
type: 'tpl',
|
||||
tpl: "${IF(createdTime, DATETOSTR(createdTime), '-')}"
|
||||
},
|
||||
{
|
||||
label: '操作',
|
||||
width: 100,
|
||||
type: 'operation',
|
||||
fixed: 'right',
|
||||
className: 'nowrap',
|
||||
buttons: [
|
||||
mappingField('confirmationState', '确权状态', confirmationStateMapping),
|
||||
timeField('createdTime', '创建时间'),
|
||||
operationField('操作', undefined, [
|
||||
{
|
||||
type: 'action',
|
||||
label: '详情',
|
||||
@@ -93,8 +78,7 @@ export function resourceList() {
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
]),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ import {
|
||||
confirmationStateMapping,
|
||||
crudCommonOptions,
|
||||
mappingField,
|
||||
operationField,
|
||||
providerOnly,
|
||||
timeField,
|
||||
userOnly
|
||||
} from "../../components/constants.js";
|
||||
import {
|
||||
@@ -49,26 +51,9 @@ export function tabPermissions() {
|
||||
label: '描述',
|
||||
name: 'description',
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
width: 80,
|
||||
align: 'center',
|
||||
...mappingField('state', confirmationStateMapping)
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
width: 150,
|
||||
align: 'center',
|
||||
type: 'tpl',
|
||||
tpl: "${IF(createdTime, DATETOSTR(createdTime), '-')}"
|
||||
},
|
||||
{
|
||||
label: '操作',
|
||||
width: 100,
|
||||
type: 'operation',
|
||||
fixed: 'right',
|
||||
className: 'nowrap',
|
||||
buttons: [
|
||||
mappingField('state', '状态', confirmationStateMapping),
|
||||
timeField('createdTime', '创建时间'),
|
||||
operationField('操作', undefined, [
|
||||
{
|
||||
type: 'action',
|
||||
label: '查看',
|
||||
@@ -103,7 +88,7 @@ export function tabPermissions() {
|
||||
trigger: 'hover',
|
||||
buttons: [
|
||||
{
|
||||
disabledOn: "${state === 'CHECKING'}",
|
||||
disabledOn: "${state !== 'DRAFT'}",
|
||||
type: 'action',
|
||||
label: '编辑',
|
||||
level: 'link',
|
||||
@@ -114,14 +99,13 @@ export function tabPermissions() {
|
||||
type: 'action',
|
||||
label: "删除",
|
||||
confirmTitle: '确认删除',
|
||||
confirmText: '确认删除名称为「${name}」的确权申请吗?',
|
||||
confirmText: '确认删除名称为「${name}」的确权申请吗?删除后对应的数据资源处于未确权状态。',
|
||||
actionType: 'ajax',
|
||||
api: apiGet('${base}/confirmation/remove/${id}'),
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
]),
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4,6 +4,8 @@ import {
|
||||
copyField,
|
||||
crudCommonOptions,
|
||||
mappingField,
|
||||
operationField,
|
||||
timeField,
|
||||
userRoleMapping,
|
||||
userStateMapping
|
||||
} from '../../components/constants.js'
|
||||
@@ -31,49 +33,18 @@ export function tabUser() {
|
||||
},
|
||||
],
|
||||
columns: [
|
||||
{
|
||||
name: 'username',
|
||||
label: '邮箱',
|
||||
...copyField(
|
||||
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: [
|
||||
),
|
||||
mappingField('role', '角色', userRoleMapping, 120),
|
||||
mappingField('state', '账号状态', userStateMapping),
|
||||
timeField('createdTime', '创建时间'),
|
||||
timeField('lastLoginTime', '上次登陆时间'),
|
||||
operationField('操作', undefined, [
|
||||
{
|
||||
visibleOn: "${state === 'CHECKING'}",
|
||||
label: '审核',
|
||||
@@ -104,8 +75,7 @@ export function tabUser() {
|
||||
actionType: 'ajax',
|
||||
api: apiGet('${base}/user_management/enable/${username}'),
|
||||
}
|
||||
]
|
||||
},
|
||||
]),
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user