rt-sim-training-client/src/views/designPlatform/trainingPreview.vue
2022-08-30 15:38:26 +08:00

143 lines
4.1 KiB
Vue

<template>
<div class="train">
<menu-demon ref="menuDemon" />
<training-jlmap refs="trainingJlmap" />
<training-tip ref="trainingTip" />
<div class="trainBack">
<el-button-group>
<el-button v-if="!trainingSwitch && trainingDetail" type="success" @click="handlerStart">开始</el-button>
<el-button v-if="trainingSwitch" type="danger" @click="handlerEnd">结束</el-button>
<el-button type="primary" @click="back">返回</el-button>
</el-button-group>
</div>
</div>
</template>
<script>
import { clearSimulation } from '@/api/simulation';
import { startTraining, endTraining, endTrainingStep } from '@/api/jmap/training';
import MenuDemon from './demonMenu.vue';
import TrainingTip from './trainingTip';
import TrainingJlmap from './trainingJlmap';
export default {
name: 'TrainingDesign',
components: {
MenuDemon,
TrainingTip,
TrainingJlmap
},
props: {
widthLeft: {
type: Number,
default: 0
}
},
data() {
return {
// maskOpen: false,
trainingObj: null,
starting: false,
selected: null,
menus: null
};
},
computed: {
mapId() {
return this.$route.query.mapId;
},
width() {
return this.$store.state.app.width;
},
height() {
return this.$store.state.app.height;
},
group() {
return this.$route.query.group;
},
teachMode() {
return this.$store.state.trainingNew.teachMode;
},
trainingSwitch() {
return this.$store.state.trainingNew.trainingSwitch;
},
trainingDetail() {
return this.$store.state.trainingNew.trainingDetail;
}
},
watch: {
'$store.state.trainingNew.stepOverCount': function(val) {
this.nextStep();
}
},
async beforeDestroy() {
this.$store.dispatch('socket/clearTrainingOverCount');
this.$store.dispatch('training/clearStepOverCount');
},
mounted() {
},
methods: {
overallTranslation(flag) {
const panel = document.getElementById('leftSlider');
if (flag) {
panel.style.transform = 'translateX(400px)';
} else {
panel.style.transform = '';
}
},
async back() {
if (this.$route.query.group) {
await clearSimulation(this.$route.query.group);
}
},
handlerStart() {
startTraining(this.group, {mode: this.teachMode}).then(() => {
this.$store.dispatch('trainingNew/trainingStart');
}).catch(() => {
this.$message.error('开始实训失败!');
});
},
nextStep() {
endTrainingStep(this.group, this.$store.state.trainingNew.stepOrder).then(resp => {
this.$store.dispatch('trainingNew/clearOperateOrder');
this.$store.dispatch('trainingNew/stepOrderIncrease');
}).catch(() => {
this.$message.error('进入下一步实训失败!');
});
},
handlerEnd() {
endTraining(this.group).then(() => {
this.$store.dispatch('trainingNew/trainingEnd');
this.$store.dispatch('socket/clearTrainingStepTip');
this.$store.dispatch('trainingNew/clearStepOrder');
// this.$store.dispatch('trainingNew/setTrainingDetail', null);
}).catch(() => {
this.$message.error('结束实训失败!');
});
}
}
};
</script>
<style lang="scss" scoped>
.train {
width: 100%;
overflow: hidden;
position: relative;
}
.trainMask{
opacity: 1;
background: #000;
position: absolute;
right: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 9;
}
.trainBack {
position: absolute;
float: right;
right: 15px;
bottom: 15px;
z-index: 19;
}
</style>