LayoutHeader.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 is_inner = this.$store.state.user.is_inner === 'true';
  54. let popedomList = this.$store.state.user.popedom_code_list;
  55. if (popedomList === undefined) {
  56. popedomList = [];
  57. }
  58. let list = [
  59. {
  60. path: '/org_manager',
  61. name: '机构管理',
  62. isShow: popedomList.includes(1000001)
  63. },
  64. {
  65. path: '/account_manager',
  66. name: '账户管理',
  67. isShow: popedomList.includes(1000002)
  68. },
  69. {
  70. path: '/teacher_manager',
  71. name: '机构教师',
  72. isShow: popedomList.includes(1000003)
  73. },
  74. {
  75. path: '/vocabulary',
  76. name: '多语言词汇',
  77. isShow: is_inner
  78. },
  79. {
  80. path: '/upload/uploadList',
  81. name: '文件静态资源',
  82. isShow: is_inner
  83. }
  84. ];
  85. return list;
  86. }
  87. },
  88. watch: {
  89. $route() {
  90. this.getBreadcrumb();
  91. }
  92. },
  93. created() {
  94. this.getBreadcrumb();
  95. },
  96. methods: {
  97. getBreadcrumb() {
  98. this.levelList = this.$route.matched.filter(item => item.meta && item.meta.title);
  99. },
  100. async signOut() {
  101. await this.$store.dispatch('user/signOut');
  102. this.$router.push(`/login`);
  103. }
  104. }
  105. };
  106. </script>
  107. <style lang="scss">
  108. .header {
  109. width: 100%;
  110. min-width: 1200px;
  111. position: fixed;
  112. top: 0;
  113. left: 0;
  114. z-index: 9;
  115. // 顶部
  116. &-top {
  117. height: 74px;
  118. padding: 15px 24px;
  119. line-height: 44px;
  120. background-color: #fff;
  121. &-logo {
  122. font-size: 30px;
  123. font-weight: 700;
  124. padding-right: 20px;
  125. }
  126. &-tab {
  127. a {
  128. margin-left: 24px;
  129. }
  130. }
  131. &-user {
  132. &-name {
  133. vertical-align: top;
  134. margin-left: 8px;
  135. cursor: pointer;
  136. }
  137. & > &-bell {
  138. top: -12px;
  139. margin-left: 26px;
  140. line-height: 18px;
  141. }
  142. }
  143. }
  144. // 面包屑导航
  145. &-crumbs {
  146. height: 56px;
  147. background-color: #ddeaf6;
  148. &-navigation {
  149. width: 1200px;
  150. height: 100%;
  151. min-width: 1200px;
  152. margin: 0 auto;
  153. padding: 15px 0;
  154. font-size: 18px;
  155. font-weight: 700;
  156. line-height: 26px;
  157. vertical-align: middle;
  158. &::before {
  159. content: '';
  160. display: inline-block;
  161. width: 6px;
  162. height: 100%;
  163. vertical-align: bottom;
  164. margin-right: 24px;
  165. background-color: #0085ff;
  166. }
  167. .home-page {
  168. color: #848b91;
  169. & ~ a {
  170. margin-left: 8px;
  171. }
  172. }
  173. }
  174. }
  175. }
  176. </style>