AdminHeader.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <a-layout-header :class="[headerTheme, 'admin-header']">
  3. <div :class="['admin-header-wide', layout, pageWidth]">
  4. <router-link
  5. v-if="isMobile || layout === 'head'"
  6. to="/"
  7. :class="['logo', isMobile ? null : 'pc', headerTheme]"
  8. >
  9. <img width="32" src="@/assets/img/title.png" />
  10. <h1 v-if="!isMobile">{{ systemName }}</h1>
  11. </router-link>
  12. <a-divider v-if="isMobile" type="vertical" />
  13. <div class="breadcrumb">
  14. <a-breadcrumb>
  15. <a-breadcrumb-item
  16. :key="index"
  17. v-for="(item, index) in breadcrumb"
  18. v-show="item.path != '/'"
  19. >
  20. <!-- {{ item.path }} -->
  21. <!-- <div style="display: flex; flex-wrap: wrap"> -->
  22. <!-- {{ item.path }} -->
  23. <!-- {{ countCharacter(item.path, "/") }} -->
  24. <router-link
  25. v-if="item.path == '/channel'"
  26. :to="'/personnelManage' + item.path"
  27. >{{ item.name }}</router-link
  28. >
  29. <router-link
  30. v-else
  31. :to="countCharacter(item.path, '/') >= 2 ? item.path : ''"
  32. >{{ item.name }}</router-link
  33. >
  34. </a-breadcrumb-item>
  35. </a-breadcrumb>
  36. </div>
  37. <!-- <a-icon v-if="layout !== 'head'" class="trigger" :type="collapsed ? 'menu-unfold' : 'menu-fold'" @click="toggleCollapse"/> -->
  38. <!-- <div v-if="layout !== 'side' && !isMobile" class="admin-header-menu" :style="`width: ${menuWidth};`">
  39. <i-menu class="head-menu" :theme="headerTheme" mode="horizontal" :options="menuData" @select="onSelect"/>
  40. </div> -->
  41. <div :class="['admin-header-right', headerTheme]">
  42. <!-- <header-search class="header-item" @active="val => searchActive = val" /> -->
  43. <!-- <a-tooltip class="header-item" title="帮助文档" placement="bottom" >
  44. <a href="https://iczer.gitee.io/vue-antd-admin-docs/" target="_blank">
  45. <a-icon type="question-circle-o" />
  46. </a>
  47. </a-tooltip> -->
  48. <!-- <ExpandOutlined /> -->
  49. <!-- <a-icon :class="['header-notice-icon']" type="scan" /> -->
  50. <HeaderExpand class="header-item"></HeaderExpand>
  51. <!-- <header-notice class="header-item" /> -->
  52. <header-avatar class="header-item" />
  53. <!-- <a-dropdown class="lang header-item">
  54. <div><a-icon type="global" /> {{ langAlias }}</div>
  55. <a-menu
  56. @click="(val) => setLang(val.key)"
  57. :selected-keys="[lang]"
  58. slot="overlay"
  59. >
  60. <a-menu-item v-for="lang in langList" :key="lang.key">{{
  61. lang.key.toLowerCase() + " " + lang.name
  62. }}</a-menu-item>
  63. </a-menu>
  64. </a-dropdown> -->
  65. </div>
  66. </div>
  67. </a-layout-header>
  68. </template>
  69. <script>
  70. // import HeaderSearch from './HeaderSearch'
  71. // import HeaderNotice from "./HeaderNotice";
  72. import HeaderAvatar from "./HeaderAvatar";
  73. import HeaderExpand from "./HeaderExpand";
  74. // import IMenu from '@/components/menu/menu'
  75. import { mapState, mapMutations } from "vuex";
  76. // import { getI18nKey } from "@/utils/routerUtil";
  77. export default {
  78. name: "AdminHeader",
  79. components: { HeaderAvatar, HeaderExpand },
  80. props: ["collapsed", "menuData"],
  81. data() {
  82. return {
  83. langList: [
  84. { key: "CN", name: "简体中文", alias: "简体" },
  85. { key: "HK", name: "繁體中文", alias: "繁體" },
  86. { key: "US", name: "English", alias: "English" },
  87. ],
  88. searchActive: false,
  89. page: {},
  90. };
  91. },
  92. created() {
  93. this.page = this.$route.meta.page;
  94. },
  95. computed: {
  96. ...mapState("setting", [
  97. "theme",
  98. "isMobile",
  99. "layout",
  100. "systemName",
  101. "lang",
  102. "pageWidth",
  103. ]),
  104. headerTheme() {
  105. if (
  106. this.layout == "side" &&
  107. this.theme.mode == "dark" &&
  108. !this.isMobile
  109. ) {
  110. return "light";
  111. }
  112. return this.theme.mode;
  113. },
  114. langAlias() {
  115. let lang = this.langList.find((item) => item.key == this.lang);
  116. return lang.alias;
  117. },
  118. menuWidth() {
  119. const { layout, searchActive } = this;
  120. const headWidth = layout === "head" ? "100% - 188px" : "100%";
  121. const extraWidth = searchActive ? "600px" : "400px";
  122. return `calc(${headWidth} - ${extraWidth})`;
  123. },
  124. breadcrumb() {
  125. let page = this.page;
  126. let breadcrumb = page && page.matched;
  127. if (breadcrumb) {
  128. let i18nBreadcrumb = [];
  129. breadcrumb.forEach((item) => {
  130. i18nBreadcrumb.push(item.name);
  131. });
  132. return i18nBreadcrumb;
  133. } else {
  134. return this.getRouteBreadcrumb();
  135. }
  136. },
  137. },
  138. methods: {
  139. countCharacter(str, charToCount) {
  140. return str.split(charToCount).length - 1;
  141. },
  142. toggleCollapse() {
  143. this.$emit("toggleCollapse");
  144. },
  145. onSelect(obj) {
  146. this.$emit("menuSelect", obj);
  147. },
  148. ...mapMutations("setting", ["setLang", "correctPageMinHeight"]),
  149. // ...mapMutations('setting', ['correctPageMinHeight']),
  150. getRouteBreadcrumb() {
  151. let routes = this.$route.matched;
  152. const path = this.$route.path;
  153. let breadcrumb = [];
  154. routes
  155. .filter((item) => path.includes(item.path))
  156. .forEach((route) => {
  157. const path = route.path;
  158. console.log(route.name);
  159. if (route.name == "保费详情") {
  160. switch (path.split("/message")[0]) {
  161. case "/business/sales":
  162. breadcrumb.push({
  163. path: path.split("/message")[0],
  164. name: "电销",
  165. });
  166. break;
  167. case "/business/agent":
  168. breadcrumb.push({
  169. path: path.split("/message")[0],
  170. name: "代理人",
  171. });
  172. break;
  173. case "/business/channel":
  174. breadcrumb.push({
  175. path: path.split("/message")[0],
  176. name: "渠道",
  177. });
  178. break;
  179. }
  180. }
  181. if (route.name == "团队管理") {
  182. switch (path.split("/teammanage")[0]) {
  183. case "/personnelManage/front/personnel":
  184. breadcrumb.push({
  185. path: path.split("/teammanage")[0],
  186. name: "代理人统计",
  187. });
  188. break;
  189. case "/personnelManage/front/resources":
  190. breadcrumb.push({
  191. path: path.split("/teammanage")[0],
  192. name: "人力达标",
  193. });
  194. break;
  195. }
  196. }
  197. if (route.name == "电销详情") {
  198. switch (path.split("/message")[0]) {
  199. case "/sales":
  200. breadcrumb.push({
  201. path: path.split("/message")[0] + "/sales",
  202. name: "电销呼出",
  203. });
  204. break;
  205. }
  206. }
  207. breadcrumb.push({ path: path, name: route.name });
  208. });
  209. let pageTitle = this.page && this.page.title;
  210. if (this.customTitle || pageTitle) {
  211. breadcrumb[breadcrumb.length - 1] = this.customTitle || pageTitle;
  212. }
  213. breadcrumb.shift();
  214. // console.log(breadcrumb)
  215. return breadcrumb;
  216. },
  217. },
  218. };
  219. </script>
  220. <style lang="less" scoped>
  221. @import "index";
  222. </style>