2022-08-22 09:24:56 +08:00
|
|
|
<template>
|
|
|
|
<div class="train">
|
|
|
|
<div v-show="maskOpen" class="trainMask" />
|
|
|
|
<jlmap-visual ref="jlmapVisual" />
|
|
|
|
<menu-demon ref="menuDemon" />
|
2022-08-24 17:52:33 +08:00
|
|
|
<voice-chat-box v-if="$route.query.lineCode == '19'" ref="chatbox" :group="group" :user-role="userRole" />
|
2022-08-22 09:24:56 +08:00
|
|
|
<chat-box v-else ref="chatbox" :group="group" :user-role="userRole" />
|
2022-08-24 17:52:33 +08:00
|
|
|
<training-tip ref="trainingTip" />
|
2022-08-22 09:24:56 +08:00
|
|
|
<div class="trainBack">
|
|
|
|
<el-button-group>
|
2022-08-24 17:52:33 +08:00
|
|
|
<el-button @click="nextStep">下一步</el-button>
|
|
|
|
<el-button v-if="!trainingSwitch && trainingDetail" type="success" @click="handlerStart">开始</el-button>
|
|
|
|
<el-button v-if="trainingSwitch" type="danger" @click="handlerEnd">结束</el-button>
|
2022-08-22 09:24:56 +08:00
|
|
|
<el-button type="primary" @click="back">返回</el-button>
|
|
|
|
</el-button-group>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import JlmapVisual from '@/views/newMap/jlmapNew/index';
|
|
|
|
import {loadMapDataById } from '@/utils/loaddata';
|
|
|
|
import { clearSimulation } from '@/api/simulation';
|
2022-08-24 17:52:33 +08:00
|
|
|
import { startTraining, endTraining, endTrainingStep } from '@/api/jmap/training';
|
2022-08-22 09:24:56 +08:00
|
|
|
import { creatSubscribe, clearSubscribe, displayTopic} from '@/utils/stomp';
|
|
|
|
import { getToken } from '@/utils/auth';
|
|
|
|
import chatBox from '@/views/newMap/chatView/chatBox.vue';
|
|
|
|
import VoiceChatBox from '@/views/newMap/chatView/voiceChatBox.vue';
|
2022-08-23 18:07:28 +08:00
|
|
|
import MenuDemon from './demonMenu.vue';
|
2022-08-24 17:52:33 +08:00
|
|
|
import TrainingTip from './trainingTip';
|
2022-08-22 09:24:56 +08:00
|
|
|
export default {
|
|
|
|
name: 'TrainingDesign',
|
|
|
|
components: {
|
|
|
|
JlmapVisual,
|
|
|
|
MenuDemon,
|
|
|
|
chatBox,
|
2022-08-24 17:52:33 +08:00
|
|
|
VoiceChatBox,
|
|
|
|
TrainingTip
|
2022-08-22 09:24:56 +08:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
widthLeft: {
|
|
|
|
type: Number,
|
2022-08-23 09:24:36 +08:00
|
|
|
default: 0
|
2022-08-22 09:24:56 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
maskOpen: false,
|
2022-08-23 09:24:36 +08:00
|
|
|
offsetBottom: 0,
|
|
|
|
trainingObj: null,
|
2022-08-24 17:52:33 +08:00
|
|
|
starting: false,
|
|
|
|
stepId: 1
|
2022-08-22 09:24:56 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
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;
|
|
|
|
},
|
2022-08-24 17:52:33 +08:00
|
|
|
teachMode() {
|
|
|
|
return this.$store.state.trainingNew.teachMode;
|
|
|
|
},
|
|
|
|
trainingSwitch() {
|
|
|
|
return this.$store.state.trainingNew.trainingSwitch;
|
|
|
|
},
|
|
|
|
trainingDetail() {
|
|
|
|
return this.$store.state.trainingNew.trainingDetail;
|
|
|
|
},
|
2022-08-22 09:24:56 +08:00
|
|
|
userRole() {
|
|
|
|
let role = 'AUDIENCE';
|
|
|
|
switch (this.$store.state.training.prdType) {
|
|
|
|
case '02': { role = 'DISPATCHER'; break; }
|
|
|
|
case '01': { role = 'STATION_SUPERVISOR'; break; }
|
|
|
|
case '04': { role = 'DRIVER'; break; }
|
|
|
|
case '05': { role = 'DEPOT_DISPATCHER'; break; }
|
|
|
|
default: { role = 'AUDIENCE'; break; }
|
|
|
|
}
|
|
|
|
return role;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
$route() {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.initLoadData();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
'$store.state.app.windowSizeCount': function() { // 窗口缩放
|
|
|
|
this.setWindowSize();
|
|
|
|
},
|
|
|
|
'$store.state.map.mapViewLoadedCount':function() {
|
|
|
|
this.$store.dispatch('map/setTrainWindowShow', false);
|
|
|
|
if (this.$route.query.group && !this.$route.path.includes('displayIscs')) {
|
|
|
|
this.subscribe();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'$store.state.socket.equipmentStatus': function (val) {
|
|
|
|
if (val.length && this.$route.query.group) {
|
|
|
|
this.statusMessage(val);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'$store.state.socket.simulationOver':function(val) {
|
|
|
|
this.backOut();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async beforeDestroy() {
|
|
|
|
await this.$store.dispatch('map/mapClear');
|
|
|
|
this.$store.dispatch('training/setPrdType', '');
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.$store.dispatch('training/setPrdType', '01');
|
|
|
|
this.setWindowSize();
|
|
|
|
this.initLoadData();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
initLoadData() { // 加载地图数据
|
|
|
|
if (this.$route.query.group) {
|
|
|
|
loadMapDataById(this.mapId, 'simulation');
|
|
|
|
} else {
|
|
|
|
this.$store.dispatch('training/changeMode', { mode: null });
|
|
|
|
loadMapDataById(this.mapId, 'preview');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
overallTranslation(flag) {
|
|
|
|
const panel = document.getElementById('leftSlider');
|
|
|
|
if (flag) {
|
|
|
|
panel.style.transform = 'translateX(400px)';
|
|
|
|
} else {
|
|
|
|
panel.style.transform = '';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async statusMessage(list) {
|
|
|
|
await this.$store.dispatch('training/updateMapState', list);
|
|
|
|
await this.$store.dispatch('socket/setEquipmentStatus');
|
|
|
|
},
|
|
|
|
setWindowSize() {
|
|
|
|
const width = this.width;
|
|
|
|
const height = this.height;
|
|
|
|
this.$store.dispatch('config/resize', { width, height });
|
|
|
|
},
|
|
|
|
async back() {
|
|
|
|
if (this.$route.query.group) {
|
|
|
|
await clearSimulation(this.$route.query.group);
|
|
|
|
this.clearSubscribe();
|
|
|
|
}
|
|
|
|
this.$store.dispatch('training/over').then(() => {
|
|
|
|
history.go(-1);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
backOut() {
|
|
|
|
if (this.$route.query.projectDevice) {
|
|
|
|
this.$store.dispatch('LogOut').then(() => {
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async subscribe() {
|
|
|
|
this.clearSubscribe();
|
|
|
|
const header = { group: this.$route.query.group || '', 'X-Token': getToken() };
|
|
|
|
creatSubscribe(`${displayTopic}\/${this.$route.query.group}`, header);
|
|
|
|
// await this.$store.dispatch('training/setHasSubscribed');
|
|
|
|
},
|
|
|
|
clearSubscribe() {
|
|
|
|
clearSubscribe(`${displayTopic}\/${this.$route.query.group}`);
|
2022-08-24 17:52:33 +08:00
|
|
|
},
|
|
|
|
handlerStart() {
|
|
|
|
startTraining(this.group, {mode: this.teachMode}).then(() => {
|
|
|
|
this.$store.dispatch('trainingNew/trainingStart');
|
|
|
|
}).catch(() => {
|
|
|
|
this.$message.error('开始实训失败!');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
nextStep() {
|
|
|
|
endTrainingStep(this.group, this.stepId).then(resp => {
|
|
|
|
this.stepId++;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handlerEnd() {
|
|
|
|
endTraining(this.group).then(() => {
|
|
|
|
this.$store.dispatch('trainingNew/trainingEnd');
|
|
|
|
this.$store.dispatch('socket/clearTrainingStepTip');
|
|
|
|
this.$store.dispatch('socket/setTrainingDetail', null);
|
|
|
|
this.stepId = 1;
|
|
|
|
}).catch(() => {
|
|
|
|
this.$message.error('结束实训失败!');
|
|
|
|
});
|
2022-08-22 09:24:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</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>
|