getters.ts 2.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
/**
 * 判断指定统一资源是否存在
 * 
 * @param state 
 */
 export const getResourceData = (state: any) => (resourcetag: string) => {
    let itemIndex: any = state.resourceData.findIndex((unirescode: any, objIndex: any, objs: any) => {
        return Object.is(unirescode, resourcetag);
    })
    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;
}

/**
 * 获取是否开启权限认证
 * 
 * @param state 
 */
export const getEnablePermissionValid = (state: any) => {
    return state.enablePermissionValid;
}

/**
 * 判断指定菜单是否显示(混合模式)
 * 
 * @param state 
 */
 export const getAuthMenu = (state: any) => (menu: any) => {
    if (state.enablePermissionValid) {
        let resourceIndex: any;
        let menuIndex: any;
        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;
    } else {
        return true;
    }
}

/**
 * 判断指定菜单是否显示(资源模式)
 * 
 * @param state 
 */
export const getAuthMenuWithResource = (state: any) => (menu: any) => {
    if (state.enablePermissionValid && menu.resourcetag) {
        let resourceIndex: any;
        resourceIndex = state.resourceData.findIndex((resourcetag: any, objIndex: any, objs: any) => {
            return Object.is(menu.resourcetag, resourcetag);
        })
        return resourceIndex !== -1 ? true : false;
    } else {
        return true;
    }
}

/**
 * 判断指定菜单是否显示(RT模式)
 * 
 * @param state 
 */
export const getAuthMenuWithRT = (state: any) => (menu: any) => {
    if (state.enablePermissionValid) {
        let menuIndex: any;
        menuIndex = state.menuData.findIndex((menutag: any, objIndex: any, objs: any) => {
            return Object.is(menu.authtag, menutag);
        })
        return menuIndex !== -1 ? true : false;
    } else {
        return true;
    }
}

/**
 * 获取实体权限数据
 * 
 * @param state 
 */
 export const getSrfappdeData = (state: any) => (key: string) => {
    return state.srfappdeData[key];
}