From 5b9a1d6cb3a7d59c8f2de83c495bba1a069b2723 Mon Sep 17 00:00:00 2001 From: gaosp <gaosp> Date: 星期五, 19 一月 2024 00:23:15 +0800 Subject: [PATCH] update --- src/container/home/index.vue | 96 ++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 77 insertions(+), 19 deletions(-) diff --git a/src/container/home/index.vue b/src/container/home/index.vue index d08b296..eaf7554 100644 --- a/src/container/home/index.vue +++ b/src/container/home/index.vue @@ -2,13 +2,13 @@ <Home> <template slot="menu"> <div class="menu-container"> - <ul> - <li v-for="item in navs" :key="item.id" :class="activeId === item.id ? 'active' : ''" @click="goTo(item)"> + <ul class="nav"> + <li v-for="item in userMenu" :key="item.label" :class="activeId === item.label ? 'active' : ''" @click="goTo(item)"> <span> {{ item.label }} <i class="el-icon-caret-bottom" v-show="item.children && item.children.length > 0"></i> </span> - <ul v-if="activeId === item.id && showSub"> + <ul class="nav-sub" v-if="item.children && item.children.length > 0 && activeId === item.label && showSub"> <li v-for="child in item.children" @click="goTo(child)">{{ child.label }}</li> </ul> </li> @@ -37,12 +37,14 @@ { label: '鐘舵�佺洃鎺�', pathName: '', - id: 1 + id: 1, + chilren: [] }, { label: '澶у睆灞曠ず', pathName: 'preview', id: 2, + chilren: [] }, { label: '杞﹂棿鍦板浘', @@ -99,7 +101,8 @@ id: 6, children: [ { - label: '鎶ヨ〃鐢熸垚1' + label: '璁捐鍣�', + href: '/mdc/ureport/designer' }, { label: '鎶ヨ〃鐢熸垚1' @@ -115,11 +118,13 @@ { label: '鐝璁剧疆', id: 7, + chilren: [] }, { label: '宸ヤ欢淇℃伅', pathName: 'component', id: 8, + chilren: [] }, { label: '鏇村鑿滃崟', @@ -134,8 +139,8 @@ pathName: 'deviceType' }, { - label: '鏈哄簥缁存姢', - pathName: 'devicemaintenance' + label: '鏈哄簥閲囬泦', + pathName: 'machineList' } ] }, @@ -145,7 +150,46 @@ } }, computed: { - ...mapGetters(['userInfo','workshopList']) + ...mapGetters(['userInfo','workshopList','userMenu']) + }, + watch: { + workshopList() { + this.$set(this.navs,3 ,{ + ...this.navs[3], + children: this.workshopList.map(item => { + return { + label: item.name, + value: item.id, + pathName: 'workshop', + params: { + id: item.id + }, + query: { + name: item.name + } + } + }) + }) + } + }, + created () { + this.$set(this.navs, 3 ,{ + ...this.navs[3], + children: this.workshopList.map(item => { + return { + label: item.name, + value: item.id, + pathName: 'workshop', + params: { + id: item.id + }, + query: { + name: item.name + } + } + }) + }) + // this.navs[3].children = workshopList }, methods: { logout() { @@ -155,18 +199,20 @@ }) }, goTo (item) { - if (item.id) { - if (item.id === this.activeId) { + if (item.children && item.children.length > 0) { // 鏈夊瓙鑿滃崟 + if (item.label === this.activeId) { this.showSub = !this.showSub } else { this.showSub = true } - this.activeId = item.id || this.activeId - if(item.pathName) { - this.$router.push({name: item.pathName,params: item.params,query: item.query}) - } - } else {//浜岀骇鑿滃崟 + this.activeId = item.label || this.activeId + } else if (item.pathName && item.children && item.children.length === 0) { //鐖惰彍鍗� + this.activeId = item.label || this.activeId this.$router.push({name: item.pathName,params: item.params,query: item.query}) + } else if(item.pathName){ //浜岀骇鑿滃崟 + this.$router.push({name: item.pathName,params: item.params,query: item.query}) + } else if(item.href) {// 鎵撳紑鏂伴〉 + window.open(item.href) } }, }, @@ -186,9 +232,14 @@ list-style: none; display: flex; & > li { + width: 112px; + height: 40px; + line-height: 38px; + text-align: center; cursor: pointer; - background: #27394E; - padding: 0 12px; + // background: #27394E; + background: url('./nav-li.png') 100% 100% no-repeat; + background-size: contain; white-space: nowrap; text-overflow: ellipsis; position: relative; @@ -199,9 +250,12 @@ // user-select:none; } & > li.active { - & > ul { + background: url('./nav-li-active.png') 100% 100% no-repeat; + background-size: contain; + & > ul.nav-sub { padding: 0; margin: 0; + margin-top: 5px; padding-inline: 0; list-style: none; min-width: 100%; @@ -211,13 +265,17 @@ z-index: 999; background: rgba(0,0,0,.5); text-align: center; - border: 1px solid #0170bc; + // border: 1px solid #0170bc; li { padding: 4px; margin: 0; color: #FFF; + background: url('./nav-li.png') 100% 100% no-repeat; + background-size: contain; } li:hover { + background: url('./nav-li-active.png') 100% 100% no-repeat; + background-size: contain; color: #68D9FF; } } -- Gitblit v1.9.3