diff --git a/frontend/src/common/router-handle.js b/frontend/src/common/router-handle.js index c6950ec70..3fc5b863f 100644 --- a/frontend/src/common/router-handle.js +++ b/frontend/src/common/router-handle.js @@ -50,11 +50,17 @@ export const getRouterDiff = (payload) => { 'permTemplateDiff', 'addGroupPerm', 'resourcePermiss', - 'firstManageSpace', 'ratingManager', + 'gradingAdminCreate', + 'gradingAdminDetail', + 'gradingAdminEdit', + 'gradingAdminUpdateTemplate', 'secondaryManageSpace', - 'authorBoundary', 'secondaryManageSpaceCreate', + 'secondaryManageSpaceDetail', + 'authorBoundary', + 'authorBoundaryEditFirstLevel', + 'authorBoundaryEditSecondLevel', 'userGroupSetting', 'sensitivityLevel', 'memberTemplate', @@ -76,6 +82,8 @@ export const getRouterDiff = (payload) => { 'ratingManager', 'gradingAdminCreate', 'gradingAdminDetail', + 'gradingAdminEdit', + 'gradingAdminUpdateTemplate', 'user', 'gradingAdminUpdateTemplate', 'administrator', @@ -89,10 +97,10 @@ export const getRouterDiff = (payload) => { 'systemAccessOptimize', 'systemAccessComplete', 'resourcePermiss', - 'userGroupDetail', - 'firstManageSpace', 'secondaryManageSpace', 'authorBoundary', + 'authorBoundaryEditFirstLevel', + 'authorBoundaryEditSecondLevel', 'myManageSpace', 'myManageSpaceCreate', 'permTransfer', @@ -116,8 +124,9 @@ export const getRouterDiff = (payload) => { 'ratingManager', 'gradingAdminCreate', 'gradingAdminDetail', - 'user', + 'gradingAdminEdit', 'gradingAdminUpdateTemplate', + 'user', 'approval', 'permRenewal', 'audit', @@ -127,10 +136,14 @@ export const getRouterDiff = (payload) => { 'systemAccessRegistry', 'systemAccessOptimize', 'systemAccessComplete', - 'firstManageSpace', 'secondaryManageSpace', + 'secondaryManageSpaceCreate', + 'secondaryManageSpaceDetail', 'authorBoundary', + 'authorBoundaryEditFirstLevel', + 'authorBoundaryEditSecondLevel', 'myManageSpace', + 'myManageSpaceCreate', 'renewalNotice', 'userOrgPerm' ]; @@ -148,8 +161,9 @@ export const getRouterDiff = (payload) => { 'ratingManager', 'gradingAdminCreate', 'gradingAdminDetail', - 'user', + 'gradingAdminEdit', 'gradingAdminUpdateTemplate', + 'user', 'administrator', 'approval', 'permRenewal', @@ -162,7 +176,6 @@ export const getRouterDiff = (payload) => { 'systemAccessComplete', 'myManageSpace', 'resourcePermiss', - 'firstManageSpace', 'sensitivityLevel', 'resourcePermManage', 'renewalNotice' @@ -181,8 +194,9 @@ export const getRouterDiff = (payload) => { 'ratingManager', 'gradingAdminCreate', 'gradingAdminDetail', - 'user', + 'gradingAdminEdit', 'gradingAdminUpdateTemplate', + 'user', 'administrator', 'approval', 'permRenewal', @@ -197,7 +211,6 @@ export const getRouterDiff = (payload) => { 'secondaryManageSpace', 'secondaryManageSpaceCreate', 'secondaryManageSpaceDetail', - 'firstManageSpace', 'myManageSpace', 'permTemplate', 'userGroupSetting', @@ -281,10 +294,17 @@ export const getNavRouterDiff = (navIndex, managerPerm = '') => { 'permTemplateDiff', 'addGroupPerm', 'resourcePermiss', - 'firstManageSpace', 'ratingManager', + 'gradingAdminCreate', + 'gradingAdminDetail', + 'gradingAdminEdit', + 'gradingAdminUpdateTemplate', 'authorBoundary', + 'authorBoundaryEditFirstLevel', + 'authorBoundaryEditSecondLevel', 'secondaryManageSpace', + 'secondaryManageSpaceCreate', + 'secondaryManageSpaceDetail', 'userGroupSetting', 'sensitivityLevel', 'memberTemplate', @@ -333,10 +353,12 @@ export const getNavRouterDiff = (navIndex, managerPerm = '') => { 'permTemplateDiff', 'addGroupPerm', 'resourcePermiss', - 'firstManageSpace', 'authorBoundary', - 'secondaryManageSpace', + 'authorBoundaryEditFirstLevel', + 'authorBoundaryEditSecondLevel', 'myManageSpace', + 'myManageSpaceCreate', + 'secondaryManageSpace', 'secondaryManageSpaceCreate', 'secondaryManageSpaceDetail', 'userGroupSetting', @@ -375,12 +397,12 @@ export const getNavRouterDiff = (navIndex, managerPerm = '') => { 'permTemplate', 'permTemplateDetail', 'permTemplateCreate', - 'authorBoundary', - 'secondaryManageSpace', 'myManageSpace', 'myManageSpaceCreate', + 'secondaryManageSpace', 'secondaryManageSpaceCreate', 'secondaryManageSpaceDetail', + 'authorBoundary', 'authorBoundaryEditFirstLevel', 'authorBoundaryEditSecondLevel', 'permTemplateEdit', diff --git a/frontend/src/components/header-nav/index.vue b/frontend/src/components/header-nav/index.vue index 87939298c..2742de4cc 100644 --- a/frontend/src/components/header-nav/index.vue +++ b/frontend/src/components/header-nav/index.vue @@ -319,7 +319,6 @@ }, appLogo () { // 如果未获取到配置,使用默认logo - console.log(this.globalConfig.appLogo); const src = this.globalConfig.appLogo || logoSvg; return src; } @@ -640,13 +639,7 @@ // this.curHeight = document.getElementsByClassName('user-dropdown')[0].offsetHeight this.isShowGradingWrapper = !this.isShowGradingWrapper; }, - - handleBack () { - this.isShowUserDropdown = false; - this.isShowGradingWrapper = false; - this.handleSwitchRole({ id: 0, type: 'staff', name: this.user.role.name }); - }, - + handleLogout () { window.localStorage.removeItem('iam-header-title-cache'); window.localStorage.removeItem('iam-header-name-cache'); diff --git a/frontend/src/components/nav/index.vue b/frontend/src/components/nav/index.vue index dd66f56ac..11d04ff19 100644 --- a/frontend/src/components/nav/index.vue +++ b/frontend/src/components/nav/index.vue @@ -250,8 +250,6 @@ [['myManageSpace', 'myManageSpaceCreate', 'gradingAdminDetail', 'gradingAdminEdit', 'gradingAdminCreate', 'myManageSpaceSubDetail', 'secondaryManageSpaceEdit'], 'myManageSpaceNav'], // 分级管理员 [['ratingManager', 'gradingAdminDetail', 'gradingAdminCreate', 'gradingAdminEdit'], 'gradingAdminNav'], - // 管理空间 - [['firstManageSpace', 'firstManageSpaceCreate'], 'firstManageSpaceNav'], // 二级管理空间 [['secondaryManageSpace', 'secondaryManageSpaceCreate', 'secondaryManageSpaceDetail'], 'secondaryManageSpaceNav'], // 授权边界 diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 6862ad5f3..cf83600ba 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -76,13 +76,10 @@ export const beforeEach = async (to, from, next) => { store.commit('updateSystemId', externalSystemId); await fetchExternalSystemsLayout(externalSystemId); } - bus.$emit('close-apply-perm-modal'); - canceling = true; await cancelRequest(); canceling = false; - let curRole = store.state.user.role.type; let navIndex = store.state.index || Number(window.localStorage.getItem('index') || 0); let currentRoleId = String(to.query.current_role_id || '').trim(); @@ -154,84 +151,89 @@ export const beforeEach = async (to, from, next) => { window.localStorage.setItem('index', index); } - // 如果进入没有权限,重新找roleList, 蓝盾交互不需要判断 - const isEXternal = !(existValue('externalApp') || to.query.hasOwnProperty('role_id')); - if (['', 'staff'].includes(curRole) && navIndex > 0 && isEXternal) { + let curRoleList = []; + const noFrom = !from.name; + // 是否是嵌入系统 + const isNoIframe = !(existValue('externalApp') || to.query.hasOwnProperty('role_id')); + // 如果进入没有权限 + const isNoPerm = ['', 'staff'].includes(curRole) && navIndex > 0; + // 跳转的页面是否需要非管理员用户界面 + const isStaff = !getNavRouterDiff(0).includes(to.name) || (['permRenewal'].includes(to.name) && ['email', 'notification'].includes(to.query.source)); + // 处理新标签页链接是管理员页面 ,但是上次用户信息是staff + const isManagerPage = !isStaff && noFrom && navIndex < 1; + // 如果进入没有权限或者是拿到的上次用户信息是非管理员身份但是新开标签页是管理员页面, 蓝盾交互不需要判断 + if ((isNoPerm || isManagerPage) && isNoIframe) { const roleList = await store.dispatch('roleList', { cancelWhenRouteChange: false, - cancelPrevious: false + cancelPrevious: false, + limit: 100 }); - if (roleList.length) { - const { id } = roleList[0]; - currentRoleId = id; - curRoleId = id; - store.commit('updateCurRoleId', id); - await getManagerInfo(); + if (roleList && roleList.length > 0) { + curRoleList = [...roleList]; + // 只有管理员页面才需要提供默认管理员身份 + if (navIndex > 0 && !isStaff) { + const { id } = roleList[0]; + [curRoleId, currentRoleId] = [id, id]; + store.commit('updateCurRoleId', id); + await getManagerInfo(); + } } } - - if (!getRouterDiff('staff').includes(to.name) || (['permRenewal'].includes(to.name) && ['email', 'notification'].includes(to.query.source))) { - await store.dispatch('role/updateCurrentRole', { id: 0 }); - await store.dispatch('userInfo'); - curRole = 'staff'; - navDiffMenuIndex(0); - } - - if (!getRouterDiff(curRole).includes(to.name) && !['', 'staff'].includes(curRole) && curRoleId > 0) { - await store.dispatch('role/updateCurrentRole', { id: curRoleId }); - navDiffMenuIndex(1); + // 因为管理空间下菜单还需要细分具体管理员身份,所以getRouterDiff用于分配管理空间导航栏下的路由,getNavRouterDiff用于分配其他几个导航栏的路由 + // 处理非管理空间模块路由跳转校验 + if (navIndex !== 1 || (navIndex > 0 && isStaff)) { + if (isStaff) { + curRoleId = 0; + navIndex = 0; + store.commit('updateCurRoleId', 0); + } + currentRoleId = curRoleId; + navDiffMenuIndex(navIndex); + await getManagerInfo(); + } else { + // 处理管理空间模块路由跳转校验 + if (!['', 'staff'].includes(curRole) && curRoleId > 0) { + // 查找当页面是否在管理空间模块 + const isManageSpace = !getRouterDiff(curRole).includes(to.name); + if (!isManageSpace) { + const allNavIndex = [0, 2, 3]; + // 根据路由名称筛选当前页面所在模块位置 + const curPageIndex = allNavIndex.findIndex((v) => !getNavRouterDiff(v).includes(to.name)); + if (curPageIndex > -1) { + if (curPageIndex === 0) { + curRoleId = 0; + currentRoleId = 0; + } + navIndex = allNavIndex[curPageIndex]; + } + } + currentRoleId = curRoleId; + navDiffMenuIndex(navIndex); + await getManagerInfo(); + } } - if (to.name === 'userGroupDetail') { navDiffMenuIndex(1); if (existValue('externalApp') && to.query.hasOwnProperty('role_id')) { getExternalRole(); } else { - if (currentRoleId) { - // const currentRole = roleList.find((item) => String(item.id) === currentRoleId); - // 从之前的拓扑接口更换成一级、二级接口 - // const currentRole = getTreeNode(+currentRoleId, roleList); - await getManagerInfo(); - } else { - const noFrom = !from.name; - // 说明是刷新页面 - if (noFrom) { - if (existValue('externalApp') || to.query.noFrom) { - next(); - } else { - next(); - // next({ path: `${SITE_URL}${defaultRoute[navIndex]}` }); - } - } else { + // 说明是刷新页面 + if (noFrom) { + if (existValue('externalApp') || to.query.noFrom) { next(); - } - } - } - } else if (to.name === 'userGroup') { - if (currentRoleId) { - await getManagerInfo(); - } else { - if (existValue('externalApp')) { // 外部嵌入页面 - next(); - } else { - if (curRole === 'staff') { - // 单独处理返回个人staff不需要重定向我的权限的路由 - const routeNavMap = [ - [(name) => !getNavRouterDiff(0).includes(name), () => next()], - [(name) => ['ratingManager'].includes(name), () => next({ path: `${SITE_URL}${to.fullPath}` })] - ]; - if (navIndex > 0) { + } else { + // 处理从staff界面跳转到用户组详情,需要提供默认管理员身份 + if ((curRoleId === 0 || ['', 'staff'].includes(curRole)) && curRoleList.length > 0) { + const { id } = curRoleList[0]; + [curRoleId, currentRoleId] = [id, id]; + store.commit('updateCurRoleId', id); await getManagerInfo(); - navDiffMenuIndex(navIndex); - next(); - } else { - const getRouteNav = routeNavMap.find((item) => item[0](to.name)); - getRouteNav ? getRouteNav[1]() : next({ path: `${SITE_URL}my-perm` }); } - // next({ path: `${SITE_URL}my-perm` }); - } else { next(); + // next({ path: `${SITE_URL}${defaultRoute[navIndex]}` }); } + } else { + next(); } } } else { @@ -272,14 +274,58 @@ export const beforeEach = async (to, from, next) => { [(name) => !getNavRouterDiff(0).includes(name), () => next()], [(name) => ['ratingManager'].includes(name), () => next({ path: `${SITE_URL}${to.fullPath}` })] ]; - if (navIndex > 0) { - await getManagerInfo(); - navDiffMenuIndex(navIndex); - next(); - } else { - const getRouteNav = routeNavMap.find((item) => item[0](to.name)); - getRouteNav ? getRouteNav[1]() : next({ path: `${SITE_URL}my-perm` }); + const getRouteNav = routeNavMap.find((item) => item[0](to.name)); + if (getRouteNav) { + getRouteNav[1](); + return; + } + if (isManagerPage) { + const superData = curRoleList.find((v) => ['super_manager'].includes(v.type)); + const managerData = curRoleList.find((v) => !['staff'].includes(v.type)); + const isAudit = !getNavRouterDiff(2).includes(to.name); + const isPlatForm = !getNavRouterDiff(3).includes(to.name); + // 如果跳转的页面必须是超管身份才能访问 + if (superData && (isAudit || isPlatForm)) { + const { id } = superData; + [currentRoleId, curRoleId] = [id, id]; + navDiffMenuIndex(isAudit ? 2 : 3); + await getManagerInfo(); + next(); + return; + } + // 如果跳转的页面只需要是管理员即可访问 + if (managerData) { + const { type } = managerData; + let isManageSpace = false; + let curManagerData = {}; + isManageSpace = !getRouterDiff(type).includes(to.name); + curManagerData = Object.assign({}, managerData); + // 没找到这个页面也可能是管理空间导航栏下页面限制了具体管理员身份才能访问 + const systemManagerData = curRoleList.find((v) => ['system_manager'].includes(v.type)); + const ratingManagerData = curRoleList.find((v) => ['rating_manager'].includes(v.type)); + const subSetManager = curRoleList.find((v) => ['subset_manager'].includes(v.type)); + if (systemManagerData && !isManageSpace) { + curManagerData = Object.assign({}, systemManagerData); + isManageSpace = !getRouterDiff(systemManagerData.type).includes(to.name); + } + if (ratingManagerData && !isManageSpace) { + curManagerData = Object.assign({}, ratingManagerData); + isManageSpace = !getRouterDiff(ratingManagerData.type).includes(to.name); + } + if (subSetManager && !isManageSpace) { + curManagerData = Object.assign({}, subSetManager); + isManageSpace = !getRouterDiff(ratingManagerData.type).includes(to.name); + } + if (isManageSpace && curManagerData.id) { + [currentRoleId, curRoleId] = [curManagerData.id, curManagerData.id]; + navDiffMenuIndex(1); + await getManagerInfo(); + next(); + return; + } + } } + // getRouteNav ? getRouteNav[1]() : next({ path: `${SITE_URL}my-perm` }); } } else { if (['groupPermRenewal', 'userGroup', 'userGroupDetail', 'createUserGroup', 'userGroupPermDetail'].includes(to.name)) { @@ -296,21 +342,8 @@ export const beforeEach = async (to, from, next) => { } // next(); } else { - const noFrom = !from.name; if (['permTemplateDetail', 'permTemplateEdit', 'permTemplateDiff'].includes(to.name) && noFrom) { next({ path: `${SITE_URL}perm-template` }); - // } else if (['createUserGroup'].includes(to.name)) { - // if (noFrom) { - // if (existValue('externalApp')) { - // next(); - // } else { - // next({ path: `${SITE_URL}${defaultRoute[navIndex]}` }); - // } - // } else { - // next(); - // } - // } else if (['myPerm'].includes(to.name)) { - // next(); } else { next(); } diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index 7a0603fc7..2e16120b8 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -259,14 +259,6 @@ const currentNav = [ path: `${SITE_URL}rating-manager`, disabled: false }, - // { - // icon: 'grade-admin', - // id: 'firstManageSpaceNav', - // rkey: 'firstManageSpace', - // name: il8n('nav', '一级管理空间'), - // path: `${SITE_URL}first-manage-space`, - // disabled: false - // }, { icon: 'perm-manage', name: il8n('common', '设置'), @@ -774,7 +766,7 @@ const store = new Vuex.Store({ commit('updateIndex', 0); } state.index = state.index || Number(window.localStorage.getItem('index')); - if (state.index && state.index > 1) { + if (state.index !== 1) { commit('updataNavRouterDiff', state.index); } else { commit('updataRouterDiff', role); diff --git a/frontend/src/views/my-manage-space/create/index.vue b/frontend/src/views/my-manage-space/create/index.vue index 7de196cca..54787f66e 100644 --- a/frontend/src/views/my-manage-space/create/index.vue +++ b/frontend/src/views/my-manage-space/create/index.vue @@ -204,7 +204,6 @@ import GradePolicy from '@/model/grade-policy'; import Condition from '@/model/condition'; export default { - name: 'firstManageSpaceCreate', components: { IamGuide, basicInfo,