diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index 78d14eea5..a8c000aa4 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -35,69 +35,28 @@ function hasPermission(roles, route, parentsRoles) { */ function resetAsyncRouter({ systemType }) { let list = publicAsyncRoute; - if (systemType == projectTrain) { + const projectList = [projectTrain, projectXian, projectJyd, projectTky, projectDrts, projectRichor]; + const specialProjects = [projectXty, projectGzzb, projectHeb, projectSdy, projectRichorJoint]; + const specialProjectEnum = {[projectXty]:'designxty', [projectGzzb]:'designgzb', [projectHeb]:'designheb', + [projectSdy]:'designsdy', [projectRichorJoint]:'designrichorjoint' }; + if (projectList.includes(systemType)) { list = [...list, ...asyncRouter]; - } else if (systemType == projectXian) { - list = [...list, ...asyncRouter]; - } else if (systemType == projectXty) { - if (projectRoute && projectRoute.designxty && projectRoute.designxty.length) { - projectRoute.designxty.forEach(item => { - if (item.merge) { - asyncRouter[item.mergeIndex].children = [...asyncRouter[item.mergeIndex].children, ...item.children]; - } else { - list.push(item); - } - }); - } - list = [...list, ...asyncRouter]; - } else if (systemType == projectGzzb) { - if (projectRoute && projectRoute.designgzb && projectRoute.designgzb.length) { - projectRoute.designgzb.forEach(item => { - if (item.merge) { - asyncRouter[item.mergeIndex].children = [...asyncRouter[item.mergeIndex].children, ...item.children]; - } else { - list.push(item); - } - }); - } - list = [...list, ...asyncRouter]; - } else if (systemType == projectHeb) { - if (projectRoute && projectRoute.designheb && projectRoute.designheb.length) { - projectRoute.designheb.forEach(item => { - if (item.merge) { - asyncRouter[item.mergeIndex].children = [...asyncRouter[item.mergeIndex].children, ...item.children]; - } else { list.push(item); } - }); + } else if (specialProjects.includes(systemType) ) { + if (projectRoute) { + const proRoute = projectRoute[specialProjectEnum[systemType]]; + if (proRoute && proRoute.length) { + proRoute.forEach(item => { + if (item.merge) { + asyncRouter[item.mergeIndex].children = [...asyncRouter[item.mergeIndex].children, ...item.children]; + } else { + list.push(item); + } + }); + } } list = [...list, ...asyncRouter]; } else if (systemType == projectJsxt) { list = [...list, ...JSXT]; - } else if (systemType == projectJyd) { - list = [...list, ...asyncRouter]; - } else if (systemType == projectTky) { - list = [...list, ...asyncRouter]; - } else if (systemType == projectDrts) { - list = [...list, ...asyncRouter]; - } else if (systemType == projectRichor) { - list = [...list, ...asyncRouter]; - } else if (systemType == projectSdy) { - if (projectRoute && projectRoute.designsdy && projectRoute.designsdy.length) { - projectRoute.designsdy.forEach(item => { - if (item.merge) { - asyncRouter[item.mergeIndex].children = [...asyncRouter[item.mergeIndex].children, ...item.children]; - } else { list.push(item); } - }); - } - list = [...list, ...asyncRouter]; - } else if (systemType == projectRichorJoint) { - if (projectRoute && projectRoute.designrichorjoint && projectRoute.designrichorjoint.length) { - projectRoute.designrichorjoint.forEach(item => { - if (item.merge) { - asyncRouter[item.mergeIndex].children = [...asyncRouter[item.mergeIndex].children, ...item.children]; - } else { list.push(item); } - }); - } - list = [...list, ...asyncRouter]; } return list; }