| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- export function hasPriv(code) {
- let privObj = JSON.parse(sessionStorage.getItem('privItem'));
- let result = hasPermission(privObj, code);
- return result;
- }
- function hasPermission(privItem, code) {
- if (code == privItem.code) {
- return true;
- } else {
- if (privItem.privList.length && privItem.privList.length > 0) {
- for (var index = 0; index < privItem.privList.length; index++) {
- var result = hasPermission(privItem.privList[index], code);
- if (result) {
- return true;
- }
- }
- }
- }
- return false;
- }
- export function hasMenu(router) {
- let list = []
- let privCollect = JSON.parse(sessionStorage.getItem('privCollect'))
- if(privCollect){
- hasMenuList(list,privCollect)
- if(router.fullPath && list.length>0){
- return list.indexOf(removeURLParams(router.fullPath))>-1
- }else{
- return false
- }
- }else{
- return true;
- }
- }
- export function hasMenuList(list,privCollect) {
- if(privCollect && privCollect.length>0){
- privCollect.forEach((item,index)=>{
- if(item.flagLeaf==="1" && item.privUri){
- list.push(item.privUri)
- }
- if(item.privList && item.privList.length>0){
- hasMenuList(list,item.privList)
- }
- })
- }
- }
- export function removeURLParams(url) {
- const index = url.indexOf('?');
- if (index !== -1) {
- return url.substr(0, index);
- }
- return url;
- }
|