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 tpl = ignoreLength === 0 ? `\${${field}}` : `\${TRUNCATE(${field}, ${ignoreLength})}`
|
||||||
let content = extra
|
let content = extra
|
||||||
? {
|
? {
|
||||||
@@ -121,6 +128,7 @@ export function copyField(field, tips = '复制', ignoreLength = 0, extra = unde
|
|||||||
tpl: tpl,
|
tpl: tpl,
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
name: field,
|
||||||
type: 'wrapper',
|
type: 'wrapper',
|
||||||
size: 'none',
|
size: 'none',
|
||||||
body: [
|
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 = {
|
let mapData = {
|
||||||
'*': `<span class='label bg-gray-300'>\${${field}}</span>`,
|
'*': `<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>`
|
mapData[item['value']] = `<span class='label ${item['color']}'>${item['label']}</span>`
|
||||||
})
|
})
|
||||||
return {
|
return {
|
||||||
|
label: label,
|
||||||
type: 'mapping',
|
type: 'mapping',
|
||||||
|
width: width,
|
||||||
value: `\${${field}}`,
|
value: `\${${field}}`,
|
||||||
|
align: 'center',
|
||||||
map: mapData,
|
map: mapData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,22 +16,8 @@ const dialogBody = [
|
|||||||
{
|
{
|
||||||
type: 'group',
|
type: 'group',
|
||||||
body: [
|
body: [
|
||||||
{
|
mappingField('role', '角色', userRoleMapping),
|
||||||
type: 'control',
|
mappingField('state', '账号状态', userStateMapping),
|
||||||
name: 'role',
|
|
||||||
label: '角色',
|
|
||||||
body: [
|
|
||||||
mappingField('role', userRoleMapping),
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'control',
|
|
||||||
name: 'state',
|
|
||||||
label: '账号状态',
|
|
||||||
body: [
|
|
||||||
mappingField('state', userStateMapping)
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
...formCreatedUserAndModifiedUser(),
|
...formCreatedUserAndModifiedUser(),
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import {
|
|||||||
checkOverMapping,
|
checkOverMapping,
|
||||||
checkTypeMapping,
|
checkTypeMapping,
|
||||||
crudCommonOptions,
|
crudCommonOptions,
|
||||||
mappingField
|
mappingField,
|
||||||
|
operationField
|
||||||
} from "../../components/constants.js";
|
} from "../../components/constants.js";
|
||||||
import {permissionDetailDialog} from "../../components/permission/dialog-permission.js";
|
import {permissionDetailDialog} from "../../components/permission/dialog-permission.js";
|
||||||
|
|
||||||
@@ -27,50 +28,33 @@ export function tabCheck() {
|
|||||||
name: 'description',
|
name: 'description',
|
||||||
label: '描述',
|
label: '描述',
|
||||||
},
|
},
|
||||||
{
|
mappingField('type', '类型', checkTypeMapping),
|
||||||
label: '类型',
|
mappingField('over', '状态', checkOverMapping),
|
||||||
width: 80,
|
operationField('操作', undefined, [
|
||||||
align: 'center',
|
{
|
||||||
...mappingField('type', checkTypeMapping)
|
visibleOn: '${!over}',
|
||||||
},
|
type: 'action',
|
||||||
{
|
label: '处理',
|
||||||
label: '状态',
|
level: 'link',
|
||||||
width: 80,
|
...permissionDetailDialog(
|
||||||
align: 'center',
|
'parameters.confirmationId',
|
||||||
...mappingField('over', checkOverMapping)
|
[
|
||||||
},
|
{
|
||||||
{
|
type: 'action',
|
||||||
label: '操作',
|
label: '同意',
|
||||||
width: 100,
|
actionType: 'ajax',
|
||||||
type: 'operation',
|
api: apiGet('${base}/check_order/operation/${checkOrderId}/APPLY')
|
||||||
fixed: 'right',
|
},
|
||||||
className: 'nowrap',
|
{
|
||||||
buttons: [
|
type: 'action',
|
||||||
{
|
label: '拒绝',
|
||||||
visibleOn: '${!over}',
|
actionType: 'ajax',
|
||||||
type: 'action',
|
api: apiGet('${base}/check_order/operation/${checkOrderId}/REJECT')
|
||||||
label: '处理',
|
}
|
||||||
level: 'link',
|
]
|
||||||
...permissionDetailDialog(
|
),
|
||||||
'parameters.confirmationId',
|
},
|
||||||
[
|
]),
|
||||||
{
|
|
||||||
type: 'action',
|
|
||||||
label: '同意',
|
|
||||||
actionType: 'ajax',
|
|
||||||
api: apiGet('${base}/check_order/operation/${checkOrderId}/APPLY')
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'action',
|
|
||||||
label: '拒绝',
|
|
||||||
actionType: 'ajax',
|
|
||||||
api: apiGet('${base}/check_order/operation/${checkOrderId}/REJECT')
|
|
||||||
}
|
|
||||||
]
|
|
||||||
),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import {
|
|||||||
confirmationStateMapping,
|
confirmationStateMapping,
|
||||||
crudCommonOptions,
|
crudCommonOptions,
|
||||||
mappingField,
|
mappingField,
|
||||||
|
operationField,
|
||||||
|
timeField,
|
||||||
userOnly
|
userOnly
|
||||||
} from "../../components/constants.js";
|
} from "../../components/constants.js";
|
||||||
|
|
||||||
@@ -38,63 +40,45 @@ export function resourceList() {
|
|||||||
label: '描述',
|
label: '描述',
|
||||||
name: 'description',
|
name: 'description',
|
||||||
},
|
},
|
||||||
{
|
mappingField('confirmationState', '确权状态', confirmationStateMapping),
|
||||||
label: '确权状态',
|
timeField('createdTime', '创建时间'),
|
||||||
width: 80,
|
operationField('操作', undefined, [
|
||||||
align: 'center',
|
{
|
||||||
...mappingField('confirmationState', confirmationStateMapping)
|
type: 'action',
|
||||||
},
|
label: '详情',
|
||||||
{
|
level: 'link',
|
||||||
label: '创建时间',
|
...resourceDetailDialog(),
|
||||||
width: 150,
|
},
|
||||||
align: 'center',
|
{
|
||||||
type: 'tpl',
|
type: 'dropdown-button',
|
||||||
tpl: "${IF(createdTime, DATETOSTR(createdTime), '-')}"
|
level: 'link',
|
||||||
},
|
icon: 'fa fa-ellipsis-h',
|
||||||
{
|
hideCaret: true,
|
||||||
label: '操作',
|
trigger: 'hover',
|
||||||
width: 100,
|
buttons: [
|
||||||
type: 'operation',
|
{
|
||||||
fixed: 'right',
|
disabledOn: arrayOutCheck([confirmationState.none, confirmationState.draft], 'confirmationState'),
|
||||||
className: 'nowrap',
|
disabledTip: '审查或确权成功后无法编辑',
|
||||||
buttons: [
|
tooltipPlacement: 'top',
|
||||||
{
|
type: 'action',
|
||||||
type: 'action',
|
label: '编辑',
|
||||||
label: '详情',
|
level: 'link',
|
||||||
level: 'link',
|
...resourceEditeDialog(),
|
||||||
...resourceDetailDialog(),
|
},
|
||||||
},
|
{
|
||||||
{
|
disabledOn: arrayInCheck([confirmationState.checking], 'confirmationState'),
|
||||||
type: 'dropdown-button',
|
disabledTip: '审查中无法删除',
|
||||||
level: 'link',
|
tooltipPlacement: 'bottom',
|
||||||
icon: 'fa fa-ellipsis-h',
|
type: 'action',
|
||||||
hideCaret: true,
|
label: "删除",
|
||||||
trigger: 'hover',
|
confirmTitle: '确认删除',
|
||||||
buttons: [
|
confirmText: '确认删除名称为「${name}」的数据资源吗?',
|
||||||
{
|
actionType: 'ajax',
|
||||||
disabledOn: arrayOutCheck([confirmationState.none, confirmationState.draft], 'confirmationState'),
|
api: apiGet('${base}/data_resource/remove/${id}')
|
||||||
disabledTip: '审查或确权成功后无法编辑',
|
},
|
||||||
tooltipPlacement: 'top',
|
]
|
||||||
type: 'action',
|
},
|
||||||
label: '编辑',
|
]),
|
||||||
level: 'link',
|
|
||||||
...resourceEditeDialog(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
disabledOn: arrayInCheck([confirmationState.checking], 'confirmationState'),
|
|
||||||
disabledTip: '审查中无法删除',
|
|
||||||
tooltipPlacement: 'bottom',
|
|
||||||
type: 'action',
|
|
||||||
label: "删除",
|
|
||||||
confirmTitle: '确认删除',
|
|
||||||
confirmText: '确认删除名称为「${name}」的数据资源吗?',
|
|
||||||
actionType: 'ajax',
|
|
||||||
api: apiGet('${base}/data_resource/remove/${id}')
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import {
|
|||||||
confirmationStateMapping,
|
confirmationStateMapping,
|
||||||
crudCommonOptions,
|
crudCommonOptions,
|
||||||
mappingField,
|
mappingField,
|
||||||
|
operationField,
|
||||||
providerOnly,
|
providerOnly,
|
||||||
|
timeField,
|
||||||
userOnly
|
userOnly
|
||||||
} from "../../components/constants.js";
|
} from "../../components/constants.js";
|
||||||
import {
|
import {
|
||||||
@@ -49,79 +51,61 @@ export function tabPermissions() {
|
|||||||
label: '描述',
|
label: '描述',
|
||||||
name: 'description',
|
name: 'description',
|
||||||
},
|
},
|
||||||
{
|
mappingField('state', '状态', confirmationStateMapping),
|
||||||
label: '状态',
|
timeField('createdTime', '创建时间'),
|
||||||
width: 80,
|
operationField('操作', undefined, [
|
||||||
align: 'center',
|
{
|
||||||
...mappingField('state', confirmationStateMapping)
|
type: 'action',
|
||||||
},
|
label: '查看',
|
||||||
{
|
level: 'link',
|
||||||
label: '创建时间',
|
...permissionDetailDialog(),
|
||||||
width: 150,
|
},
|
||||||
align: 'center',
|
{
|
||||||
type: 'tpl',
|
visibleOn: "${state === 'CHECKING'}",
|
||||||
tpl: "${IF(createdTime, DATETOSTR(createdTime), '-')}"
|
type: 'action',
|
||||||
},
|
label: '撤销',
|
||||||
{
|
level: 'link',
|
||||||
label: '操作',
|
confirmTitle: '确认撤销',
|
||||||
width: 100,
|
confirmText: '确认撤销名称为「${name}」的确权申请吗?',
|
||||||
type: 'operation',
|
actionType: 'ajax',
|
||||||
fixed: 'right',
|
api: apiGet('${base}/confirmation/retract/${id}'),
|
||||||
className: 'nowrap',
|
},
|
||||||
buttons: [
|
{
|
||||||
{
|
visibleOn: "${state === 'DRAFT' || state === 'REJECT'}",
|
||||||
type: 'action',
|
type: 'action',
|
||||||
label: '查看',
|
label: '提交',
|
||||||
level: 'link',
|
level: 'link',
|
||||||
...permissionDetailDialog(),
|
confirmTitle: '确认提交',
|
||||||
},
|
confirmText: '确认提交名称为「${name}」的确权申请吗?',
|
||||||
{
|
actionType: 'ajax',
|
||||||
visibleOn: "${state === 'CHECKING'}",
|
api: apiGet('${base}/confirmation/submit/${id}'),
|
||||||
type: 'action',
|
},
|
||||||
label: '撤销',
|
{
|
||||||
level: 'link',
|
type: 'dropdown-button',
|
||||||
confirmTitle: '确认撤销',
|
level: 'link',
|
||||||
confirmText: '确认撤销名称为「${name}」的确权申请吗?',
|
icon: 'fa fa-ellipsis-h',
|
||||||
actionType: 'ajax',
|
hideCaret: true,
|
||||||
api: apiGet('${base}/confirmation/retract/${id}'),
|
trigger: 'hover',
|
||||||
},
|
buttons: [
|
||||||
{
|
{
|
||||||
visibleOn: "${state === 'DRAFT' || state === 'REJECT'}",
|
disabledOn: "${state !== 'DRAFT'}",
|
||||||
type: 'action',
|
type: 'action',
|
||||||
label: '提交',
|
label: '编辑',
|
||||||
level: 'link',
|
level: 'link',
|
||||||
confirmTitle: '确认提交',
|
...permissionEditeDialog(),
|
||||||
confirmText: '确认提交名称为「${name}」的确权申请吗?',
|
},
|
||||||
actionType: 'ajax',
|
{
|
||||||
api: apiGet('${base}/confirmation/submit/${id}'),
|
disabledOn: "${state === 'CHECKING'}",
|
||||||
},
|
type: 'action',
|
||||||
{
|
label: "删除",
|
||||||
type: 'dropdown-button',
|
confirmTitle: '确认删除',
|
||||||
level: 'link',
|
confirmText: '确认删除名称为「${name}」的确权申请吗?删除后对应的数据资源处于未确权状态。',
|
||||||
icon: 'fa fa-ellipsis-h',
|
actionType: 'ajax',
|
||||||
hideCaret: true,
|
api: apiGet('${base}/confirmation/remove/${id}'),
|
||||||
trigger: 'hover',
|
},
|
||||||
buttons: [
|
]
|
||||||
{
|
},
|
||||||
disabledOn: "${state === 'CHECKING'}",
|
]),
|
||||||
type: 'action',
|
|
||||||
label: '编辑',
|
|
||||||
level: 'link',
|
|
||||||
...permissionEditeDialog(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
disabledOn: "${state === 'CHECKING'}",
|
|
||||||
type: 'action',
|
|
||||||
label: "删除",
|
|
||||||
confirmTitle: '确认删除',
|
|
||||||
confirmText: '确认删除名称为「${name}」的确权申请吗?',
|
|
||||||
actionType: 'ajax',
|
|
||||||
api: apiGet('${base}/confirmation/remove/${id}'),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import {
|
|||||||
copyField,
|
copyField,
|
||||||
crudCommonOptions,
|
crudCommonOptions,
|
||||||
mappingField,
|
mappingField,
|
||||||
|
operationField,
|
||||||
|
timeField,
|
||||||
userRoleMapping,
|
userRoleMapping,
|
||||||
userStateMapping
|
userStateMapping
|
||||||
} from '../../components/constants.js'
|
} from '../../components/constants.js'
|
||||||
@@ -31,81 +33,49 @@ export function tabUser() {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
columns: [
|
columns: [
|
||||||
{
|
copyField(
|
||||||
name: 'username',
|
'username',
|
||||||
label: '邮箱',
|
'邮箱',
|
||||||
...copyField(
|
undefined,
|
||||||
'username',
|
undefined,
|
||||||
undefined,
|
userDetailDialog(),
|
||||||
undefined,
|
),
|
||||||
userDetailDialog(),
|
mappingField('role', '角色', userRoleMapping, 120),
|
||||||
)
|
mappingField('state', '账号状态', userStateMapping),
|
||||||
},
|
timeField('createdTime', '创建时间'),
|
||||||
{
|
timeField('lastLoginTime', '上次登陆时间'),
|
||||||
label: '角色',
|
operationField('操作', undefined, [
|
||||||
width: 120,
|
{
|
||||||
align: 'center',
|
visibleOn: "${state === 'CHECKING'}",
|
||||||
...mappingField('role', userRoleMapping)
|
label: '审核',
|
||||||
},
|
icon: 'fa fa-fingerprint',
|
||||||
{
|
level: 'primary',
|
||||||
label: '账号状态',
|
size: 'xs',
|
||||||
width: 80,
|
...userCheckDialog(),
|
||||||
align: 'center',
|
},
|
||||||
...mappingField('state', userStateMapping)
|
{
|
||||||
},
|
visibleOn: "${state === 'NORMAL' && role !== 'ADMINISTRATOR'}",
|
||||||
{
|
label: '禁用',
|
||||||
label: '创建时间',
|
icon: 'fa fa-ban',
|
||||||
width: 150,
|
level: 'danger',
|
||||||
align: 'center',
|
size: 'xs',
|
||||||
type: 'tpl',
|
confirmText: '确认禁用账号${username}?',
|
||||||
tpl: "${IF(createdTime, DATETOSTR(createdTime), '-')}"
|
confirmTitle: '禁用账号',
|
||||||
},
|
actionType: 'ajax',
|
||||||
{
|
api: apiGet('${base}/user_management/disable/${username}'),
|
||||||
label: '上次登陆时间',
|
},
|
||||||
width: 150,
|
{
|
||||||
align: 'center',
|
visibleOn: "${state === 'DISABLED' && role !== 'ADMINISTRATOR'}",
|
||||||
type: 'tpl',
|
label: '启用',
|
||||||
tpl: "${IF(lastLoginTime, DATETOSTR(lastLoginTime), '-')}"
|
icon: 'fa fa-check',
|
||||||
},
|
level: 'success',
|
||||||
{
|
size: 'xs',
|
||||||
label: '操作',
|
confirmText: '确认启用账号${username}?',
|
||||||
width: 100,
|
confirmTitle: '启用账号',
|
||||||
type: 'operation',
|
actionType: 'ajax',
|
||||||
fixed: 'right',
|
api: apiGet('${base}/user_management/enable/${username}'),
|
||||||
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}'),
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user