Navside.vue 6.8 KB

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