LayoutHeader.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <div class="header">
  3. <div class="header-top">
  4. <el-row type="flex" justify="space-between">
  5. <el-col :span="4" class="header-top-logo">LOGO</el-col>
  6. <el-col class="header-top-tab" :span="16">
  7. <span>主页</span>
  8. <template v-for="item in routerList">
  9. <router-link v-if="item.isShow" :key="item.path" :to="item.path">
  10. {{ item.name }}
  11. </router-link>
  12. </template>
  13. </el-col>
  14. <el-col class="header-top-user" :span="4">
  15. <el-avatar :src="$store.state.user.image_url"> user </el-avatar>
  16. <el-dropdown class="header-top-user-name" placement="bottom">
  17. <span>{{ realName }}</span>
  18. <el-dropdown-menu slot="dropdown">
  19. <el-dropdown-item @click.native="signOut">退出</el-dropdown-item>
  20. </el-dropdown-menu>
  21. </el-dropdown>
  22. <el-badge :is-dot="isDot" class="header-top-user-bell">
  23. <i class="el-icon-bell"></i>
  24. </el-badge>
  25. </el-col>
  26. </el-row>
  27. </div>
  28. <div class="header-crumbs">
  29. <div class="header-crumbs-navigation">
  30. <span class="home-page">后台主页 ></span>
  31. <router-link v-for="item in levelList" :key="item.path" :to="item.path">
  32. {{ item.meta.title }}
  33. </router-link>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. export default {
  40. name: 'LayoutHeader',
  41. data() {
  42. return {
  43. levelList: null,
  44. isDot: false
  45. };
  46. },
  47. computed: {
  48. realName() {
  49. let user = this.$store.state.user;
  50. return user.user_real_name ? user.user_real_name : user.user_name;
  51. },
  52. routerList() {
  53. let popedomList = this.$store.state.user.popedom_code_list;
  54. if (popedomList === undefined) {
  55. popedomList = [];
  56. }
  57. let list = [
  58. {
  59. path: '/org_manager',
  60. name: '机构管理',
  61. isShow: popedomList.indexOf(1000001) !== -1
  62. },
  63. {
  64. path: '/account_manager',
  65. name: '账户管理',
  66. isShow: popedomList.indexOf(1000002) !== -1
  67. },
  68. {
  69. path: '/teacher_manager',
  70. name: '机构教师',
  71. isShow: popedomList.indexOf(1000003) !== -1
  72. },
  73. {
  74. path: '/vocabulary',
  75. name: '多语言词汇',
  76. isShow: true
  77. },
  78. {
  79. path: '/upload/uploadList',
  80. name: '文件静态资源',
  81. isShow: true
  82. }
  83. ];
  84. return list;
  85. }
  86. },
  87. watch: {
  88. $route() {
  89. this.getBreadcrumb();
  90. }
  91. },
  92. created() {
  93. this.getBreadcrumb();
  94. },
  95. methods: {
  96. getBreadcrumb() {
  97. this.levelList = this.$route.matched.filter(item => item.meta && item.meta.title);
  98. },
  99. async signOut() {
  100. await this.$store.dispatch('user/signOut');
  101. this.$router.push(`/login`);
  102. }
  103. }
  104. };
  105. </script>
  106. <style lang="scss">
  107. .header {
  108. width: 100%;
  109. min-width: 1200px;
  110. position: fixed;
  111. top: 0;
  112. left: 0;
  113. z-index: 9;
  114. // 顶部
  115. &-top {
  116. height: 74px;
  117. padding: 15px 24px;
  118. line-height: 44px;
  119. background-color: #fff;
  120. &-logo {
  121. font-size: 30px;
  122. font-weight: 700;
  123. padding-right: 20px;
  124. }
  125. &-tab {
  126. a {
  127. margin-left: 24px;
  128. }
  129. }
  130. &-user {
  131. &-name {
  132. vertical-align: top;
  133. margin-left: 8px;
  134. cursor: pointer;
  135. }
  136. & > &-bell {
  137. top: -12px;
  138. margin-left: 26px;
  139. line-height: 18px;
  140. }
  141. }
  142. }
  143. // 面包屑导航
  144. &-crumbs {
  145. height: 56px;
  146. background-color: #ddeaf6;
  147. &-navigation {
  148. width: 1200px;
  149. height: 100%;
  150. min-width: 1200px;
  151. margin: 0 auto;
  152. padding: 15px 0;
  153. font-size: 18px;
  154. font-weight: 700;
  155. line-height: 26px;
  156. vertical-align: middle;
  157. &::before {
  158. content: '';
  159. display: inline-block;
  160. width: 6px;
  161. height: 100%;
  162. vertical-align: bottom;
  163. margin-right: 24px;
  164. background-color: #0085ff;
  165. }
  166. .home-page {
  167. color: #848b91;
  168. & ~ a {
  169. margin-left: 8px;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. </style>