<template>
|
<div class="full-screen-container">
|
<router-view class="router-view">
|
<template v-slot:function>
|
<a-space>
|
<button class="button" @click="handleLogout">切换用户</button>
|
<button class="button" @click="backToIndex">返回主页</button>
|
<button class="button">设置</button>
|
</a-space>
|
</template>
|
</router-view>
|
|
<div class="footer" v-if="$route.path!=='/terminal/login'">
|
<div>姓名:{{nickname()}}</div>
|
<div>当前时间:{{currentDateAndTime}}</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { mapActions, mapGetters } from 'vuex'
|
|
import moment from 'moment'
|
|
export default {
|
name: 'TerminalLayout',
|
data() {
|
return {
|
currentDateAndTime: null,
|
getDateAndTimeInterval: null
|
}
|
},
|
watch: {
|
'$route.path': {
|
handler(val) {
|
if (val === '/terminal/index' || val === '/terminal/login') document.title = 'MDC智慧车间'
|
}
|
}
|
},
|
created() {
|
this.getCurrentDateAndTime()
|
|
},
|
beforeDestroy() {
|
if (this.getDateAndTimeInterval) {
|
clearInterval(this.getDateAndTimeInterval)
|
this.getDateAndTimeInterval = null
|
}
|
},
|
methods: {
|
...mapActions(['Logout']),
|
|
...mapGetters(['nickname']),
|
|
handleLogout() {
|
const that = this
|
|
this.$confirm({
|
title: '提示',
|
content: '确定要切换用户吗 ?',
|
onOk() {
|
return that.Logout({}).then(() => {
|
window.location.reload()
|
}).catch(err => {
|
that.$message.error({
|
title: '错误',
|
description: err.message
|
})
|
})
|
},
|
onCancel() {
|
}
|
})
|
},
|
|
backToIndex() {
|
if (this.$route.path !== '/terminal/index') this.$router.push('/terminal/index')
|
},
|
|
// 获取当前日期和时间(1秒更新1次)
|
getCurrentDateAndTime() {
|
this.getDateAndTimeInterval = setInterval(() => this.currentDateAndTime = moment().format('YYYY-MM-DD HH:mm:ss'), 1000)
|
}
|
}
|
}
|
</script>
|
|
<style scoped lang="less">
|
.full-screen-container {
|
display: flex;
|
flex-direction: column;
|
height: 100vh;
|
|
.router-view {
|
flex: 1;
|
padding: 24px;
|
display: flex;
|
flex-direction: column;
|
}
|
}
|
|
.button {
|
font-weight: bold;
|
padding: 15px 15px;
|
border: 1px solid rgba(0, 0, 0, .2);
|
border-radius: 5px;
|
cursor: pointer;
|
box-shadow: 6px 6px 16px rgba(0, 0, 0, 0.2),
|
-6px -6px 16px rgba(255, 255, 255, 0.8),
|
inset 0 0 0 transparent;
|
|
&:hover {
|
box-shadow: 0 0 0 transparent,
|
inset 6px 6px 12px rgba(0, 0, 0, 0.2),
|
inset -6px -6px 12px rgba(255, 255, 255, 0.8);
|
}
|
}
|
|
.footer {
|
font-size: 16px;
|
padding: 12px 24px;
|
color: #000;
|
display: flex;
|
justify-content: space-between;
|
}
|
</style>
|