YZProjectCloud/yanzhu-bigscreen/src/components/header.vue

172 lines
4.8 KiB
Vue
Raw Normal View History

2024-11-27 23:42:39 +08:00
<template>
2024-11-29 23:08:39 +08:00
<div class="div-header">
<el-row>
<el-col :span="8">
<div class="head-title-tab">
<div :class="nav == 1 ? 'head-nav active' : 'head-nav'" @click="doNav(1)"></div>
<div :class="nav == 2 ? 'head-nav active' : 'head-nav'" @click="doNav(2)"></div>
<div :class="nav == 3 ? 'head-nav active' : 'head-nav'" @click="doNav(3)"></div>
<div :class="nav == 4 ? 'head-nav active' : 'head-nav'" @click="doNav(4)"></div>
<div :class="nav == 5 ? 'head-nav active' : 'head-nav'" @click="doNav(5)"></div>
</div>
</el-col>
<el-col :span="8" class="header-center">
数字建安施工管理平台
</el-col>
<el-col :span="8">
<div class="header-title-user-info">
<el-select v-model="selProject" popper-class="header-sel-project-pop"
style="width: 150px;margin-right: 20px;height:30px;line-height: 30px;"
@change="doProjectSelect">
<el-option v-for="it in projects" :key="it.id" :label="it.projectName"
:value="it.id"></el-option>
</el-select>
<span class="command" @click="doLogout">{{ nickName }}
<i class="el-icon-switch-button"></i>
</span>
</div>
</el-col>
</el-row>
</div>
2024-11-27 23:42:39 +08:00
</template>
<script>
export default {
2024-11-29 23:08:39 +08:00
data() {
2024-11-27 23:42:39 +08:00
return {
2024-11-29 23:08:39 +08:00
nav: 1,
selProject: '',
projects: []
2024-11-27 23:42:39 +08:00
}
},
2024-11-29 23:08:39 +08:00
computed: {
nickName() {
2024-11-27 23:42:39 +08:00
return this.$store.getters.nickName;
},
2024-11-29 23:08:39 +08:00
curNav() {
2024-11-27 23:42:39 +08:00
return this.$store.getters.nav;
}
},
2024-11-29 23:08:39 +08:00
watch: {
curNav(n, o) {
this.nav = this.$store.getters.nav;
2024-11-27 23:42:39 +08:00
}
},
2024-11-29 23:08:39 +08:00
mounted() {
window.xapp = this;
this.$api.project.findMyProjectList().then(d => {
this.projects = d.rows || [];
if (this.projects.length > 0) {
let id = localStorage.getItem("selProj") || this.projects[0].id
this.selProject = +id;
2024-11-27 23:42:39 +08:00
this.doProjectSelect();
}
});
},
2024-11-29 23:08:39 +08:00
methods: {
doProjectSelect() {
let tmps = this.projects.filter(d => d.id == this.selProject);
if (tmps.length > 0) {
this.$store.dispatch('SetSelProject', tmps[0]);
} else {
this.$store.dispatch('SetSelProject', null);
2024-11-27 23:42:39 +08:00
}
2024-11-29 23:08:39 +08:00
localStorage.setItem("selProj", this.selProject);
2024-11-27 23:42:39 +08:00
},
2024-11-29 23:08:39 +08:00
doNav(n) {
if (this.nav == n) {
2024-11-27 23:42:39 +08:00
return;
}
2024-11-29 23:08:39 +08:00
this.nav = n;
let path = ["/index", "/detail", "/prjSafety", "/prjQuality", "/prjProgress"][n - 1];
2024-11-27 23:42:39 +08:00
this.$router.push(path);
},
2024-11-29 23:08:39 +08:00
doLogout() {
2024-11-27 23:42:39 +08:00
this.$confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$store.dispatch('LogOut').then(() => {
location.href = '/';
})
}).catch(() => { });
}
}
}
</script>
<style lang="less">
2024-11-29 23:08:39 +08:00
.div-header {
2024-11-27 23:42:39 +08:00
line-height: 100px;
2024-11-29 23:08:39 +08:00
.header-center {
2024-11-27 23:42:39 +08:00
text-align: center;
color: #3da2ff;
font-size: 32px;
font-weight: bold;
}
}
2024-11-29 23:08:39 +08:00
@media (min-width: 1921px) and (max-width: 2560px) {
.div-header {
.head-nav {
2024-12-05 23:18:31 +08:00
font-size: 18px;
2024-11-29 23:08:39 +08:00
width: auto;
height: auto;
padding: 5px 40px;
position: relative;
top: -8px;
}
}
.header-center {
font-size: 42px !important;
margin-top: 10px;
}
.header-title-user-info {
font-size: 20px;
.el-select {
transform: scale(1.5);
margin-right: 60px !important;
position: relative;
top: -5px;
}
}
.header-sel-project-pop {
transform: scale(1.5);
width: 200px;
min-width: unset !important;
margin-left: 50px;
}
}
@media (min-width: 2561px) {
2024-12-07 12:49:34 +08:00
2024-11-29 23:08:39 +08:00
.header-center {
font-size: 52px !important;
margin-top: 10px;
}
.header-title-user-info {
font-size: 30px;
.el-select {
transform: scale(2);
margin-right: 100px !important;
position: relative;
top: -5px;
}
}
.header-sel-project-pop {
transform: scale(2);
width: 200px;
min-width: unset !important;
margin-left: 100px;
}
}
2024-11-27 23:42:39 +08:00
</style>