rt-sim-training-client/src/views/display/menuReplay.vue

176 lines
5.7 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
<div>
<div>
<chart-view ref="chatView" :group="group"></chart-view>
</div>
<div class="draft-box">
<div class="draft-menu">
<el-row>
<el-col :span="4">
<el-select v-model="speed" placeholder="请选择" @change="changeSpeed">
<el-option v-for="item in optionsList" :key="item.value" :label="item.label" size="mini"
:value="item.value">
</el-option>
</el-select>
</el-col>
<el-col :span="4">
<el-button type="primary" @click="play" class="back btn">{{playName}}</el-button>
</el-col>
<el-col :span="12">
<el-progress class="progress" :percentage="progress" style="width: 100%" :show-text="false">
</el-progress>
</el-col>
<el-col :span="2">
<el-button type="primary" @click="back" class="back">返回</el-button>
</el-col>
</el-row>
</div>
</div>
</div>
</template>
<!-- 回放界面 -->
<script>
import { mapGetters } from 'vuex';
import { Notification } from 'element-ui';
import { exitFullscreen } from '@/utils/screen';
import ChartView from './demon/chatBox';
import { putsSimulationRecord, putsSimulationRecordPause, putsSimulationRecordPlay, putsSimulationRecordPlaySpeed, putsSimulationRecordplayTime } from '@/api/simulationRecord';
export default {
name: 'MenuReplay',
props: {
group: {
type: String,
required: true
},
offset: {
type: Number
}
},
components: {
ChartView,
},
data() {
return {
isDisable: false,
startLoading: false,
speed: '1X',
level: 1,
isPlay: true,
time: '',
timeInterval: null,
progress: 0,
schedule: 0,
optionsList: [
{
label: '1X',
value: '1',
},
{
label: '2X',
value: '2',
},
{
label: '4X',
value: '4',
},
{
label: '8X',
value: '8',
}
]
}
},
computed: {
...mapGetters('map', [
'mapDeviceStatus'
]),
playName() {
return this.isPlay ? '暂停' : '播放'
}
},
mounted() {
eventBus.$emit('showChat');
this.time = (+new Date(this.$route.query.destroyTime) - +new Date(this.$route.query.createTime)) / 1000;
this.timeIntervals();
},
beforeDestroy() {
clearInterval(this.timeInterval);
this.timeInterval = null;
},
methods: {
timeIntervals() {
let timebili = 100 / this.time;
if (!this.timeInterval) {
this.timeInterval = setInterval(() => {
if (this.isPlay) {
this.progress += (this.level) * timebili;
if (this.progress >= 100) {
clearInterval(this.timeInterval);
this.timeInterval = null;
this.progress = 100;
this.isPlay = false;
}
}
}, 1000);
}
},
async play() {
this.isPlay = !this.isPlay;
if (this.isPlay) {
if (this.progress >= 100) {
this.progress = 0;
this.timeIntervals();
this.$refs.chatView.clearTextList();
await putsSimulationRecordplayTime(this.$route.query.replayId, 0);
} else {
await putsSimulationRecordPlay(this.$route.query.replayId);
}
} else {
await putsSimulationRecordPause(this.$route.query.replayId);
}
},
async changeSpeed(val) {
this.level = val;
let res = await putsSimulationRecordPlaySpeed(this.$route.query.replayId, val);
},
async back() {
await putsSimulationRecord(this.$route.query.replayId);
history.go(-1);
Notification.closeAll();
exitFullscreen();
},
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.draft-box {
position: absolute;
display: inline;
width: 100%;
bottom: 10px;
.draft-menu {
position: static;
width: 800px;
float: right;
.back {
z-index: 100000;
/deep/ .el-button {
font-weight: bold;
}
}
.progress {
left: -30px;
position: relative;
top: 14px;
}
}
}
</style>