Navside.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <div>
  3. <el-row :class="[{'shortnav':isCollapse},{'longNav':!isCollapse}]">
  4. <el-col :span="24">
  5. <el-menu
  6. default-active="2"
  7. class="el-menu-vertical-demo"
  8. @open="handleOpen"
  9. @close="handleClose"
  10. @select="handleSelect"
  11. background-color="#545c64"
  12. text-color="#fff"
  13. active-text-color="#ffd04b"
  14. router
  15. :collapse="isCollapse"
  16. >
  17. <el-menu-item class="el-submenu" index="1" route="/" title="系统首页">
  18. <i class="icon-home"></i>
  19. <span slot="title">系统首页</span>
  20. </el-menu-item>
  21. <el-submenu :index="nav.clmid" :route="nav.clmurl" v-for="nav in navs">
  22. <template slot="title">
  23. <i :class="nav.icon"></i>
  24. <span>{{nav.clmname}}</span>
  25. </template>
  26. <el-menu-item-group v-for="(child,j) in nav.childs">
  27. <el-menu-item :index="child.clmid" :route="child.clmurl">{{child.clmname}}
  28. </el-menu-item>
  29. </el-menu-item-group>
  30. </el-submenu>
  31. <el-menu-item index="99" route="#" title="退出登陆" @click="clickLogout">
  32. <i class="icon-logout"></i>
  33. <span slot="title">退出登陆</span>
  34. </el-menu-item>
  35. </el-menu>
  36. </el-col>
  37. </el-row>
  38. </div>
  39. </template>
  40. <script>
  41. import Navs from '../api/Navs';
  42. import {SignOut} from '../api/getApiRes.js'
  43. let qs = require('qs');
  44. export default {
  45. data() {
  46. return {
  47. wildState: 0,
  48. navs: [],
  49. }
  50. },
  51. props: ['isCollapse'],
  52. mounted() {
  53. this.getTableQuery();
  54. },
  55. methods: {
  56. handleSelect(i, s, t) {
  57. this.$emit('TabsAdd', i);//触发事件
  58. },
  59. getTableQuery() {
  60. // 菜单
  61. this.navs = Navs;
  62. },
  63. handleOpen(key, keyPath) {
  64. // console.log(key, keyPath);
  65. },
  66. handleClose(key, keyPath) {
  67. // console.log(key, keyPath);
  68. },
  69. clickLogout() {
  70. let that = this;
  71. let param = {
  72. token: localStorage.token
  73. };
  74. let postdata = qs.stringify(param);
  75. this.$confirm('此操作将退出当前账号, 是否继续?', '提示', {
  76. confirmButtonText: '确定',
  77. cancelButtonText: '取消',
  78. type: 'warning'
  79. }).then(() => {
  80. SignOut(postdata).then(res => {
  81. that.$message({
  82. showClose: true,
  83. message: '用户已退出!',
  84. type: 'success'
  85. });
  86. localStorage.usercode = '';
  87. that.$router.push({path: '/login', query: {status: 1}});
  88. })
  89. }).catch(() => {
  90. this.$message({
  91. type: 'info',
  92. message: '已取消删除'
  93. });
  94. })
  95. }
  96. }
  97. }
  98. </script>
  99. <style scoped>
  100. .shortnav {
  101. position: absolute;
  102. width: 65px;
  103. top: 48px;
  104. bottom: 0;
  105. overflow: hidden;
  106. display: block;
  107. margin: 0 auto;
  108. height: 100%;
  109. }
  110. .longNav {
  111. position: absolute;
  112. width: 320px;
  113. top: 48px;
  114. bottom: 0;
  115. overflow: hidden;
  116. display: block;
  117. margin: 0 auto;
  118. height: 100%;
  119. }
  120. .el-col, .el-menu {
  121. height: 100%;
  122. border-right: 0;
  123. }
  124. /deep/ .el-menu-item {
  125. background-color: rgba(255, 255, 255, 0) !important;
  126. }
  127. /deep/ .el-menu {
  128. background-color: rgba(255, 255, 255, 0.1) !important;
  129. }
  130. /deep/ .el-submenu__title {
  131. background: rgba(255, 255, 255, 0) !important;
  132. }
  133. .el-menu li:hover {
  134. background: #00599A;
  135. }
  136. /deep/ .el-menu-item:hover {
  137. background: #00599A !important;
  138. }
  139. .logout {
  140. color: #fff;
  141. font-size: 14px;
  142. cursor: pointer;
  143. height: 56px;
  144. line-height: 56px;
  145. }
  146. .logout:hover {
  147. background: rgb(67, 74, 80);
  148. }
  149. .littleLogo {
  150. float: left;
  151. }
  152. .icon-home {
  153. width: 18px;
  154. height: 18px;
  155. float: left;
  156. margin-top: 20px;
  157. background: url("../assets/img/icon/home.png") top center no-repeat;
  158. background-size: 100%;
  159. }
  160. .icon-location {
  161. width: 18px;
  162. height: 18px;
  163. float: left;
  164. margin-top: 20px;
  165. background: url("../assets/img/icon/location.png") top center no-repeat;
  166. background-size: 100%;
  167. }
  168. .icon-list {
  169. width: 18px;
  170. height: 18px;
  171. float: left;
  172. margin-top: 20px;
  173. background: url("../assets/img/icon/list.png") top center no-repeat;
  174. background-size: 100%;
  175. }
  176. .icon-equip {
  177. width: 18px;
  178. height: 18px;
  179. float: left;
  180. margin-top: 20px;
  181. background: url("../assets/img/icon/equip.png") top center no-repeat;
  182. background-size: 100%;
  183. }
  184. .icon-qrcode {
  185. width: 18px;
  186. height: 18px;
  187. float: left;
  188. margin-top: 20px;
  189. background: url("../assets/img/icon/qrcode.png") top center no-repeat;
  190. background-size: 100%;
  191. }
  192. .icon-setting {
  193. width: 18px;
  194. height: 18px;
  195. float: left;
  196. margin-top: 20px;
  197. background: url("../assets/img/icon/setting.png") top center no-repeat;
  198. background-size: 100%;
  199. }
  200. .icon-logout {
  201. width: 18px;
  202. height: 18px;
  203. float: left;
  204. margin-top: 20px;
  205. background: url("../assets/img/icon/logout.png") top center no-repeat;
  206. background-size: 100%;
  207. }
  208. </style>