2022-08-22 09:24:56 +08:00
|
|
|
<template>
|
|
|
|
<div class="train">
|
|
|
|
<menu-demon ref="menuDemon" />
|
2022-08-29 16:51:36 +08:00
|
|
|
<training-jlmap refs="trainingJlmap" />
|
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 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 { clearSimulation } from '@/api/simulation';
|
2022-08-24 17:52:33 +08:00
|
|
|
import { startTraining, endTraining, endTrainingStep } from '@/api/jmap/training';
|
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-29 16:51:36 +08:00
|
|
|
import TrainingJlmap from './trainingJlmap';
|
2022-08-22 09:24:56 +08:00
|
|
|
export default {
|
|
|
|
name: 'TrainingDesign',
|
|
|
|
components: {
|
|
|
|
MenuDemon,
|
2022-08-29 16:51:36 +08:00
|
|
|
TrainingTip,
|
|
|
|
TrainingJlmap
|
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 {
|
2022-08-29 16:51:36 +08:00
|
|
|
// maskOpen: false,
|
2022-08-23 09:24:36 +08:00
|
|
|
trainingObj: null,
|
2022-08-24 17:52:33 +08:00
|
|
|
starting: false,
|
2022-08-29 11:06:11 +08:00
|
|
|
selected: null,
|
|
|
|
menus: null
|
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
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
2022-08-29 11:06:11 +08:00
|
|
|
'$store.state.trainingNew.trainingOperate':function(val) {
|
|
|
|
if (this.trainingSwitch && val) {
|
|
|
|
const stepList = JSON.parse(this.trainingDetail.stepJson);
|
|
|
|
const step = stepList.find(item => item.id == this.$store.state.trainingNew.stepOrder );
|
|
|
|
const operateIndex = step.operations.findIndex(item => item.id == this.$store.state.trainingNew.operateOrder);
|
|
|
|
this.checkOperation(val, step.operations[operateIndex], step.operations.length === (operateIndex + 1 ));
|
|
|
|
}
|
2022-08-22 09:24:56 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async beforeDestroy() {
|
2022-08-29 11:06:11 +08:00
|
|
|
this.$store.dispatch('socket/clearTrainingOverCount');
|
2022-08-22 09:24:56 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
},
|
|
|
|
methods: {
|
2022-08-29 11:06:11 +08:00
|
|
|
checkOperation(now, data, stepOver) {
|
|
|
|
let flag = true;
|
|
|
|
if (now.cmdType || data.operationType) {
|
|
|
|
const cmd = now.cmdType ? now.cmdType.value : '';
|
|
|
|
flag = (cmd === data.operationType) && flag;
|
|
|
|
}
|
|
|
|
if (now.code || data.deviceCode) {
|
|
|
|
flag = (now.code === data.deviceCode) && flag;
|
|
|
|
}
|
|
|
|
if (now.operation || data.domId) {
|
|
|
|
flag = (now.operation === data.domId) && flag;
|
|
|
|
}
|
|
|
|
if (now.userOperationType || data.userOperationType) {
|
|
|
|
flag = (now.userOperationType === data.userOperationType) && flag;
|
|
|
|
}
|
|
|
|
for (const param in data.params) {
|
|
|
|
flag = (now.params[param] === data.params[param]) && flag;
|
|
|
|
}
|
|
|
|
console.log(now, data, stepOver, flag);
|
|
|
|
if (flag && stepOver) {
|
|
|
|
this.nextStep();
|
|
|
|
} else if (flag) {
|
|
|
|
this.$store.dispatch('trainingNew/operateOrderIncrease');
|
|
|
|
} else {
|
|
|
|
console.error('校验失败;');
|
|
|
|
}
|
|
|
|
},
|
2022-08-22 09:24:56 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
},
|
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() {
|
2022-08-29 11:06:11 +08:00
|
|
|
endTrainingStep(this.group, this.$store.state.trainingNew.stepOrder).then(resp => {
|
|
|
|
this.$store.dispatch('trainingNew/clearOperateOrder');
|
|
|
|
this.$store.dispatch('trainingNew/stepOrderIncrease');
|
|
|
|
}).catch(() => {
|
|
|
|
this.$message.error('进入下一步实训失败!');
|
2022-08-24 17:52:33 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
handlerEnd() {
|
|
|
|
endTraining(this.group).then(() => {
|
|
|
|
this.$store.dispatch('trainingNew/trainingEnd');
|
|
|
|
this.$store.dispatch('socket/clearTrainingStepTip');
|
2022-08-29 11:06:11 +08:00
|
|
|
this.$store.dispatch('trainingNew/clearStepOrder');
|
|
|
|
this.$store.dispatch('trainingNew/setTrainingDetail', null);
|
2022-08-24 17:52:33 +08:00
|
|
|
}).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>
|