rt-sim-training-client/src/views/newMap/displayNew/menuSystemTime.vue

154 lines
4.6 KiB
Vue
Raw Normal View History

2019-12-30 09:00:16 +08:00
<template>
2020-05-25 10:32:14 +08:00
<div v-if="isShowSystemTime" class="display-card" :style="{top: top+'px', right: newRight+'px'}">
2019-12-30 09:00:16 +08:00
<template v-if="pause">
<span class="display-pause">{{ $t('display.systemTime.timePause') }}</span>
</template>
<template v-else>
<system-time
class="display-time"
:time="time"
/>
2020-05-25 10:32:14 +08:00
<div v-if="isShowDate" style="width: 80px;height: 58px;float: right;box-shadow: 0 0 5px #eee;">
<div class="display-date-box">{{ dateString }}</div>
<div class="display-date-box">{{ dayString }}</div>
</div>
2019-12-30 09:00:16 +08:00
</template>
</div>
</template>
<script>
import { prefixIntrger } from '@/utils/date';
import SystemTime from '@/views/components/systemTime/index';
2020-09-07 17:07:09 +08:00
import { timeFormat } from '@/utils/date';
2019-12-30 09:00:16 +08:00
// 顶部时间栏显示
export default {
name: 'MenuSystemTime',
components: {
SystemTime
},
props: {
offset: {
type: Number,
required: true
}
},
data() {
return {
2020-05-22 20:32:19 +08:00
time: '00:0000',
2020-05-25 10:32:14 +08:00
dateString: '00/00/00',
dayString: ''
2019-12-30 09:00:16 +08:00
};
},
computed: {
isShowSystemTime() {
return this.$route.params.mode == 'demon' ||
this.$route.params.mode == 'dp' ||
this.$route.params.mode == 'plan' ||
this.$route.params.mode == 'script' ||
this.$route.params.mode == 'practice' ||
2019-12-30 09:00:16 +08:00
!this.$route.params.mode;
},
pause() {
return this.$store.state.scriptRecord.simulationPause;
2020-05-25 10:32:14 +08:00
},
2020-06-11 18:32:26 +08:00
isDisplay() {
return this.$route.path.includes('displayNew') || this.$route.path.includes('scriptDisplayNew');
},
2020-07-27 13:15:01 +08:00
isShowDate() { // 西安一 三号线
2020-06-11 18:32:26 +08:00
return (this.$route.query.lineCode == 10 || this.$route.query.lineCode == 11) && this.isDisplay;
2020-05-25 10:32:14 +08:00
},
top() {
2020-08-28 10:59:44 +08:00
return this.isShowDate ? (this.$route.query.prdType == '05' ? 5 : this.offset - 10) : this.offset;
2020-05-25 10:32:14 +08:00
},
newRight() {
2020-07-28 11:29:39 +08:00
return this.isShowDate ? this.$store.state.config.width - 420 : this.$store.state.config.width / 2 - 55;
2019-12-30 09:00:16 +08:00
}
},
watch: {
'$store.state.training.initTime': function (initTime) {
const date = new Date(initTime);
2020-05-25 10:32:14 +08:00
this.initDate(date);
2020-09-07 17:07:09 +08:00
},
'$store.state.socket.simulationTimeSync': function (time) { // 仿真时间更新
this.$store.dispatch('training/setInitTime', +new Date(`${new Date().toLocaleDateString()} ${timeFormat(time)}`));
const date = new Date(+new Date(`${new Date().toLocaleDateString()} ${timeFormat(time)}`));
this.initDate(date);
2019-12-30 09:00:16 +08:00
}
2020-05-18 11:04:39 +08:00
},
mounted() {
const initTime = this.$store.state.training.initTime;
if (initTime > 0) {
const date = new Date(initTime);
2020-05-25 10:32:14 +08:00
this.initDate(date);
}
},
methods: {
initDate(date) {
2020-05-18 11:04:39 +08:00
this.time = `${prefixIntrger(date.getHours(), 2)}:${prefixIntrger(date.getMinutes(), 2)}${prefixIntrger(date.getSeconds(), 2)}`;
2020-05-25 10:32:14 +08:00
const years = date.getFullYear() + '';
let months = date.getMonth() + 1 + '';
let dates = date.getDate() + '';
if (months.length < 2) { months = '0' + months; }
if (dates.length < 2) { dates = '0' + dates; }
this.dateString = dates + '/' + months + '/' + years.slice(2);
const day = date.getDay();
switch (day) {
case 0:
2020-06-03 16:18:40 +08:00
this.dayString = '星 期 日';
2020-05-25 10:32:14 +08:00
break;
case 1:
2020-06-03 16:18:40 +08:00
this.dayString = '星 期 一';
2020-05-25 10:32:14 +08:00
break;
case 2:
2020-06-03 16:18:40 +08:00
this.dayString = '星 期 二';
2020-05-25 10:32:14 +08:00
break;
case 3:
2020-06-03 16:18:40 +08:00
this.dayString = '星 期 三';
2020-05-25 10:32:14 +08:00
break;
case 4:
2020-06-03 16:18:40 +08:00
this.dayString = '星 期 四';
2020-05-25 10:32:14 +08:00
break;
case 5:
2020-06-03 16:18:40 +08:00
this.dayString = '星 期 五';
2020-05-25 10:32:14 +08:00
break;
case 6:
2020-06-03 16:18:40 +08:00
this.dayString = '星 期 六';
2020-05-25 10:32:14 +08:00
}
2020-05-18 11:04:39 +08:00
}
2019-12-30 09:00:16 +08:00
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.display-card {
z-index: 9;
display: inline;
position: absolute;
}
.display-pause {
font-size: 21px;
font-weight: bold;
color: yellow;
}
.display-time{
padding: 3px 5px;
box-shadow: 0px 0px 5px #eee;
border-radius: 3px;
}
.display-card .el-row {
line-height: 32px !important;
}
2020-05-25 10:32:14 +08:00
.display-date-box{
height: 29px;
line-height: 29px;
background: #404040;
color: #1DEA1E;
text-align: center;
}
2019-12-30 09:00:16 +08:00
</style>