| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <template>
- <a-layout-header :class="[headerTheme, 'admin-header']">
- <div :class="['admin-header-wide', layout, pageWidth]">
- <router-link
- v-if="isMobile || layout === 'head'"
- to="/"
- :class="['logo', isMobile ? null : 'pc', headerTheme]"
- >
- <img width="32" src="@/assets/img/title.png" />
- <h1 v-if="!isMobile">{{ systemName }}</h1>
- </router-link>
- <a-divider v-if="isMobile" type="vertical" />
- <div class="breadcrumb">
- <a-breadcrumb>
- <a-breadcrumb-item
- :key="index"
- v-for="(item, index) in breadcrumb"
- v-show="item.path != '/'"
- >
- <!-- {{ item.path }} -->
- <!-- <div style="display: flex; flex-wrap: wrap"> -->
- <!-- {{ item.path }} -->
- <!-- {{ countCharacter(item.path, "/") }} -->
- <router-link
- v-if="item.path == '/channel'"
- :to="'/personnelManage' + item.path"
- >{{ item.name }}</router-link
- >
- <router-link
- v-else-if="item.path == '/verification'"
- :to="'/financial' + item.path"
- >{{ item.name }}</router-link
- >
- <router-link
- v-else
- :to="countCharacter(item.path, '/') >= 2 ? item.path : ''"
- >{{ item.name }}</router-link
- >
- </a-breadcrumb-item>
- </a-breadcrumb>
- </div>
- <!-- <a-icon v-if="layout !== 'head'" class="trigger" :type="collapsed ? 'menu-unfold' : 'menu-fold'" @click="toggleCollapse"/> -->
- <!-- <div v-if="layout !== 'side' && !isMobile" class="admin-header-menu" :style="`width: ${menuWidth};`">
- <i-menu class="head-menu" :theme="headerTheme" mode="horizontal" :options="menuData" @select="onSelect"/>
- </div> -->
- <div :class="['admin-header-right', headerTheme]">
- <!-- <header-search class="header-item" @active="val => searchActive = val" /> -->
- <!-- <a-tooltip class="header-item" title="帮助文档" placement="bottom" >
- <a href="https://iczer.gitee.io/vue-antd-admin-docs/" target="_blank">
- <a-icon type="question-circle-o" />
- </a>
- </a-tooltip> -->
- <!-- <ExpandOutlined /> -->
- <!-- <a-icon :class="['header-notice-icon']" type="scan" /> -->
- <HeaderExpand class="header-item"></HeaderExpand>
- <!-- <header-notice class="header-item" /> -->
- <header-avatar class="header-item" />
- <!-- <a-dropdown class="lang header-item">
- <div><a-icon type="global" /> {{ langAlias }}</div>
- <a-menu
- @click="(val) => setLang(val.key)"
- :selected-keys="[lang]"
- slot="overlay"
- >
- <a-menu-item v-for="lang in langList" :key="lang.key">{{
- lang.key.toLowerCase() + " " + lang.name
- }}</a-menu-item>
- </a-menu>
- </a-dropdown> -->
- </div>
- </div>
- </a-layout-header>
- </template>
- <script>
- // import HeaderSearch from './HeaderSearch'
- // import HeaderNotice from "./HeaderNotice";
- import HeaderAvatar from "./HeaderAvatar";
- import HeaderExpand from "./HeaderExpand";
- // import IMenu from '@/components/menu/menu'
- import { mapState, mapMutations } from "vuex";
- // import { getI18nKey } from "@/utils/routerUtil";
- export default {
- name: "AdminHeader",
- components: { HeaderAvatar, HeaderExpand },
- props: ["collapsed", "menuData"],
- data() {
- return {
- langList: [
- { key: "CN", name: "简体中文", alias: "简体" },
- { key: "HK", name: "繁體中文", alias: "繁體" },
- { key: "US", name: "English", alias: "English" },
- ],
- searchActive: false,
- page: {},
- };
- },
- created() {
- this.page = this.$route.meta.page;
- },
- computed: {
- ...mapState("setting", [
- "theme",
- "isMobile",
- "layout",
- "systemName",
- "lang",
- "pageWidth",
- ]),
- headerTheme() {
- if (
- this.layout == "side" &&
- this.theme.mode == "dark" &&
- !this.isMobile
- ) {
- return "light";
- }
- return this.theme.mode;
- },
- langAlias() {
- let lang = this.langList.find((item) => item.key == this.lang);
- return lang.alias;
- },
- menuWidth() {
- const { layout, searchActive } = this;
- const headWidth = layout === "head" ? "100% - 188px" : "100%";
- const extraWidth = searchActive ? "600px" : "400px";
- return `calc(${headWidth} - ${extraWidth})`;
- },
- breadcrumb() {
- let page = this.page;
- let breadcrumb = page && page.matched;
- if (breadcrumb) {
- let i18nBreadcrumb = [];
- breadcrumb.forEach((item) => {
- i18nBreadcrumb.push(item.name);
- });
- return i18nBreadcrumb;
- } else {
- return this.getRouteBreadcrumb();
- }
- },
- },
- methods: {
- countCharacter(str, charToCount) {
- return str.split(charToCount).length - 1;
- },
- toggleCollapse() {
- this.$emit("toggleCollapse");
- },
- onSelect(obj) {
- this.$emit("menuSelect", obj);
- },
- ...mapMutations("setting", ["setLang", "correctPageMinHeight"]),
- // ...mapMutations('setting', ['correctPageMinHeight']),
- getRouteBreadcrumb() {
- let routes = this.$route.matched;
- const lastPath = this.$route.path;
- let breadcrumb = [];
- routes
- .filter((item) => lastPath.includes(item.path))
- .forEach((route, index) => {
- const path =
- index == 1 ? "/" + lastPath.split("/")[1] + route.path : route.path;
- // console.log(route.name);
- // console.log(path.split("/message")[0]);
- if (route.name == "保费详情") {
- switch (path.split("/message")[0]) {
- case "/business/business/sales":
- breadcrumb.push({
- path: "/business/sales",
- name: "电销",
- });
- break;
- case "/business/business/agent":
- breadcrumb.push({
- path: "/business/agent",
- name: "代理人",
- });
- break;
- case "/business/business/channel":
- breadcrumb.push({
- path: "/business/channel",
- name: "渠道",
- });
- break;
- }
- }
- if (route.name == "订单详情") {
- switch (path.split("/orderMessage")[0]) {
- case "/business/business/sales":
- breadcrumb.push({
- path: "/business/sales",
- name: "电销",
- });
- break;
-
- }
- }
- if (route.name == "团队管理") {
- switch (path.split("/teammanage")[0]) {
- case "/personnelManage/front/personnel":
- breadcrumb.push({
- path: path.split("/teammanage")[0],
- name: "代理人统计",
- });
- break;
- case "/personnelManage/front/resources":
- breadcrumb.push({
- path: path.split("/teammanage")[0],
- name: "人力达标",
- });
- break;
- }
- }
- if (route.name == "电销详情") {
- switch (path.split("/message")[0]) {
- case "/sales":
- breadcrumb.push({
- path: path.split("/message")[0] + "/sales",
- name: "电销呼出",
- });
- break;
- }
- }
- // console.log(breadcrumb);
- breadcrumb.push({ path: path, name: route.name });
- });
- let pageTitle = this.page && this.page.title;
- if (this.customTitle || pageTitle) {
- breadcrumb[breadcrumb.length - 1] = this.customTitle || pageTitle;
- }
- breadcrumb.shift();
- console.log(breadcrumb);
- return breadcrumb;
- },
- },
- };
- </script>
- <style lang="less" scoped>
- @import "index";
- </style>
|