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

284 lines
6.2 KiB

3 years ago
<template>
<div :class="classObj" class="app-wrapper">
<div class="top-head-bar">
<div class="top-head-bar__logo">
3 years ago
<img style="height: 20px;" src="../assets/logo.png" alt="logo">
3 years ago
</div>
<ul>
3 years ago
<li v-for="item in $store.state.permission.rootMenu" :class="{'li-active':new RegExp(`^${item.path}`).test($route.path) && $route.path !== '/contract/system/menu'}" @click="menuClick(item)">{{ item.name }}</li>
3 years ago
</ul>
<div class="top-head-bar__user">
<el-dropdown class="avatar-container" trigger="click">
<div class="avatar-wrapper">
3 years ago
<div class="avatar-wrapper__name">{{ $store.state.user.name }}</div>
3 years ago
<i class="el-icon-caret-bottom" />
</div>
<el-dropdown-menu slot="dropdown" class="user-dropdown">
<router-link to="/">
<el-dropdown-item>
系统首页
</el-dropdown-item>
</router-link>
<el-dropdown-item divided>
<span style="display:block;">退出</span>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
<div v-if="device==='mobile'&&sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
<template v-if="$route.path === '/worker'">
3 years ago
<el-scrollbar style="padding-top: 50px;height: 100%;">
<worker></worker>
3 years ago
</el-scrollbar>
</template>
3 years ago
<template v-else-if="$route.path === '/bookmanage'">
3 years ago
<iframe ref="bookIframe" style="width: 100%;height: 100%;padding-top: 50px;" src="http://localhost:8014/admin/#/">你的浏览器不支持该iframe</iframe>
3 years ago
</template>
3 years ago
<template v-else>
<sidebar class="sidebar-container" />
<div class="main-container">
<div :class="{'fixed-header':fixedHeader}" v-if="false">
<navbar />
</div>
<el-scrollbar style="height: 100%">
<app-main />
</el-scrollbar>
</div>
</template>
</div>
</template>
<script>
import {
Navbar,
Sidebar,
AppMain
} from './components'
import ResizeMixin from './mixin/ResizeHandler'
3 years ago
import worker from "./components/worker/index.vue"
3 years ago
export default {
name: 'Layout',
components: {
Navbar,
Sidebar,
3 years ago
AppMain,
worker
3 years ago
},
mixins: [ResizeMixin],
data(){
return {
3 years ago
active:0
3 years ago
}
},
computed: {
sidebar() {
return this.$store.state.app.sidebar
},
device() {
return this.$store.state.app.device
},
fixedHeader() {
return this.$store.state.settings.fixedHeader
},
classObj() {
return {
hideSidebar: !this.sidebar.opened,
openSidebar: this.sidebar.opened,
withoutAnimation: this.sidebar.withoutAnimation,
mobile: this.device === 'mobile'
}
}
},
methods: {
handleClickOutside() {
this.$store.dispatch('app/closeSideBar', {
withoutAnimation: false
})
3 years ago
},
menuClick(item){
this.$router.push(item.path)
console.log(this.$route.path)
3 years ago
}
3 years ago
},
mounted() {
3 years ago
},
3 years ago
}
</script>
<style lang="scss" scoped>
@import "~@/styles/mixin.scss";
@import "~@/styles/variables.scss";
.app-wrapper {
@include clearfix;
position: relative;
height: 100%;
width: 100%;
&.mobile.openSidebar {
position: fixed;
top: 0;
}
}
.top-head-bar{
background: #338DE3FF;
height: 50px;
filter: drop-shadow(0 1px 1px #49a0f3);
display: grid;
3 years ago
grid-template-columns: auto .5fr 6fr .2fr 1fr;
3 years ago
grid-template-rows: 50px;
3 years ago
grid-template-areas:
"logo . menu . user";
z-index: 9999;
position: fixed;
top: 0;
left: 0;
right: 0;
&__logo{
3 years ago
height: 50px;
3 years ago
grid-area:logo;
3 years ago
display: flex;
align-items: center;
3 years ago
padding:0 20px;
}
3 years ago
@media screen and (max-width: 1000px){
&__logo{
display: none;
}
}
3 years ago
&__user{
grid-area: user;
}
ul{
grid-area:menu;
height: 100%;
display: flex;
justify-self: flex-end;
align-items: flex-end;
li{
color:#fff;
height: 40px;
line-height: 40px;
list-style: none;
transition: all 300ms ease-out;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
3 years ago
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
3 years ago
cursor: pointer;
3 years ago
padding: 0 20px;
position: relative;
&::after{
content:"";
background: #338DE3FF;
height: 3px;
width: 0;
border-radius: 1px;
transition: all 300ms ease-out;
position: absolute;
left: 6px;
bottom: 2px;
}
&+li{
margin-left: 20px;
}
&:hover{
background: #fff;
color:rgb(100,100,100);
&::after{
width: calc(100% - 12px);
}
}
}
.li-active{
background: #fff;
color:rgb(100,100,100);
&::after{
width: calc(100% - 12px);
}
}
}
}
.drawer-bg {
background: #000;
opacity: 0.3;
width: 100%;
top: 0;
height: 100%;
position: absolute;
z-index: 999;
}
.fixed-header {
position: fixed;
top: 0;
right: 0;
z-index: 9;
width: calc(100% - #{$sideBarWidth});
transition: width 0.28s;
}
.hideSidebar .fixed-header {
width: calc(100% - 54px)
}
.mobile .fixed-header {
width: 100%;
}
.avatar-container {
3 years ago
height: 100%;
3 years ago
margin-right: 30px;
3 years ago
.avatar-wrapper{
height: 100%;
display: flex;
align-items: center;
3 years ago
.user-avatar {
cursor: pointer;
width: 40px;
height: 40px;
border-radius: 10px;
}
3 years ago
&__name{
color: #fff;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
3 years ago
3 years ago
padding: 0 6px;
}
3 years ago
.el-icon-caret-bottom {
cursor: pointer;
3 years ago
color: #FFF;
3 years ago
position: absolute;
right: -20px;
font-size: 12px;
}
}
}
3 years ago
3 years ago
</style>