You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
6.0 KiB
Vue

2 years ago
<template>
<div>
<div class="title">智慧物联监控平台</div>
<div>
2 years ago
<div v-if="isIndex" :class="`menu ${nowMenu==='1'? 'menuClick' :''}`" style="left: 2%"
@click="toLink('index','1')">
2 years ago
<span>
监控主页
</span>
</div>
<div :class="`menu ${nowMenu==='2'? 'menuClick' :''}`" style="left: 9%">
2 years ago
<el-dropdown trigger="click" @command="dropdownLink">
2 years ago
<span class="el-dropdown-link">
2 years ago
{{ name }} <i class="el-icon-arrow-down el-icon--right"></i>
2 years ago
</span>
2 years ago
<el-dropdown-menu slot="dropdown">
2 years ago
<div class="topNavScroll" style="max-height: 300px;overflow: auto;background-color: #053563;padding: 0;border: none;">
2 years ago
<el-dropdown-item v-for="i in selectSecnesList" :key="i.sceneId"
2 years ago
:command="{router:i.router,name:i.sceneName,sceneId:i.sceneId}">
<span style="color: #f8fefd">
{{
i.sceneName
}}
</span>
2 years ago
</el-dropdown-item>
</div>
2 years ago
</el-dropdown-menu>
</el-dropdown>
</div>
2 years ago
<div :class="`menu ${nowMenu==='3'? 'menuClick' :''}`" style="left: 16%" @click="toLink('equipment','3')">
2 years ago
<span>
设备监测
</span>
</div>
2 years ago
<div :class="`menu ${nowMenu==='4'? 'menuClick' :''}`" style="left: 23%"
@click="toLink('equipmentMonitoring','4')">
2 years ago
<span>
传感器汇总
</span>
</div>
</div>
<div class="right">
2 years ago
<span>
</span>
</div>
2 years ago
<div class="rightImg" @click="toIndex">
2 years ago
</div>
</div>
</template>
<script>
import {
selectSecnes
} from '@/api/board/nav'
export default {
2 years ago
name: 'BoardTopNav',
2 years ago
data() {
return {
2 years ago
selectSecnesList: [],
name: '智慧场景',
isIndex: true,
2 years ago
sceneId: this.$store.getters.sceneId,
2 years ago
nowMenu: '1'
2 years ago
}
},
2 years ago
// props: {
// nowMenu: {
// type: String,
// default: '1'
// },
// },
2 years ago
async mounted() {
2 years ago
if (!this.$store.getters.sceneId) {
this.$router.replace({path: "/board/index"})
}
2 years ago
if (this.$route.name === 'smartScene' || this.$route.name === 'GPS' || this.$route.name === 'index' || this.$store.getters.sceneId) {
2 years ago
} else {
if (this.$store.state.user.permissions.includes('business:monitor:index') || this.$store.state.user.permissions.includes('*:*:*')) {
await this.$router.replace({path: "/board/index"});
} else {
await this.$router.replace({path: "/board/smartScene"});
this.$router.push({path: '/board/smartScene'})
}
2 years ago
}
await this.setSelectSecnes()
2 years ago
if (this.$route.name === 'smartScene' || this.$route.name === 'GPS') {
2 years ago
if (this.$route.query?.name) {
2 years ago
this.name = this.$route.query?.name
} else {
let routerData = this.selectSecnesList.find(e => e.sceneId === this.sceneId)
await this.$router.push({
path: "/board/" + (routerData.router || 'smartScene'),
query: {name: routerData.sceneName}
});
2 years ago
}
}
if (this.$store.state.user.permissions.includes('business:monitor:index') || this.$store.state.user.permissions.includes('*:*:*')) {
this.isIndex = true
} else {
this.isIndex = false
}
2 years ago
2 years ago
},
methods: {
async setSelectSecnes() {
const {data} = await selectSecnes()
this.selectSecnesList = data
2 years ago
if (!this.$store.getters.sceneId) {
2 years ago
this.sceneId = data.find(e => e.defaultFlag === '1').sceneId
2 years ago
this.name = data.find(e => e.defaultFlag === '1').sceneName
2 years ago
}
if (this.$route.query.name) {
2 years ago
this.sceneId = data.find(e => e.sceneName === this.$route.query.name).sceneId
2 years ago
this.name = data.find(e => e.sceneName === this.$route.query.name).sceneName
2 years ago
}
2 years ago
if (this.name === '智慧场景' && this.$store.getters.sceneId) {
this.name = data.find(e => e.sceneId === this.$store.getters.sceneId).sceneName
}
2 years ago
await this.$store.dispatch('app/setSceneId', this.sceneId)
2 years ago
},
2 years ago
toLink(e, nowMenu) {
2 years ago
if (this.$store.getters.sceneId) {
this.nowMenu = nowMenu
this.$router.replace({path: "/board/" + e});
}
2 years ago
},
2 years ago
async dropdownLink(e,) {
this.nowMenu = '2'
2 years ago
await this.$store.dispatch('app/setSceneId', e.sceneId)
2 years ago
this.name = e.name
2 years ago
await this.$router.replace({path: "/board/" + (e.router || 'smartScene'), query: {name: e.name}});
2 years ago
},
toIndex() {
2 years ago
this.$router.replace({path: "/index"});
2 years ago
}
}
};
</script>
<style lang="less" scoped>
.menu {
background-image: url("~@/assets/board/common/subheadClick1.png");
background-repeat: no-repeat;
background-size: 100% 100%;
position: absolute;
width: 8vw;
height: 1.66vw;
top: 3.8%;
line-height: 1.66vw;
font-size: 0.8vw;
color: #d4d4d4;
text-align: center;
}
.menu .el-dropdown {
font-size: 0.8vw;
color: #d4d4d4;
}
.menuClick {
background-image: url("~@/assets/board/common/subheadClick.png");
color: #f3f3f3;
}
.title {
position: absolute;
top: 3%;
left: 50%;
font-size: 2vw;
letter-spacing: 12px;
transform: translate(-50%, -50%);
color: #f6f6f6;
}
.rightImg {
transform: rotateX(180deg);
background-image: url('~@/assets/board/common/subheadClick1.png');
background-repeat: no-repeat;
background-size: 100% 100%;
position: absolute;
width: 8vw;
height: 1.66vw;
top: 3.8%;
left: 71%;
}
.right {
position: absolute;
width: 8vw;
height: 1.66vw;
top: 3.8%;
left: 71%;
line-height: 1.66vw;
font-size: 0.8vw;
color: #d4d4d4;
text-align: center;
}
2 years ago
.el-dropdown-menu {
padding: 0 !important;
border: none !important;
}
.topNavScroll::-webkit-scrollbar {
width: 0px;
height: 0px;
}
.el-dropdown-menu__item:not(.is-disabled):hover span {
color: #053563 !important;
}
2 years ago
</style>