From b072b83f809391243be3e8991eeb7fe35389ae60 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Sun, 1 Dec 2024 11:17:44 +0800 Subject: [PATCH] =?UTF-8?q?feat(web):=20=E5=A2=9E=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=BA=9Bamis=E7=BB=93=E6=9E=84=E7=9A=84=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gringotts-frontend/components/constants.js | 52 ++++++- .../components/user/dialog-user-check.js | 18 +-- gringotts-frontend/pages/index/tab-check.js | 74 ++++------ gringotts-frontend/pages/index/tab-data.js | 98 ++++++------- .../pages/index/tab-permissions.js | 130 ++++++++---------- gringotts-frontend/pages/index/tab-user.js | 120 ++++++---------- 6 files changed, 224 insertions(+), 268 deletions(-) diff --git a/gringotts-frontend/components/constants.js b/gringotts-frontend/components/constants.js index 77468d7..b10a983 100644 --- a/gringotts-frontend/components/constants.js +++ b/gringotts-frontend/components/constants.js @@ -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 = { '*': `\${${field}}`, } @@ -147,8 +192,11 @@ export function mappingField(field, mapping) { mapData[item['value']] = `${item['label']}` }) return { + label: label, type: 'mapping', + width: width, value: `\${${field}}`, + align: 'center', map: mapData, } } diff --git a/gringotts-frontend/components/user/dialog-user-check.js b/gringotts-frontend/components/user/dialog-user-check.js index 2ab0114..57ca8f5 100644 --- a/gringotts-frontend/components/user/dialog-user-check.js +++ b/gringotts-frontend/components/user/dialog-user-check.js @@ -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(), diff --git a/gringotts-frontend/pages/index/tab-check.js b/gringotts-frontend/pages/index/tab-check.js index 8607c4b..5033e18 100644 --- a/gringotts-frontend/pages/index/tab-check.js +++ b/gringotts-frontend/pages/index/tab-check.js @@ -4,7 +4,8 @@ import { checkOverMapping, checkTypeMapping, crudCommonOptions, - mappingField + mappingField, + operationField } from "../../components/constants.js"; import {permissionDetailDialog} from "../../components/permission/dialog-permission.js"; @@ -27,50 +28,33 @@ 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: [ - { - visibleOn: '${!over}', - type: 'action', - 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') - } - ] - ), - }, - ] - } + mappingField('type', '类型', checkTypeMapping), + mappingField('over', '状态', checkOverMapping), + operationField('操作', undefined, [ + { + visibleOn: '${!over}', + type: 'action', + 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') + } + ] + ), + }, + ]), ] } ] diff --git a/gringotts-frontend/pages/index/tab-data.js b/gringotts-frontend/pages/index/tab-data.js index beffd42..06d0230 100644 --- a/gringotts-frontend/pages/index/tab-data.js +++ b/gringotts-frontend/pages/index/tab-data.js @@ -11,6 +11,8 @@ import { confirmationStateMapping, crudCommonOptions, mappingField, + operationField, + timeField, userOnly } from "../../components/constants.js"; @@ -38,63 +40,45 @@ 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: [ - { - type: 'action', - label: '详情', - level: 'link', - ...resourceDetailDialog(), - }, - { - type: 'dropdown-button', - level: 'link', - icon: 'fa fa-ellipsis-h', - hideCaret: true, - trigger: 'hover', - buttons: [ - { - disabledOn: arrayOutCheck([confirmationState.none, confirmationState.draft], 'confirmationState'), - 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}') - }, - ] - }, - ] - }, + mappingField('confirmationState', '确权状态', confirmationStateMapping), + timeField('createdTime', '创建时间'), + operationField('操作', undefined, [ + { + type: 'action', + label: '详情', + level: 'link', + ...resourceDetailDialog(), + }, + { + type: 'dropdown-button', + level: 'link', + icon: 'fa fa-ellipsis-h', + hideCaret: true, + trigger: 'hover', + buttons: [ + { + disabledOn: arrayOutCheck([confirmationState.none, confirmationState.draft], 'confirmationState'), + 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}') + }, + ] + }, + ]), ] } } diff --git a/gringotts-frontend/pages/index/tab-permissions.js b/gringotts-frontend/pages/index/tab-permissions.js index 9dd1df1..887ebd5 100644 --- a/gringotts-frontend/pages/index/tab-permissions.js +++ b/gringotts-frontend/pages/index/tab-permissions.js @@ -3,7 +3,9 @@ import { confirmationStateMapping, crudCommonOptions, mappingField, + operationField, providerOnly, + timeField, userOnly } from "../../components/constants.js"; import { @@ -49,79 +51,61 @@ 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: [ - { - type: 'action', - label: '查看', - level: 'link', - ...permissionDetailDialog(), - }, - { - visibleOn: "${state === 'CHECKING'}", - type: 'action', - label: '撤销', - level: 'link', - confirmTitle: '确认撤销', - confirmText: '确认撤销名称为「${name}」的确权申请吗?', - actionType: 'ajax', - api: apiGet('${base}/confirmation/retract/${id}'), - }, - { - visibleOn: "${state === 'DRAFT' || state === 'REJECT'}", - type: 'action', - label: '提交', - level: 'link', - confirmTitle: '确认提交', - confirmText: '确认提交名称为「${name}」的确权申请吗?', - actionType: 'ajax', - api: apiGet('${base}/confirmation/submit/${id}'), - }, - { - type: 'dropdown-button', - level: 'link', - icon: 'fa fa-ellipsis-h', - hideCaret: true, - 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}'), - }, - ] - }, - ] - }, + mappingField('state', '状态', confirmationStateMapping), + timeField('createdTime', '创建时间'), + operationField('操作', undefined, [ + { + type: 'action', + label: '查看', + level: 'link', + ...permissionDetailDialog(), + }, + { + visibleOn: "${state === 'CHECKING'}", + type: 'action', + label: '撤销', + level: 'link', + confirmTitle: '确认撤销', + confirmText: '确认撤销名称为「${name}」的确权申请吗?', + actionType: 'ajax', + api: apiGet('${base}/confirmation/retract/${id}'), + }, + { + visibleOn: "${state === 'DRAFT' || state === 'REJECT'}", + type: 'action', + label: '提交', + level: 'link', + confirmTitle: '确认提交', + confirmText: '确认提交名称为「${name}」的确权申请吗?', + actionType: 'ajax', + api: apiGet('${base}/confirmation/submit/${id}'), + }, + { + type: 'dropdown-button', + level: 'link', + icon: 'fa fa-ellipsis-h', + hideCaret: true, + trigger: 'hover', + buttons: [ + { + disabledOn: "${state !== 'DRAFT'}", + type: 'action', + label: '编辑', + level: 'link', + ...permissionEditeDialog(), + }, + { + disabledOn: "${state === 'CHECKING'}", + type: 'action', + label: "删除", + confirmTitle: '确认删除', + confirmText: '确认删除名称为「${name}」的确权申请吗?删除后对应的数据资源处于未确权状态。', + actionType: 'ajax', + api: apiGet('${base}/confirmation/remove/${id}'), + }, + ] + }, + ]), ] } }, diff --git a/gringotts-frontend/pages/index/tab-user.js b/gringotts-frontend/pages/index/tab-user.js index 3966ec7..4671103 100644 --- a/gringotts-frontend/pages/index/tab-user.js +++ b/gringotts-frontend/pages/index/tab-user.js @@ -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}'), + } + ]), ] } ]