From 21b279646c2dcd6d3b51b4ea0f0f40ac39caece6 Mon Sep 17 00:00:00 2001 From: joylink_cuiweidong <364937672@qq.com> Date: Thu, 16 Sep 2021 15:02:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E8=BF=87=E6=BB=A4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/permission.js | 75 ++++++++------------------------- 1 file changed, 17 insertions(+), 58 deletions(-) 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; }