提交 9faa9c8f 编写于 作者: tony001's avatar tony001

补充菜单权限

上级 66dbb43b
...@@ -4,10 +4,13 @@ ...@@ -4,10 +4,13 @@
* @param param0 * @param param0
* @param data * @param data
*/ */
export const commitResourceData = ({ commit, state }: { commit: any, state: any }, { unires, enablepermissionvalid }: { unires: Array<any>, enablepermissionvalid: boolean }) => { export const commitAuthData = ({ commit, state }: { commit: any, state: any }, { unires,appmenu,enablepermissionvalid }: { unires: Array<any>, appmenu: Array<any>, enablepermissionvalid: boolean }) => {
if(unires && unires.length > 0){ if(unires && unires.length > 0){
commit('setResourceData', unires); commit('setResourceData', unires);
} }
if(appmenu && appmenu.length >0){
commit('setMenuData', appmenu);
}
if(enablepermissionvalid){ if(enablepermissionvalid){
commit('setEnablePermissionValid', enablepermissionvalid); commit('setEnablePermissionValid', enablepermissionvalid);
} }
......
...@@ -10,6 +10,18 @@ export const getResourceData = (state: any) => (resourcetag: string) => { ...@@ -10,6 +10,18 @@ export const getResourceData = (state: any) => (resourcetag: string) => {
return itemIndex === -1 ? false : true; return itemIndex === -1 ? false : true;
} }
/**
* 判断指定菜单权限是否存在
*
* @param state
*/
export const getMenuData = (state: any) => (menutag: string) => {
let itemIndex: any = state.menuData.findIndex((menucode: any, objIndex: any, objs: any) => {
return Object.is(menucode, menutag);
})
return itemIndex === -1 ? false : true;
}
/** /**
* 获取是否开启权限认证 * 获取是否开启权限认证
* *
...@@ -18,3 +30,23 @@ export const getResourceData = (state: any) => (resourcetag: string) => { ...@@ -18,3 +30,23 @@ export const getResourceData = (state: any) => (resourcetag: string) => {
export const getEnablePermissionValid = (state: any) => { export const getEnablePermissionValid = (state: any) => {
return state.enablePermissionValid; return state.enablePermissionValid;
} }
/**
* 判断指定菜单是否显示
*
* @param state
*/
export const getAuthMenu = (state: any) => (menu:any) =>{
// 存在权限
let resourceIndex: any;
let menuIndex:any;
if(state.enablePermissionValid){
resourceIndex= state.resourceData.findIndex((resourcetag: any, objIndex: any, objs: any) => {
return Object.is(menu.resourcetag, resourcetag);
})
}
menuIndex= state.menuData.findIndex((menutag: any, objIndex: any, objs: any) => {
return Object.is(menu.authtag, menutag);
})
return (resourceIndex !== -1 && menuIndex !== -1)?true:false;
}
\ No newline at end of file
...@@ -11,6 +11,19 @@ export const setResourceData = (state: any, resourceArray:Array<any>) => { ...@@ -11,6 +11,19 @@ export const setResourceData = (state: any, resourceArray:Array<any>) => {
state.resourceData = resourceArray; state.resourceData = resourceArray;
} }
/**
* 设置菜单数据
*
* @param state
* @param resourceArray
*/
export const setMenuData = (state: any, menuArray:Array<any>) => {
if(menuArray && menuArray.length === 0){
return;
}
state.menuData = menuArray;
}
/** /**
* 设置是否开启权限认证 * 设置是否开启权限认证
* *
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
export const resourcestate: any = { export const resourcestate: any = {
// 统一资源数据 // 统一资源数据
resourceData: [], resourceData: [],
// 菜单数据
menuData:[],
// 是否开启权限认证 // 是否开启权限认证
enablePermissionValid: false enablePermissionValid: false
} }
\ No newline at end of file
...@@ -67,7 +67,7 @@ export class AuthGuard { ...@@ -67,7 +67,7 @@ export class AuthGuard {
} }
router.app.$store.commit('addAppData', data); router.app.$store.commit('addAppData', data);
// 提交统一资源数据 // 提交统一资源数据
router.app.$store.dispatch('authresource/commitResourceData', data); router.app.$store.dispatch('authresource/commitAuthData', data);
} }
} }
resolve(true); resolve(true);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册