getters.ts 1.5 KB
Newer Older
1 2 3 4 5 6
/**
 * 判断指定统一资源是否存在
 * 
 * @param state 
 */
export const getResourceData = (state: any) => (resourcetag: string) => {
tony001's avatar
tony001 committed
7 8
    let itemIndex: any = state.resourceData.findIndex((unirescode: any, objIndex: any, objs: any) => {
        return Object.is(unirescode, resourcetag);
9 10 11 12
    })
    return itemIndex === -1 ? false : true;
}

tony001's avatar
tony001 committed
13 14 15 16 17 18 19 20 21 22 23 24
/**
 * 判断指定菜单权限是否存在
 * 
 * @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;
}

25 26 27 28 29 30 31
/**
 * 获取是否开启权限认证
 * 
 * @param state 
 */
export const getEnablePermissionValid = (state: any) => {
    return state.enablePermissionValid;
tony001's avatar
tony001 committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
}

/**
 * 判断指定菜单是否显示
 * 
 * @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);
        })
47 48 49 50 51 52
        menuIndex= state.menuData.findIndex((menutag: any, objIndex: any, objs: any) => {
            return Object.is(menu.authtag, menutag);
        })
        return (resourceIndex !== -1 || menuIndex !== -1)?true:false;
    }else{
        return true;
tony001's avatar
tony001 committed
53
    }
54
}