From 74c87d8d29dd8492d68af6a433d72571abb6e89f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Fri, 18 Jun 2021 21:25:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B5=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=A4=9A=E4=BD=99=E7=9A=84=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jshERP-web/src/components/menu/index.js | 4 +- .../src/components/page/GlobalLayout.vue | 8 +- jshERP-web/src/store/modules/permission.js | 2 +- jshERP-web/src/utils/hasPermission.js | 240 +++++++++--------- jshERP-web/src/utils/request.js | 2 +- 5 files changed, 128 insertions(+), 128 deletions(-) diff --git a/jshERP-web/src/components/menu/index.js b/jshERP-web/src/components/menu/index.js index facafb82..8c41c241 100644 --- a/jshERP-web/src/components/menu/index.js +++ b/jshERP-web/src/components/menu/index.js @@ -103,8 +103,8 @@ export default { return null }, renderMenuItem (menu) { - // const target = menu.meta.target || null - // const tag = target && 'a' || 'router-link' + const target = null + const tag = target && 'a' || 'router-link' let props = { to: { name: menu.name } } if(menu.route && menu.route === '0'){ props = { to: { path: menu.path } } diff --git a/jshERP-web/src/components/page/GlobalLayout.vue b/jshERP-web/src/components/page/GlobalLayout.vue index e5fca5c2..d3b847ba 100644 --- a/jshERP-web/src/components/page/GlobalLayout.vue +++ b/jshERP-web/src/components/page/GlobalLayout.vue @@ -132,10 +132,10 @@ //this.menus = this.mainRouters.find((item) => item.path === '/').children; this.menus = this.permissionMenuList // 根据后台配置菜单,重新排序加载路由信息 - console.log('----加载菜单逻辑----') - console.log(this.mainRouters) - console.log(this.permissionMenuList) - console.log('----navTheme------'+this.navTheme) + //console.log('----加载菜单逻辑----') + //console.log(this.mainRouters) + //console.log(this.permissionMenuList) + //console.log('----navTheme------'+this.navTheme) //--update-end----author:scott---date:20190320------for:根据后台菜单配置,判断是否路由菜单字段,动态选择是否生成路由(为了支持参数URL菜单)------ }, methods: { diff --git a/jshERP-web/src/store/modules/permission.js b/jshERP-web/src/store/modules/permission.js index 85f0b356..6f6e42fc 100644 --- a/jshERP-web/src/store/modules/permission.js +++ b/jshERP-web/src/store/modules/permission.js @@ -58,7 +58,7 @@ const permission = { }, mutations: { SET_ROUTERS: (state, data) => { - console.log('-----mutations---SET_ROUTERS----', data) + //console.log('-----mutations---SET_ROUTERS----', data) state.addRouters = data state.routers = constantRouterMap.concat(data) // console.log('-----mutations last ---SET_ROUTERS----', state.routers) diff --git a/jshERP-web/src/utils/hasPermission.js b/jshERP-web/src/utils/hasPermission.js index 8ba34f75..6eadab67 100644 --- a/jshERP-web/src/utils/hasPermission.js +++ b/jshERP-web/src/utils/hasPermission.js @@ -1,120 +1,120 @@ -import { USER_AUTH,SYS_BUTTON_AUTH } from "@/store/mutation-types" - -const hasPermission = { - install (Vue, options) { - console.log(options); - Vue.directive('has', { - inserted: (el, binding, vnode)=>{ - console.log("页面权限控制----"); - //console.time() - //节点权限处理,如果命中则不进行全局权限处理 - if(!filterNodePermission(el, binding, vnode)){ - filterGlobalPermission(el, binding, vnode); - } - //console.timeEnd() //计时结束并输出时长 - } - }); - } -}; - -/** - * 流程节点权限控制 - */ -export function filterNodePermission(el, binding, vnode) { - let permissionList = []; - try { - let obj = vnode.context.$props.formData; - if (obj) { - let bpmList = obj.permissionList; - for (let bpm of bpmList) { - if(bpm.type != '2') { - permissionList.push(bpm); - } - } - }else{ - return false; - } - } catch (e) { - //console.log("页面权限异常----", e); - } - if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) { - //el.parentNode.removeChild(el) - return false; - } - - console.log("流程节点页面权限--NODE--"); - let permissions = []; - for (let item of permissionList) { - if(item.type != '2') { - permissions.push(item.action); - } - } - //console.log("页面权限----"+permissions); - //console.log("页面权限----"+binding.value); - if (!permissions.includes(binding.value)) { - //el.parentNode.removeChild(el) - return false; - }else{ - for (let item2 of permissionList) { - if(binding.value === item2.action){ - return true; - } - } - } - return false; -} - -/** - * 全局权限控制 - */ -export function filterGlobalPermission(el, binding, vnode) { - console.log("全局页面权限--Global--"); - - let permissionList = []; - let allPermissionList = []; - - //let authList = Vue.ls.get(USER_AUTH); - let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]"); - for (let auth of authList) { - if(auth.type != '2') { - permissionList.push(auth); - } - } - //console.log("页面权限--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH)); - let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || "[]"); - for (let gauth of allAuthList) { - if(gauth.type != '2') { - allPermissionList.push(gauth); - } - } - //设置全局配置是否有命中 - let invalidFlag = false;//无效命中 - if(allPermissionList != null && allPermissionList != "" && allPermissionList != undefined && allPermissionList.length > 0){ - for (let itemG of allPermissionList) { - if(binding.value === itemG.action){ - if(itemG.status == '0'){ - invalidFlag = true; - break; - } - } - } - } - if(invalidFlag){ - return; - } - if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) { - el.parentNode.removeChild(el); - return; - } - let permissions = []; - for (let item of permissionList) { - if(item.type != '2'){ - permissions.push(item.action); - } - } - if (!permissions.includes(binding.value)) { - el.parentNode.removeChild(el); - } -} - -export default hasPermission; +import { USER_AUTH,SYS_BUTTON_AUTH } from "@/store/mutation-types" + +const hasPermission = { + install (Vue, options) { + //console.log(options); + Vue.directive('has', { + inserted: (el, binding, vnode)=>{ + console.log("页面权限控制----"); + //console.time() + //节点权限处理,如果命中则不进行全局权限处理 + if(!filterNodePermission(el, binding, vnode)){ + filterGlobalPermission(el, binding, vnode); + } + //console.timeEnd() //计时结束并输出时长 + } + }); + } +}; + +/** + * 流程节点权限控制 + */ +export function filterNodePermission(el, binding, vnode) { + let permissionList = []; + try { + let obj = vnode.context.$props.formData; + if (obj) { + let bpmList = obj.permissionList; + for (let bpm of bpmList) { + if(bpm.type != '2') { + permissionList.push(bpm); + } + } + }else{ + return false; + } + } catch (e) { + //console.log("页面权限异常----", e); + } + if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) { + //el.parentNode.removeChild(el) + return false; + } + + console.log("流程节点页面权限--NODE--"); + let permissions = []; + for (let item of permissionList) { + if(item.type != '2') { + permissions.push(item.action); + } + } + //console.log("页面权限----"+permissions); + //console.log("页面权限----"+binding.value); + if (!permissions.includes(binding.value)) { + //el.parentNode.removeChild(el) + return false; + }else{ + for (let item2 of permissionList) { + if(binding.value === item2.action){ + return true; + } + } + } + return false; +} + +/** + * 全局权限控制 + */ +export function filterGlobalPermission(el, binding, vnode) { + console.log("全局页面权限--Global--"); + + let permissionList = []; + let allPermissionList = []; + + //let authList = Vue.ls.get(USER_AUTH); + let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]"); + for (let auth of authList) { + if(auth.type != '2') { + permissionList.push(auth); + } + } + //console.log("页面权限--Global--",sessionStorage.getItem(SYS_BUTTON_AUTH)); + let allAuthList = JSON.parse(sessionStorage.getItem(SYS_BUTTON_AUTH) || "[]"); + for (let gauth of allAuthList) { + if(gauth.type != '2') { + allPermissionList.push(gauth); + } + } + //设置全局配置是否有命中 + let invalidFlag = false;//无效命中 + if(allPermissionList != null && allPermissionList != "" && allPermissionList != undefined && allPermissionList.length > 0){ + for (let itemG of allPermissionList) { + if(binding.value === itemG.action){ + if(itemG.status == '0'){ + invalidFlag = true; + break; + } + } + } + } + if(invalidFlag){ + return; + } + if (permissionList === null || permissionList === "" || permissionList === undefined||permissionList.length<=0) { + el.parentNode.removeChild(el); + return; + } + let permissions = []; + for (let item of permissionList) { + if(item.type != '2'){ + permissions.push(item.action); + } + } + if (!permissions.includes(binding.value)) { + el.parentNode.removeChild(el); + } +} + +export default hasPermission; diff --git a/jshERP-web/src/utils/request.js b/jshERP-web/src/utils/request.js index 2e1cf67b..87a713f3 100644 --- a/jshERP-web/src/utils/request.js +++ b/jshERP-web/src/utils/request.js @@ -12,7 +12,7 @@ import { ACCESS_TOKEN } from "@/store/mutation-types" * @type {*|string} */ let apiBaseUrl = window._CONFIG['domianURL'] || "/jshERP-boot"; -console.log("apiBaseUrl= ",apiBaseUrl) +//console.log("apiBaseUrl= ",apiBaseUrl) // 创建 axios 实例 const service = axios.create({ baseURL: apiBaseUrl, // api base_url