1
0

feat(web): 统一页面显示和权限

This commit is contained in:
2024-11-26 10:40:58 +08:00
parent 246e27677e
commit e76236be62
6 changed files with 43 additions and 7 deletions

View File

@@ -187,3 +187,19 @@ export function apiGet(url) {
export function apiPost(url) {
return api('post', url)
}
export function roleCheck(roles) {
return `\${ARRAYINCLUDES(['${roles.join("','")}'], role)}`
}
export const role = {
administrator: 'ADMINISTRATOR',
checker: 'CHECKER',
provider: 'PROVIDER',
customer: 'CUSTOMER',
}
export const administratorOnly = roleCheck([role.administrator])
export const checkerOnly = roleCheck([role.administrator, role.checker])
export const userOnly = roleCheck([role.administrator, role.provider, role.customer])

View File

@@ -1,9 +1,9 @@
import {apiGet, useAmis} from '../../components/constants.js'
import {userChangePasswordDialog} from "../../components/user/dialog-user-change-password.js";
import {tabUser} from "./tab-user.js";
import {tabMarket} from "./tab-market.js";
import {tabData} from "./tab-data.js";
import {tabSettings} from "./tab-settings.js";
import {tabCheck} from "./tab-check.js";
useAmis(information => {
return {
@@ -56,9 +56,10 @@ useAmis(information => {
type: 'tabs',
tabsMode: 'vertical',
tabs: [
tabData(),
// tabOverview(),
tabMarket(),
// tabMarket(),
tabData(),
tabCheck(),
tabUser(),
tabSettings(),
]

View File

@@ -0,0 +1,12 @@
import {checkerOnly} from "../../components/constants.js";
export function tabCheck() {
return {
visibleOn: checkerOnly,
title: '审核审查',
icon: 'fa fa-shield-halved',
body: [
'hello world'
]
}
}

View File

@@ -3,10 +3,11 @@ import {
resourceDetailDialog,
resourceEditeDialog
} from "../../components/resource/dialog-resource.js";
import {apiGet, apiPost, crudCommonOptions} from "../../components/constants.js";
import {apiGet, apiPost, crudCommonOptions, userOnly} from "../../components/constants.js";
export function tabData() {
return {
visibleOn: userOnly,
title: '数据资源',
icon: 'fa fa-database',
body: [
@@ -20,7 +21,7 @@ export function tabData() {
'reload',
{
type: 'action',
label: '新增数据资源',
label: '',
icon: 'fa fa-plus',
...resourceAddDialog()
},
@@ -52,18 +53,21 @@ 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',
level: 'link',
className: 'text-danger',
confirmTitle: '确认删除',

View File

@@ -1,6 +1,8 @@
import {administratorOnly} from "../../components/constants.js";
export function tabSettings() {
return {
visibleOn: '${role === "ADMINISTRATOR"}',
visibleOn: administratorOnly,
title: '系统管理',
icon: 'fa fa-gear',
body: [

View File

@@ -1,4 +1,5 @@
import {
administratorOnly,
apiGet,
copyField,
crudCommonOptions,
@@ -11,7 +12,7 @@ import {userAdministratorRegisterDialog} from "../../components/user/dialog-user
export function tabUser() {
return {
visibleOn: '${role === "ADMINISTRATOR"}',
visibleOn: administratorOnly,
title: '用户管理',
icon: 'fa fa-user',
body: [