From d4ab8daa939334d634c5ccfe2ccac7d61d17a467 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期五, 28 十月 2022 15:07:35 +0800 Subject: [PATCH] 权限菜单加载--未完 --- src/views/layout/components/Menu/index.vue | 220 +++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 172 insertions(+), 48 deletions(-) diff --git a/src/views/layout/components/Menu/index.vue b/src/views/layout/components/Menu/index.vue index 7a0c60f..1dfcb9e 100644 --- a/src/views/layout/components/Menu/index.vue +++ b/src/views/layout/components/Menu/index.vue @@ -5,7 +5,58 @@ <h2 class="siderbar-title">閬傛槍鎵ф硶骞冲彴</h2> <el-scrollbar> <!-- 璺敱 --> - <el-menu router class="el-menu-vertical" :default-active="$route.path" > + <el-menu router class="el-menu-vertical" :default-active="$route.path"> + <!-- <el-submenu + :index="menu.url ? menu.url : menu.id.toString()" + v-for="menu in menuList" + :key="menu.id" + class="firstMenu" + > + <template slot="title"> + <span slot="prefix" class="icon-padding fisrtSpan"> + <svg-icon :icon-class="menu.icon"></svg-icon> + </span> + <span class="fisrtSpan">{{ menu.title }}</span> + </template> + <template v-if="menu.children.length > 0"> + <el-submenu + v-for="secondMenu in menu.children" + :key="secondMenu.id" + :index=" + secondMenu.url ? secondMenu.url : secondMenu.id.toString() + " + class="secondMenu" + > + <template v-if="secondMenu.children.length > 0"> + <template slot="title"> + <span class="secondSpan">{{ secondMenu.title }}</span> + </template> + <el-menu-item + v-for="thirdMenu in secondMenu.children" + :key="thirdMenu.id" + :index="`${thirdMenu.id}`" + :route="{ name: thirdMenu.url }" + >{{ thirdMenu.title }}</el-menu-item + > + </template> + <el-menu-item + v-else + :key="secondMenu.id" + :index="`${secondMenu.id}`" + :route="{ name: secondMenu.url }" + >{{ secondMenu.title }}</el-menu-item + > + </el-submenu> + </template> + + <el-menu-item + v-else + :key="menu.id" + :index="`${menu.id}`" + :route="{ name: menu.url }" + >{{ menu.title }}</el-menu-item + > + </el-submenu> --> <!-- 绯荤粺璁剧疆妯″潡 --> <el-submenu index="/home/system" class="firstMenu"> <template slot="title"> @@ -21,29 +72,47 @@ <span class="secondSpan">鍩烘湰璁剧疆</span> </template> <!-- 鐢ㄦ埛绠$悊 --> - <el-menu-item index="/home/system/userSetting/user">鐢ㄦ埛绠$悊</el-menu-item> + <el-menu-item index="/home/system/userSetting/user" + >鐢ㄦ埛绠$悊</el-menu-item + > <!-- 瑙掕壊绠$悊 --> - <el-menu-item index="/home/system/userSetting/role">瑙掕壊绠$悊</el-menu-item> + <el-menu-item index="/home/system/userSetting/role" + >瑙掕壊绠$悊</el-menu-item + > <!-- 閮ㄩ棬绠$悊 --> - <el-menu-item index="/home/system/userSetting/department">閮ㄩ棬绠$悊</el-menu-item> + <el-menu-item index="/home/system/userSetting/department" + >閮ㄩ棬绠$悊</el-menu-item + > </el-submenu> <!-- 骞冲彴璁剧疆 --> <el-submenu index="/home/system/platform" class="secondMenu"> <template slot="title"> <span class="secondSpan">闂ㄦ埛绠$悊</span> </template> - <el-menu-item index="/home/system/platform/mySetting">鑷畾涔夎彍鍗�</el-menu-item> - <el-menu-item index="/home/system/platform/portalSetting">logo绠$悊</el-menu-item> - <el-menu-item index="/home/system/platform/otherInterface">绗笁鏂规帴鍙g鐞�</el-menu-item> + <el-menu-item index="/home/system/platform/mySetting" + >鑷畾涔夎彍鍗�</el-menu-item + > + <el-menu-item index="/home/system/platform/portalSetting" + >logo绠$悊</el-menu-item + > + <el-menu-item index="/home/system/platform/otherInterface" + >绗笁鏂规帴鍙g鐞�</el-menu-item + > </el-submenu> <!-- 璁惧绠$悊 --> <el-submenu index="/home/system/device" class="secondMenu"> <template slot="title"> <span class="secondSpan">璁惧绠$悊</span> </template> - <el-menu-item index="/home/system/device/bayonet">鍗″彛璁惧绠$悊</el-menu-item> - <el-menu-item index="/home/system/device/point">鐐逛綅绠$悊</el-menu-item> - <el-menu-item index="/home/system/device/grid">缃戞牸绠$悊</el-menu-item> + <el-menu-item index="/home/system/device/bayonet" + >鍗″彛璁惧绠$悊</el-menu-item + > + <el-menu-item index="/home/system/device/point" + >鐐逛綅绠$悊</el-menu-item + > + <el-menu-item index="/home/system/device/grid" + >缃戞牸绠$悊</el-menu-item + > </el-submenu> </el-submenu> <!-- 杩愯惀绠$悊妯″潡 --> @@ -58,26 +127,44 @@ <template slot="title"> <span class="secondSpan">鍩虹璁剧疆</span> </template> - <el-menu-item index="/home/operate/baseSetting/violation">杩濊浜嬮」璁剧疆</el-menu-item> - <el-menu-item index="/home/operate/baseSetting/illegalBuild">杩濆缓浜嬮」璁剧疆</el-menu-item> + <el-menu-item index="/home/operate/baseSetting/violation" + >杩濊浜嬮」璁剧疆</el-menu-item + > + <el-menu-item index="/home/operate/baseSetting/illegalBuild" + >杩濆缓浜嬮」璁剧疆</el-menu-item + > <!-- <el-menu-item index="/home/operate/baseSetting/threepack">闂ㄥ墠涓夊寘璁剧疆</el-menu-item> --> </el-submenu> <el-submenu index="/home/operate/disposal" class="secondMenu"> <template slot="title"> <span class="secondSpan">浜嬮」澶勭悊绠$悊</span> </template> - <el-menu-item index="/home/operate/casepool/pool">妗堜欢姹�</el-menu-item> - <el-menu-item index="/home/operate/casepool/escalation">涓婃姤绠$悊</el-menu-item> - <el-menu-item index="/home/operate/casepool/dispatch">璋冨害绠$悊</el-menu-item> - <el-menu-item index="/home/operate/casepool/learn">鍐嶅涔犵鐞�</el-menu-item> - <el-menu-item index="/home/operate/casepool/notDeal">鏆備笉澶勭悊</el-menu-item> + <el-menu-item index="/home/operate/casepool/pool" + >妗堜欢姹�</el-menu-item + > + <el-menu-item index="/home/operate/casepool/escalation" + >涓婃姤绠$悊</el-menu-item + > + <el-menu-item index="/home/operate/casepool/dispatch" + >璋冨害绠$悊</el-menu-item + > + <el-menu-item index="/home/operate/casepool/learn" + >鍐嶅涔犵鐞�</el-menu-item + > + <el-menu-item index="/home/operate/casepool/notDeal" + >鏆備笉澶勭悊</el-menu-item + > </el-submenu> <el-submenu index="/home/operate/management" class="secondMenu"> <template slot="title"> <span class="secondSpan">瀹℃牳绠$悊</span> </template> - <el-menu-item index="/home/operate/management">瀹℃牳绠$悊</el-menu-item> - <el-menu-item index="/home/operate/management/managementMessage">鐭俊瀹℃牳绠$悊</el-menu-item> + <el-menu-item index="/home/operate/management" + >瀹℃牳绠$悊</el-menu-item + > + <el-menu-item index="/home/operate/management/managementMessage" + >鐭俊瀹℃牳绠$悊</el-menu-item + > <!-- <el-menu-item index="/home/operate/baseSetting/threepack">闂ㄥ墠涓夊寘璁剧疆</el-menu-item> --> </el-submenu> <el-menu-item index="/home/operate/myWait">鎴戠殑寰呭姙</el-menu-item> @@ -85,27 +172,47 @@ <template slot="title"> <span class="secondSpan">涓撻」鏁存不</span> </template> - <el-menu-item index="/home/operate/rectification/taskList">浠诲姟鍒楄〃</el-menu-item> - <el-menu-item index="/home/operate/rectification/surveyList">鏅煡鍒楄〃</el-menu-item> - <el-menu-item index="/home/operate/rectification/renovationList">鏁存不鍒楄〃</el-menu-item> + <el-menu-item index="/home/operate/rectification/taskList" + >浠诲姟鍒楄〃</el-menu-item + > + <el-menu-item index="/home/operate/rectification/surveyList" + >鏅煡鍒楄〃</el-menu-item + > + <el-menu-item index="/home/operate/rectification/renovationList" + >鏁存不鍒楄〃</el-menu-item + > </el-submenu> - <el-menu-item index="/home/operate/lawEnforcement">宸℃煡鎵ф硶</el-menu-item> + <el-menu-item index="/home/operate/lawEnforcement" + >宸℃煡鎵ф硶</el-menu-item + > <el-menu-item index="/home/operate/dasds">妗堝嵎鏌ヨ</el-menu-item> <el-submenu index="/home/operate/fivepack" class="secondMenu"> <template slot="title"> <span class="secondSpan">闂ㄥ墠浜斿寘澶勭疆绠$悊</span> </template> - <el-menu-item index="/home/operate/fivepack/threepackage">闂ㄥ墠涓夊寘</el-menu-item> - <el-menu-item index="/home/operate/fivepack/shop">搴楅摵绠$悊</el-menu-item> + <el-menu-item index="/home/operate/fivepack/threepackage" + >闂ㄥ墠涓夊寘</el-menu-item + > + <el-menu-item index="/home/operate/fivepack/shop" + >搴楅摵绠$悊</el-menu-item + > </el-submenu> - <el-menu-item index="/home/operate/dasdas">绠楁硶妯″瀷绠$悊</el-menu-item> + <el-menu-item index="/home/operate/dasdas" + >绠楁硶妯″瀷绠$悊</el-menu-item + > <el-submenu index="/home/operate/car" class="secondMenu"> <template slot="title"> <span class="secondSpan">杞﹁締绠$悊</span> </template> - <el-menu-item index="/home/operate/car/carIndex">杞﹁締绠$悊</el-menu-item> - <el-menu-item index="/home/operate/car/lawTrajectory">杞ㄨ抗鍒嗘瀽(鎵ф硶杞�)</el-menu-item> - <el-menu-item index="/home/operate/car/soilTrajectory">杞ㄨ抗鍒嗘瀽(娓e湡杞�)</el-menu-item> + <el-menu-item index="/home/operate/car/carIndex" + >杞﹁締绠$悊</el-menu-item + > + <el-menu-item index="/home/operate/car/lawTrajectory" + >杞ㄨ抗鍒嗘瀽(鎵ф硶杞�)</el-menu-item + > + <el-menu-item index="/home/operate/car/soilTrajectory" + >杞ㄨ抗鍒嗘瀽(娓e湡杞�)</el-menu-item + > </el-submenu> <el-menu-item index="/home/operate">鍥剧墖绠$悊</el-menu-item> <el-menu-item index="/home/operate">瑙嗛绠$悊</el-menu-item> @@ -113,8 +220,12 @@ <template slot="title"> <span class="secondSpan">娑堟伅绠$悊</span> </template> - <el-menu-item index="/home/operate/message/messageIndex">娑堟伅绠$悊</el-menu-item> - <el-menu-item index="/home/operate/message/mycontrol">鏍忕洰绠$悊</el-menu-item> + <el-menu-item index="/home/operate/message/messageIndex" + >娑堟伅绠$悊</el-menu-item + > + <el-menu-item index="/home/operate/message/mycontrol" + >鏍忕洰绠$悊</el-menu-item + > </el-submenu> <el-menu-item index="/home/operate">鐭俊绠$悊</el-menu-item> <el-menu-item index="/home/operate/log">鏃ュ織绠$悊</el-menu-item> @@ -193,27 +304,40 @@ <script> export default { - data(){ - return{ - - } + data() { + return { + menuList: [], + }; }, - created(){ + created() { // this.getMenuList(); + this.loadMenu(); }, - methods:{ + methods: { + loadMenu() { + const info = JSON.parse(sessionStorage.getItem("user")); + var timer; + if (info && info.menus) { + clearTimeout(timer); + this.menuList = info.menus; + console.log(info.menus); + } else { + timer = setInterval(() => { + this.loadMenu(); + }, 1000); + } + }, // 鑾峰彇鑿滃崟鍒楄〃 - getMenuList(){ + getMenuList() { let arr; this.$axios({ - method:'get', - url:'sccg/system/portal/menu/search_myself' - }) - .then(res=>{ + method: "get", + url: "sccg/system/portal/menu/search_myself", + }).then((res) => { console.log(res); - }) - } - } + }); + }, + }, }; </script> @@ -255,7 +379,7 @@ background: #07162e; text-align: left; - &:hover>.el-submenu__title { + &:hover > .el-submenu__title { background-color: #092c4a; } @@ -285,7 +409,7 @@ } .secondMenu { - &:hover>.el-submenu__title { + &:hover > .el-submenu__title { background-color: #092c4a; } @@ -295,7 +419,7 @@ } .thirdMenu { - &:hover>.el-submenu__title { + &:hover > .el-submenu__title { background-color: #092c4a; } -- Gitblit v1.8.0