diff --git a/report-ui/src/mixins/access.js b/report-ui/src/mixins/access.js index 894819b4..db9e7af4 100644 --- a/report-ui/src/mixins/access.js +++ b/report-ui/src/mixins/access.js @@ -33,49 +33,29 @@ export default { destroyed () { }, methods: { - hasPermission (permissionStr, orgIds) { - //判断用户权限列表是否为空 - if (this.opAuthorities == null) { - return false - } - if (permissionStr && permissionStr.indexOf('|') !== -1) { - let flag = false - let arr = permissionStr.split('|') - for (let i = 0; i < arr.length; i++) { - let a = arr[i].replace(/(^\s*)|(\s*$)/g, ""); - if (this.opAuthorities.hasOwnProperty(a)) { - flag = true - } - } - return flag + hasPermission (permissionStr) { + if (permissionStr == null || permissionStr.length == 0) { + return true } - //登录用户没有某个操作权限 - if (!this.opAuthorities.hasOwnProperty(permissionStr)) { + // 登录用户权限列表 + if (this.opAuthorities == null) { return false } - //如果当前验证,不包含项目级别验证,直接返回 - if (typeof (orgIds) == 'undefined' || orgIds == null) { - return true - } - //验证登录用户是否有某个项目的有操作权限 - var orgIdsHasPermission = this.opAuthorities[permissionStr] - //如果projectIds是个数字,只要验证登录用户是否有该项目的操作权限 - if (typeof orgIds == 'number') { - if (orgIdsHasPermission.indexOf(orgIds) > -1) { + // 用户有的全部权限码 + var opAuthoritiesStr = JSON.stringify(this.opAuthorities) + + // permissionStr可能是:authorityManage、authorityManage:insert、authorityManage:insert|authorityManage:update + var needPermissionArray = permissionStr.split('|') + for (var i = 0; i < needPermissionArray.length; i++) { + // 只要有其中的一个权限,就返回true + var needPermission = needPermissionArray[i] // authorityManage、authorityManage:insert + needPermission = needPermission.replace(/\ /g, "") // 去除authorityManage : insert中:前后的空格 + + if(opAuthoritiesStr.indexOf(needPermission)>=0){ return true - } else { - return false - } - } else { - var result = false - for (var i in orgIdsHasPermission) { - var flag = orgIds.indexOf(orgIdsHasPermission[i]) > -1 - if (flag) { - result = true - } } - return result } + return false }, } } diff --git a/report-ui/src/router/index.js b/report-ui/src/router/index.js index a93a416d..55190ad2 100644 --- a/report-ui/src/router/index.js +++ b/report-ui/src/router/index.js @@ -28,31 +28,31 @@ import Layout from '../views/layout/Layout' export const constantRouterMap = [ { path: '/login', component: () => import('@/views/login'), hidden: true }, { - path: '/index', component: Layout, redirect: '/access/accessAuthority', name: '首页', meta: { title: '首页', icon: 'iconhome2' }, + path: '/index', component: Layout, name: 'index', meta: { title: '首页', icon: 'iconhome2' }, children: [ - { path: '', name: 'accessUser', component: () => import('@/views/home/index'), meta: { title: '首页', icon: 'iconhome2', keepAlive: true, isBack: true, requireAuth: true } }, + { path: '', component: () => import('@/views/home/index'), meta: { title: '首页', icon: 'iconhome2', keepAlive: true, requireAuth: true } }, ] }, { - path: '/access', component: Layout, name: 'access', meta: { title: '用户权限', icon: 'icondfzq-' }, + path: '/access', name: 'access', component: Layout, meta: { title: '用户权限', icon: 'icondfzq-', requireAuth: true, permission: 'authorityManage|roleManage|userManage' }, children: [ - { path: 'authority', name: 'authority', component: () => import('@/views/accessAuthority/index'), meta: { title: '权限管理', icon: 'iconquanxian', keepAlive: true, isBack: true } }, - { path: 'role', name: 'role', component: () => import('@/views/accessRole/index'), meta: { title: '角色管理', icon: 'iconjiaose1', keepAlive: true, isBack: true } }, - { path: 'user', name: 'user', component: () => import('@/views/accessUser/index'), meta: { title: '用户管理', icon: 'iconyonghu', keepAlive: true, isBack: true } }, + { path: 'authority', name: 'authority', component: () => import('@/views/accessAuthority/index'), meta: { title: '权限管理', icon: 'iconquanxian', keepAlive: true, requireAuth: true, permission: 'authorityManage'} }, + { path: 'role', name: 'role', component: () => import('@/views/accessRole/index'), meta: { title: '角色管理', icon: 'iconjiaose1', keepAlive: true, requireAuth: true, permission: 'roleManage'} }, + { path: 'user', name: 'user', component: () => import('@/views/accessUser/index'), meta: { title: '用户管理', icon: 'iconyonghu', keepAlive: true, requireAuth: true, permission: 'userManage'} }, ] }, { - path: '/report', component: Layout, name: '报表设计', meta: { title: '报表设计', icon: 'iconnavicon-ywcs' }, + path: '/report', name: 'report', component: Layout, meta: { title: '报表设计', icon: 'iconnavicon-ywcs', requireAuth: true, permission: 'datasourceManage|resultsetManage|reportManage|bigScreenManage' }, children: [ - { path: 'datasource', name: 'datasource', component: () => import('@/views/report/datasource/index'), meta: { title: '数据源', icon: 'iconeventbridgexiaoxishijianzongxian', keepAlive: true, isBack: true } }, - { path: 'resultset', name: 'resultset', component: () => import('@/views/report/resultset/index'), meta: { title: '数据集', icon: 'iconalikafkaxiaoxiduilieKafka', keepAlive: true, isBack: true } }, - { path: 'report', name: 'reportIndex', component: () => import('@/views/report/report/index'), meta: { title: '报表管理', icon: 'iconnavicon-ywcs', keepAlive: true, isBack: true } }, - { path: 'bigscreen', name: 'bigscreen', component: () => import('@/views/report/bigscreen/index'), meta: { title: '大屏报表', icon: 'iconchufaqipeizhi-hui', keepAlive: true, isBack: true }, }, - //{ path: 'excelreport', name: 'excelreport', component: () => import('@/views/report/excelreport/index'), meta: { title: '表格报表', icon: 'iconliebiao', keepAlive: true, isBack: true } }, + { path: 'datasource', name: 'datasource', component: () => import('@/views/report/datasource/index'), meta: { title: '数据源', icon: 'iconeventbridgexiaoxishijianzongxian', keepAlive: true, requireAuth: true, permission: 'datasourceManage'} }, + { path: 'resultset', name: 'resultset', component: () => import('@/views/report/resultset/index'), meta: { title: '数据集', icon: 'iconalikafkaxiaoxiduilieKafka', keepAlive: true, requireAuth: true, permission: 'resultsetManage'} }, + { path: 'report', name: 'reportIndex', component: () => import('@/views/report/report/index'), meta: { title: '报表管理', icon: 'iconnavicon-ywcs', keepAlive: true, requireAuth: true, permission: 'reportManage'} }, + { path: 'bigscreen', name: 'bigscreen', component: () => import('@/views/report/bigscreen/index'), meta: { title: '大屏报表', icon: 'iconchufaqipeizhi-hui', keepAlive: true, requireAuth: true, permission: 'bigScreenManage'}, }, + //{ path: 'excelreport', name: 'excelreport', component: () => import('@/views/report/excelreport/index'), meta: { title: '表格报表', icon: 'iconliebiao', keepAlive: true, requireAuth: true, permission: 'excelManage'} }, ] }, - { path: '/bigscreen/viewer', component: () => import('@/views/report/bigscreen/viewer'), hidden: true }, - { path: '/bigscreen/designer', component: () => import('@/views/report/bigscreen/designer'), hidden: true }, + { path: '/bigscreen/viewer', component: () => import('@/views/report/bigscreen/viewer'), hidden: true, meta: { requireAuth: true }}, + { path: '/bigscreen/designer', component: () => import('@/views/report/bigscreen/designer'), hidden: true, meta: { requireAuth: true }}, { path: '/404', component: () => import('@/views/404'), hidden: true }, { path: '*', redirect: '/login', hidden: true }, /* diff --git a/report-ui/src/views/layout/components/Sidebar/SidebarItem.vue b/report-ui/src/views/layout/components/Sidebar/SidebarItem.vue index d6983750..1f273ec3 100644 --- a/report-ui/src/views/layout/components/Sidebar/SidebarItem.vue +++ b/report-ui/src/views/layout/components/Sidebar/SidebarItem.vue @@ -1,52 +1,32 @@ @@ -64,20 +44,20 @@ export default { // route object item: { type: Object, - required: true + required: true, }, isNest: { type: Boolean, - default: false + default: false, }, basePath: { type: String, - default: '' - } + default: '', + }, }, - data () { + data() { return { - onlyOneChild: null + onlyOneChild: null, } }, computed: { @@ -89,8 +69,8 @@ export default { // } }, methods: { - hasOneShowingChild (children, parent) { - const showingChildren = children.filter(item => { + hasOneShowingChild(children, parent) { + const showingChildren = children.filter((item) => { if (item.hidden) { return false } else { @@ -112,16 +92,16 @@ export default { return false }, - resolvePath (routePath) { + resolvePath(routePath) { if (this.isExternalLink(routePath)) { return routePath } return path.resolve(this.basePath, routePath) }, - isExternalLink (routePath) { + isExternalLink(routePath) { return isExternal(routePath) - } - } + }, + }, }