123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270 |
- <template>
- <div class="header-menu">
- <ul class="header-menu-list">
- <li class="header-menu-item"
- v-for="(menu, index) of menus"
- :key="menu"
- @click="click(index, menu)"
- :class="{ active: activeIndex == index }">
- {{ menu.text }}
- </li>
- </ul>
- <!-- <ul class="header-menu-dropdown" :class="{ dropdown: dropdown }">
- <li class="header-menu-dropdown-title" @click="clickMenu()"><i class="fa fa-gear"></i>菜单<i class="fa fa-sort-down down"></i></li>
- <ul class="header-menu-dropdown-list">
- <li class="header-menu-dropdown-item" v-for="(menu, index) of menusDropdown" :key="menu" @click="clickSubMenu(index, menu.code)">
- {{ menu.text }}
- </li>
- </ul>
- </ul> -->
- <ul class="header-menu-user">
- <li class="header-menu-user-title"><i class="fa fa-user"></i>白玉杰</li>
- </ul>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- menus: [
- {
- id: 'monitor',
- text: '驾驶舱',
- path: '/monitor/home',
- isActive: true
- },
- {
- id: 'decision',
- text: '经济运行',
- path: '/decision/pb',
- isActive: false
- },
- {
- id: 'health',
- text: '智慧检修',
- // path: '/sandtable',
- path: '/health/sandtable',
- isActive: false
- },
- // {
- // id: "decision",
- // text: "决策支持",
- // path: "/decision/decision1",
- // isActive: false,
- // },
- {
- id: 'personnel',
- text: '安全管控',
- path: '/new/personnel',
- isActive: false
- },
- {
- id: "znbb",
- text: "智能报表",
- path: "/znbb/reportPandect",
- isActive: false,
- },
- {
- id: 'realSearch',
- text: '其他',
- path: '/realSearch',
- isActive: false
- }
- ],
- activeIndex: 0
- // menusDropdown: [
- // {
- // text: "子菜单1",
- // code: "submenu1",
- // },
- // {
- // text: "子菜单2",
- // code: "submenu2",
- // },
- // {
- // text: "子菜单3",
- // code: "submenu3",
- // },
- // ],
- // dropdown: false,
- }
- },
- methods: {
- click(index, data) {
- this.activeIndex = index
- this.$router.push(data.path)
- },
- clickSubMenu(index, code) {
- console.log(index, code)
- },
- clickMenu() {
- this.dropdown = !this.dropdown
- }
- },
- computed: {
- activeClass(data) {
- return data.isActive ? 'active' : ''
- }
- },
- watch: {
- $route: {
- handler: function(val, oldVal) {
- this.menus.some((t, index) => {
- if (val.path.includes(t.id)) {
- this.activeIndex = index
- }
- })
- },
- //深度观察监听
- deep: true
- }
- }
- }
- </script>
- <style lang="less">
- .header-menu {
- display: flex;
- flex-direction: row;
- width: 100%;
- height: 100%;
- font-size: @fontsize;
- .header-menu-list {
- margin: 0;
- padding: 0;
- list-style: none;
- margin-left: auto;
- display: flex;
- flex-direction: row;
- height: 100%;
- .header-menu-item {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 9.259vh;
- height: 100%;
- color: @font-color;
- cursor: pointer;
- transition: color 0.2s ease-in-out;
- &.active {
- color: @green;
- position: relative;
- background: @greenLinearTop;
- transition: color 0.2s ease-in-out;
- &::after {
- content: '';
- position: absolute;
- width: 100%;
- height: 0.463vh;
- border: 0.093vh solid @green;
- border-top: 0;
- left: 0;
- bottom: 0;
- box-sizing: border-box;
- }
- }
- }
- }
- .header-menu-dropdown {
- width: 11.111vh;
- height: 100%;
- margin: 0;
- padding: 0;
- list-style: none;
- .header-menu-dropdown-title {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 100%;
- color: @gray;
- cursor: pointer;
- i {
- margin: 0 0.741vh;
- transition: all 0.3s;
- }
- }
- .header-menu-dropdown-list {
- display: none;
- margin: 0;
- padding: 0;
- list-style: none;
- margin-left: auto;
- position: absolute;
- .header-menu-dropdown-item {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 11.111vh;
- height: 3.704vh;
- color: @gray;
- cursor: pointer;
- position: relative;
- z-index: 1;
- background-color: fade(@write, 5%);
- &::after {
- content: '';
- position: absolute;
- width: 100%;
- height: 0.463vh;
- border: 0.093vh solid @green;
- border-top: 0;
- left: 0;
- bottom: 0;
- box-sizing: border-box;
- }
- &:hover {
- color: @write;
- background-color: fade(@write, 10%);
- }
- }
- }
- &.dropdown {
- .header-menu-dropdown-title {
- .down {
- transform: rotate(180deg);
- }
- }
- .header-menu-dropdown-list {
- display: flex;
- flex-direction: column;
- }
- }
- }
- .header-menu-user {
- width: 16.667vh;
- height: 100%;
- margin: 0;
- padding: 0;
- list-style: none;
- .header-menu-user-title {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 100%;
- color: @gray;
- cursor: pointer;
- i {
- margin: 0 0.741vh;
- }
- }
- }
- }
- </style>
|