MenuComponent.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <el-col :span="24" class>
  3. <el-col :span="2" :offset="2">
  4. <img class="logoImg" src="../assets/img/log.png">
  5. </el-col>
  6. <!-- v-show="roles.indexOf(item.id) >= 0" -->
  7. <el-col
  8. :span="2"
  9. v-for="(item, index) of menuData"
  10. :key="item.index"
  11. @click.native="secondNavClick(item,index)"
  12. style="text-align: center"
  13. >
  14. <span class="lineStyle" :class="{active:index == checkindex,menu_item:true}">{{item.name}}</span>
  15. </el-col>
  16. <el-col :span="4" :offset="12">
  17. <div class="login">
  18. <img class="userstyle" :src="BASE_URL + avatar" alt="">
  19. <!-- <img class="userstyle" src="../assets/img/user.jpg"> -->
  20. <span>{{name}}</span>
  21. <i class="el-icon-caret-bottom"></i>
  22. </div>
  23. <div class="out">
  24. <img src="../assets/img/out.png" alt class="out-img">
  25. <span @click="Loginout">退出</span>
  26. </div>
  27. </el-col>
  28. <el-col :span="1"></el-col>
  29. </el-col>
  30. </template>
  31. <script>
  32. import { mapGetters } from "vuex";
  33. export default {
  34. name: "navMenu",
  35. // props: {
  36. // navsData: Array
  37. // },
  38. data() {
  39. return {
  40. BASE_URL: "https://xt.sharingschool.com/upload/",
  41. menuData: [
  42. {
  43. id: "2",
  44. name: "校区群管理员",
  45. href: "SchoolManager"
  46. },
  47. {
  48. id: "2",
  49. name: " 在线批改老师",
  50. href: "TeacherApporval"
  51. }
  52. // {
  53. // id: "3",
  54. // name: "",
  55. // href: "TeacherPay"
  56. // },
  57. // {
  58. // id: "1",
  59. // name: "校区管理员",
  60. // href: "SuperAdmin"
  61. // },
  62. // {
  63. // id: "1",
  64. // name: " 批改老师注册审核",
  65. // href: "CheckTeacherAudit"
  66. // },
  67. // {
  68. // id: "3",
  69. // name: "批改老师薪酬表",
  70. // href: "CheckTeacherPay"
  71. // }
  72. ],
  73. checkindex: 0
  74. };
  75. },
  76. watch: {
  77. navsData(n) {
  78. this.navsData = n;
  79. this.initNav();
  80. }
  81. },
  82. methods: {
  83. // 初始化处理
  84. // initNav() {
  85. // this.menuData = JSON.parse(JSON.stringify(this.navsData));
  86. // },
  87. secondNavClick(val, index) {
  88. this.$router.push("/home/" + val.href);
  89. this.checkindex = index;
  90. },
  91. // 账号管理、退出登录
  92. Loginout() {
  93. this.$confirm("您确定退出吗?", "提示", {
  94. confirmButtonText: "确定",
  95. cancelButtonText: "取消",
  96. type: "warning"
  97. })
  98. .then(() => {
  99. localStorage.removeItem("accessToken");
  100. this.$store.dispatch("LogOut").then(() => {
  101. location.reload(); // 为了重新实例化vue-router对象 避免bug
  102. });
  103. })
  104. .catch(() => {
  105. // console.log(err)
  106. this.$message("已取消操作!");
  107. });
  108. }
  109. },
  110. computed: {
  111. ...mapGetters(["name", "avatar", "roles"])
  112. },
  113. mounted() {
  114. // this.initNav();
  115. }
  116. };
  117. </script>
  118. <style scoped>
  119. /*.mainHeader{*/
  120. /*height: 110px;*/
  121. /*line-height:110px;*/
  122. /*}*/
  123. .menu_item {
  124. cursor: pointer;
  125. color: #999999;
  126. font-size: 9px;
  127. font-family: serif;
  128. box-sizing: border-box;
  129. height: 80%;
  130. text-align: center;
  131. padding-bottom: 19px;
  132. /*display: inline-block;*/
  133. }
  134. .menu_item:hover {
  135. color: #52cc60;
  136. border-bottom: 2px solid #52cc60;
  137. }
  138. .active {
  139. color: #52cc60 !important;
  140. border-bottom: 2px solid #52cc60;
  141. }
  142. .menu_item + .menu_item {
  143. border-left: 1px solid #ffffff;
  144. }
  145. .logoImg {
  146. width: 136px;
  147. height: 52px;
  148. }
  149. .sishuLogo {
  150. margin-left: 125px;
  151. }
  152. .userstyle {
  153. width:50px;
  154. height:50px;
  155. border-radius: 25px;
  156. }
  157. .lineStyle {
  158. color: #999999;
  159. font-size: 18px;
  160. }
  161. .login {
  162. color: #333333;
  163. font-size: 14px;
  164. display: inline-block;
  165. }
  166. .out {
  167. margin-left: 40px;
  168. font-size: 14px;
  169. color: #666666;
  170. display: inline-block;
  171. cursor: pointer;
  172. }
  173. .out-img {
  174. width: 16px;
  175. height: 18px;
  176. display: inline-block;
  177. }
  178. </style>