From 851fc02ce5092026db8e7a2cbbfc9d571aec1421 Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Tue, 26 Nov 2024 14:02:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(web):=20=E5=A2=9E=E5=8A=A0=E6=9D=83?= =?UTF-8?q?=E5=B1=9E=E7=AE=A1=E7=90=86=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gringotts-frontend/components/constants.js | 45 +++++++++-------- .../permission/dialog-permission.css | 3 ++ .../permission/dialog-permission.js | 48 +++++++++++++++++++ .../components/resource/dialog-resource.js | 32 ++++++------- gringotts-frontend/pages/index/main.js | 2 + gringotts-frontend/pages/index/tab-data.js | 31 +++++++----- .../pages/index/tab-permissions.js | 31 ++++++++++++ 7 files changed, 144 insertions(+), 48 deletions(-) create mode 100644 gringotts-frontend/components/permission/dialog-permission.css create mode 100644 gringotts-frontend/components/permission/dialog-permission.js create mode 100644 gringotts-frontend/pages/index/tab-permissions.js diff --git a/gringotts-frontend/components/constants.js b/gringotts-frontend/components/constants.js index ecb6bc2..26a07a2 100644 --- a/gringotts-frontend/components/constants.js +++ b/gringotts-frontend/components/constants.js @@ -1,26 +1,26 @@ const information = { - debug: false, - // baseUrl: '', - baseUrl: 'http://127.0.0.1:20080', - title: '可信供给中心', + debug: false, + // baseUrl: '', + baseUrl: 'http://127.0.0.1:20080', + title: '可信供给中心', } export function useAmis(amisObject) { - document.title = information.title - let amis = amisRequire('amis/embed') - amis.embed( - '#app', - amisObject(information), - { - data: { - base: information.baseUrl, - }, - }, - { - theme: 'antd', - enableAMISDebug: information.debug, - } - ) + document.title = information.title + let amis = amisRequire('amis/embed') + amis.embed( + '#app', + amisObject(information), + { + data: { + base: information.baseUrl, + }, + }, + { + theme: 'antd', + enableAMISDebug: information.debug, + } + ) } export function crudCommonOptions() { @@ -202,4 +202,11 @@ export const role = { export const administratorOnly = roleCheck([role.administrator]) export const checkerOnly = roleCheck([role.administrator, role.checker]) export const userOnly = roleCheck([role.administrator, role.provider, role.customer]) +export const providerOnly = roleCheck([role.administrator, role.provider]) +export const customerOnly = roleCheck([role.administrator, role.customer]) + +export const formInputClearable = { + clearable: true, + clearValueOnEmpty: true, +} diff --git a/gringotts-frontend/components/permission/dialog-permission.css b/gringotts-frontend/components/permission/dialog-permission.css new file mode 100644 index 0000000..e297e56 --- /dev/null +++ b/gringotts-frontend/components/permission/dialog-permission.css @@ -0,0 +1,3 @@ +textarea { + resize: none !important; +} \ No newline at end of file diff --git a/gringotts-frontend/components/permission/dialog-permission.js b/gringotts-frontend/components/permission/dialog-permission.js new file mode 100644 index 0000000..2efa9a6 --- /dev/null +++ b/gringotts-frontend/components/permission/dialog-permission.js @@ -0,0 +1,48 @@ +import './dialog-permission.css' +import {horizontalFormOptions} from "../constants.js"; + +function detailForm() { + return { + id: 'resource_data_form', + type: 'form', + ...horizontalFormOptions(), + horizontal: { + left: 2, + }, + body: [ + { + type: 'hidden', + name: 'id', + }, + ] + } +} + +export function permissionAddDialog() { + return { + actionType: 'dialog', + dialog: { + title: '新增确权申请', + size: 'md', + actions: [ + { + type: 'reset', + label: '重置', + }, + { + type: 'submit', + label: '确定', + level: 'primary', + } + ], + body: { + debug: true, + ...detailForm(), + // api: apiPost('${base}/data_resource/save'), + data: { + add: true, + }, + } + } + } +} diff --git a/gringotts-frontend/components/resource/dialog-resource.js b/gringotts-frontend/components/resource/dialog-resource.js index 4900aa9..f5d776d 100644 --- a/gringotts-frontend/components/resource/dialog-resource.js +++ b/gringotts-frontend/components/resource/dialog-resource.js @@ -2,17 +2,13 @@ import './dialog-resource.css' import { apiGet, apiPost, + formInputClearable, horizontalFormOptions, inputFileFormItemCommonOptions, size1GB, size500MB } from "../constants.js"; -const clearable = { - clearable: true, - clearValueOnEmpty: true, -} - function inputFileFormItemUpdateFieldOptions(target) { let value = {} value[target] = '${event.data.value}' @@ -51,13 +47,13 @@ function detailForm() { name: 'name', label: '资源名称', required: true, - ...clearable, + ...formInputClearable, }, { type: 'textarea', name: 'description', label: '资源描述', - ...clearable, + ...formInputClearable, showCounter: true, trimContents: true, minRows: 2, @@ -90,19 +86,19 @@ function detailForm() { label: 'API地址', name: 'apiUrl', required: true, - ...clearable, + ...formInputClearable, }, { type: 'input-text', label: '用户名', name: 'apiUsername', - ...clearable, + ...formInputClearable, }, { type: 'input-password', label: '密码', name: 'apiPassword', - ...clearable, + ...formInputClearable, }, ] }, @@ -149,19 +145,19 @@ function detailForm() { label: 'JDBC', name: 'databaseJdbc', required: true, - ...clearable, + ...formInputClearable, }, { type: 'input-text', label: '用户名', name: 'databaseUsername', - ...clearable, + ...formInputClearable, }, { type: 'input-password', label: '密码', name: 'databasePassword', - ...clearable, + ...formInputClearable, }, ] }, @@ -210,33 +206,33 @@ function detailForm() { label: 'FTP地址', name: 'ftpUrl', required: true, - ...clearable, + ...formInputClearable, }, { type: 'input-text', label: 'FTP账号', name: 'ftpUsername', - ...clearable, + ...formInputClearable, }, { type: 'input-password', label: 'FTP密码', name: 'ftpPassword', - ...clearable, + ...formInputClearable, }, { type: 'input-text', label: '相对路径', name: 'ftpPath', description: '若为空,则使用用户根目录', - ...clearable, + ...formInputClearable, }, { type: 'input-text', label: '文件筛选', name: 'ftpRegexFilter', description: '正则表达式,用于匹配文件的路径,只有符合筛选条件的文件才会被采集;若为空则默认采集全部文件', - ...clearable, + ...formInputClearable, }, ] }, diff --git a/gringotts-frontend/pages/index/main.js b/gringotts-frontend/pages/index/main.js index f42bb4e..c832177 100644 --- a/gringotts-frontend/pages/index/main.js +++ b/gringotts-frontend/pages/index/main.js @@ -4,6 +4,7 @@ import {tabUser} from "./tab-user.js"; import {tabData} from "./tab-data.js"; import {tabSettings} from "./tab-settings.js"; import {tabCheck} from "./tab-check.js"; +import {tabPermissions} from "./tab-permissions.js"; useAmis(information => { return { @@ -58,6 +59,7 @@ useAmis(information => { tabs: [ // tabOverview(), // tabMarket(), + tabPermissions(), tabData(), tabCheck(), tabUser(), diff --git a/gringotts-frontend/pages/index/tab-data.js b/gringotts-frontend/pages/index/tab-data.js index ddaae4a..5b61035 100644 --- a/gringotts-frontend/pages/index/tab-data.js +++ b/gringotts-frontend/pages/index/tab-data.js @@ -45,7 +45,7 @@ export function tabData() { }, { label: '操作', - width: 200, + width: 100, type: 'operation', fixed: 'right', className: 'nowrap', @@ -53,27 +53,36 @@ export function tabData() { { type: 'action', label: '查看', - icon: 'fa fa-eye', level: 'link', ...resourceDetailDialog(), }, { type: 'action', label: '编辑', - icon: 'fa fa-pen-fancy', level: 'link', ...resourceEditeDialog(), }, { - type: 'action', - label: '删除', - icon: 'fa fa-remove', + type: 'dropdown-button', level: 'link', - className: 'text-danger', - confirmTitle: '确认删除', - confirmText: '确认删除名称为「${name}」的数据资源吗?', - actionType: 'ajax', - api: apiGet('${base}/data_resource/remove/${id}') + icon: 'fa fa-ellipsis-h', + hideCaret: true, + trigger: 'hover', + buttons: [ + { + type: 'action', + label: '申请确权', + level: 'link', + }, + { + 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 new file mode 100644 index 0000000..751bb15 --- /dev/null +++ b/gringotts-frontend/pages/index/tab-permissions.js @@ -0,0 +1,31 @@ +import {providerOnly, userOnly} from "../../components/constants.js"; +import {permissionAddDialog} from "../../components/permission/dialog-permission.js"; + +export function tabPermissions() { + return { + visibleOn: userOnly, + title: '权属管理', + icon: 'fa fa-user-shield', + body: { + type: 'tabs', + tabs: [ + { + visibleOn: providerOnly, + title: '确权管理', + body: [ + { + type: 'action', + label: '', + icon: 'fa fa-plus', + ...permissionAddDialog() + }, + ] + }, + { + title: '授权管理', + body: [] + } + ] + } + } +} \ No newline at end of file