侧边栏权限数据筛选模拟

let pageRouter = [
    {
        path: '/place/placeCenter',
        name: 'placeCenter',
        meta: {
            title: '场所中心',
            icon: 'el-icon-location'
        },
        redirect: '/place/sceneManagement',
         
        children: [
            {
                path: '/place/sceneManagement',
                name: 'sceneManagement',
                meta: {
                    title: '场景管理',
                    isRoot: true,
                    notShowChildren: true
                },
                component:' SceneList'
            },
            {
                path: '/place/buildingManagement',
                name: 'buildingManagement',
                meta: {
                    title: '场所管理',
                    isRoot: true,
                    notShowChildren: true
                },
                component: 'RouteReplaceSelf(BuildingManagementList)',
                children: [
                    {
                        path: '/place/addBuilding',
                        name: 'addBuilding',
                        meta: {
                            title: '新增场所',
                            prevLevel: 'buildingManagement',
                            notShowInMenu: true
                        },
                        component:' AddBuilding',
                    },
                    {
                        path: '/place/placeDetail',
                        name: 'placeDetail',
                        meta: {
                            title: '场所详情',
                            notShowInMenu: true,
                            prevLevel: 'buildingManagement'
                        },
                        component: 'SupspaceList',
                    }
                ]
            }
        ]
    },

    {
        path: '/place/locationCenter',
        name: 'locationCenter',
        meta: {
            title: '位置中心',
            icon: 'el-icon-location'
        },
        redirect: '/place/trajectoryTracking',
         
        children: [
            {
                path: '/place/trajectoryTracking',
                name: 'trajectoryTracking',
                meta: {
                    title: '轨迹跟踪',
                    isRoot: true,
                    notShowChildren: true
                },
                component: 'TrajectoryTracking'
            },
            {
                path: '/place/drawMap',
                name: 'drawMap',
                meta: {
                    title: '绘制地图',
                    isRoot: true,
                    notShowChildren: true
                },
                component: 'DrawMap'
            },
            {
                path: '/place/pathPlanning',
                name: 'pathPlanning',
                meta: {
                    title: '路线规划',
                    isRoot: true,
                    notShowChildren: true
                },
                component:' PathPlanning'
            },
            {
                path: '/place/goodsTransport',
                name: 'goodsTransport',
                meta: {
                    title: '危货运输',
                    isRoot: true,
                    notShowChildren: true
                },
                component:' GoodsTransport'
            },
            {
                path: '/place/electronicFence',
                name: 'electronicFence',
                meta: {
                    title: '电子围栏',
                    isRoot: true,
                    notShowChildren: true
                },
                component: 'RouteReplaceSelf(ElectronicFence)',
                children: [
                    {
                        path: '/place/addFence',
                        name: 'addFence',
                        meta: {
                            title: '新增电子围栏',
                            prevLevel: 'electronicFence',
                            notShowInMenu: true
                        },
                        component:' AddFence',
                    }
                ]
            },
            {
                path: '/place/standardAddressLibrary',
                name: 'standardAddressLibrary',
                meta: {
                    title: '标准地址库',
                },
                redirect: '/place/buildingSupervise',
                
                children: [
                    {
                        path: '/place/buildingSupervise',
                        name: 'buildingSupervise',
                        meta: {
                            title: '楼栋管理',
                            isRoot: true,
                            notShowChildren: true
                        },
                        component:' StandardManage '//标准管理
                    },
                    {
                        path: '/place/villageSupervise',
                        name: 'villageSupervise',
                        meta: {
                            title: '小区管理',
                            isRoot: true,
                            notShowChildren: true
                        },
                        component: 'StandardManage'
                    },
                    {
                        path: '/place/streetSupervise',
                        name: 'streetSupervise',
                        meta: {
                            title: '街道管理',
                            isRoot: true,
                            notShowChildren: true
                        },
                        component: 'StandardManage'
                    }
                ]
            }
        ]
    },
    {
        path: '/place/systemManagement',
        name: 'systemManagement',
        meta: {
            title: '系统管理',
            icon: 'el-icon-location'
        },
        redirect: '/place/systemLog',
         
        children: [
            {
                path: '/place/systemLog',
                name: 'systemLog',
                meta: {
                    title: '系统日志',
                    isRoot: true,
                    notShowChildren: true
                },
                component: 'SystemLog,'
            },
        ]
    }
]

let data = [
    {
        "level": 0, //级别
        "resDesc": "string",
        "resId": "string",
        "resKey": "string",
        "resName": "systemManagement",  //名字
        "resType": "string",
        "rsrv1": "string",
        "subMenu": [
            {}
        ],
        "url": "string"
    },
    {
        "level": 0, //级别
        "resDesc": "string",
        "resId": "string",
        "resKey": "string",
        "resName": "locationCenter",  //名字
        "resType": "string",
        "rsrv1": "string",
        "subMenu": [
            {}
        ],
        "url": "string"
    }
];
let result=authMenu(pageRouter,data);
function authMenu(localRouter, interfaceRouter){
    if (Array.isArray(localRouter) && Array.isArray(interfaceRouter)) {
        return localRouter.filter((item) => {
            return interfaceRouter.find((v) => v.resName=== item.name)
       })
   }
}

console.log(result)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容