feat: 修改角色切换

This commit is contained in:
ibuler
2020-06-05 19:10:21 +08:00
parent 41a69b1b6b
commit 1d4fb281fb
3 changed files with 16 additions and 16 deletions

View File

@@ -50,7 +50,7 @@ export default {
'currentOrgPerms' 'currentOrgPerms'
]), ]),
isInAdminRole() { isInAdminRole() {
const inAdmin = (this.currentRole & this.adminPageRequirePerm) !== 0 const inAdmin = rolec.hasPerm(rolec.ADMIN_PAGE_REQUIRE_PERM_MIN, this.currentRole)
return inAdmin return inAdmin
}, },
hasAdminOrg() { hasAdminOrg() {
@@ -59,9 +59,9 @@ export default {
adminPageRequirePerm() { adminPageRequirePerm() {
return rolec.PERM_SUPER | rolec.PERM_ADMIN | rolec.PERM_AUDIT return rolec.PERM_SUPER | rolec.PERM_ADMIN | rolec.PERM_AUDIT
}, },
currentOrgAdminPagePerm() { hasCurrentOrgAdminPagePerm() {
// 只有有一个权限就可以 // 只有有一个权限就可以
return this.adminPageRequirePerm & this.currentOrgPerms return rolec.hasAdminPagePerm(this.currentOrgPerms)
}, },
currentOrgUsePagePerm() { currentOrgUsePagePerm() {
const userPageRequireRole = rolec.PERM_USE const userPageRequireRole = rolec.PERM_USE
@@ -75,8 +75,9 @@ export default {
this.$router.push({ name: 'UserProfile' }) this.$router.push({ name: 'UserProfile' })
break break
case 'adminPage': case 'adminPage':
this.$store.dispatch('users/setCurrentRole', this.currentOrgAdminPagePerm) if (this.hasCurrentOrgAdminPagePerm) {
if (this.currentOrgAdminPagePerm) { const currentRole = rolec.getUserInAdminPagePerm(this.currentOrgPerms)
this.$store.dispatch('users/setCurrentRole', currentRole)
window.location.href = `/ui/` window.location.href = `/ui/`
} else { } else {
orgUtil.change2PropOrg() orgUtil.change2PropOrg()

View File

@@ -152,17 +152,18 @@ export const allRoleRoutes = [
}, },
...requireContext.keys().map(key => requireContext(key).default), ...requireContext.keys().map(key => requireContext(key).default),
{ {
name: 'Settings',
path: '/settings', path: '/settings',
component: Layout, component: Layout,
redirect: '/settings/', redirect: '/settings/',
permissions: [rolec.PERM_SUPER], permissions: [rolec.PERM_SUPER],
children: [{ children: [
path: 'settings', {
name: 'Settings', path: '',
component: () => import('@/views/settings/index'), name: 'Settings',
meta: { title: i18n.t('route.Settings'), icon: 'gears', permissions: [rolec.PERM_SUPER] } component: () => import('@/views/settings/index'),
}] meta: { title: i18n.t('route.Settings'), icon: 'gears', permissions: [rolec.PERM_SUPER] }
}
]
}, },
...userPageRoutes, ...userPageRoutes,
{ path: '*', redirect: '/404', hidden: true, meta: { roles: ['SuperAdmin', 'Admin', 'Auditor', 'User'] }} { path: '*', redirect: '/404', hidden: true, meta: { roles: ['SuperAdmin', 'Admin', 'Auditor', 'User'] }}

View File

@@ -25,7 +25,7 @@ export default {
{ {
path: '', path: '',
component: () => import('@/views/xpack/GatheredUser/index'), component: () => import('@/views/xpack/GatheredUser/index'),
name: 'GatherUserList', name: 'GatherUserListIndex',
meta: { title: i18n.t('xpack.GatherUser.GatherUser'), activeMenu: '/xpack/gathered-users' } meta: { title: i18n.t('xpack.GatherUser.GatherUser'), activeMenu: '/xpack/gathered-users' }
}, },
{ {
@@ -61,9 +61,8 @@ export default {
{ {
path: 'orgs', path: 'orgs',
component: empty, component: empty,
name: 'OrganizationList',
redirect: '', redirect: '',
meta: { title: i18n.t('xpack.Organization.OrganizationList'), permissions: [rolec.PERM_SUPER] }, meta: { permissions: [rolec.PERM_SUPER] },
children: [ children: [
{ {
path: '', path: '',
@@ -159,7 +158,6 @@ export default {
path: 'cloud', path: 'cloud',
component: empty, component: empty,
redirect: '', redirect: '',
name: 'Cloud',
meta: { title: i18n.t('xpack.Cloud.Cloud') }, meta: { title: i18n.t('xpack.Cloud.Cloud') },
children: [ children: [
{ {