<template>
|
<div class="full-screen-container">
|
<router-view class="router-view">
|
<template v-slot:function>
|
<a-space class="common-button-container">
|
<a-button type="primary" @click="handleLogout" size="large">切换用户</a-button>
|
<a-button @click="backToIndex" size="large">返回主页</a-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: moment().format('YYYY-MM-DD HH:mm:ss'),
|
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;
|
background-color: #fff;
|
|
.router-view {
|
flex: 1;
|
padding: 1.25vw;
|
display: flex;
|
flex-direction: column;
|
}
|
}
|
|
.common-button-container {
|
margin-bottom: 1vw;
|
}
|
|
.footer {
|
font-size: 0.8vw;
|
padding: 0.5vw 0;
|
color: #000;
|
/*font-weight: bold;*/
|
text-align: center;
|
}
|
</style>
|