AdminHeader.vue 8.0 KB

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