实训设计界面功能

This commit is contained in:
dong 2022-08-31 10:35:34 +08:00
parent 8161162b45
commit f72527f177
2 changed files with 68 additions and 5 deletions

View File

@ -5,6 +5,7 @@ const training = {
trainingDetail: null, // 实训详情 trainingDetail: null, // 实训详情
trainingSwitch: false, // 实训开始结束标志 trainingSwitch: false, // 实训开始结束标志
trainingOperate: null, trainingOperate: null,
simulationPause: false, // 实训 暂停判断
stepOrder: 1, stepOrder: 1,
operateOrder: 0, operateOrder: 0,
stepOverCount: 0 stepOverCount: 0
@ -51,6 +52,9 @@ const training = {
operateOrderIncrease: (state) => { operateOrderIncrease: (state) => {
state.operateOrder++; state.operateOrder++;
}, },
setSimulationPause: (state, value) => {
state.simulationPause = value;
},
clearOperateOrder: (state) => { clearOperateOrder: (state) => {
state.operateOrder = 0; state.operateOrder = 0;
}, },
@ -86,6 +90,9 @@ const training = {
operateOrderIncrease: ({commit}) => { operateOrderIncrease: ({commit}) => {
commit('operateOrderIncrease'); commit('operateOrderIncrease');
}, },
setSimulationPause: ({commit}, simulationPause) => {
commit('setSimulationPause', simulationPause);
},
clearOperateOrder: ({commit}) => { clearOperateOrder: ({commit}) => {
commit('clearOperateOrder'); commit('clearOperateOrder');
}, },

View File

@ -3,21 +3,26 @@
<menu-demon ref="menuDemon" /> <menu-demon ref="menuDemon" />
<training-jlmap refs="trainingJlmap" /> <training-jlmap refs="trainingJlmap" />
<training-tip ref="trainingTip" /> <training-tip ref="trainingTip" />
<el-button size="small" class="fault-button" :type="faultMode ? '':'primary' " @click="changeOperateMode()">{{ faultMode?'切换到普通模式':'切换到故障模式' }}</el-button>
<div class="trainBack"> <div class="trainBack">
<el-button-group> <el-button-group>
<el-button v-if="!trainingSwitch && trainingDetail" type="success" @click="handlerStart">开始</el-button> <el-button type="danger" size="small" @click="init">初始化</el-button>
<el-button v-if="trainingSwitch" type="danger" @click="handlerEnd">结束</el-button> <el-button v-if="!isPause" size="small" type="primary" @click="pauseScript">暂停</el-button>
<el-button type="primary" @click="back">返回</el-button> <el-button v-else size="small" type="primary" @click="executePlayScript">恢复</el-button>
<el-button v-if="!trainingSwitch && trainingDetail" type="success" size="small" @click="handlerStart">开始</el-button>
<el-button v-if="trainingSwitch" type="danger" size="small" @click="handlerEnd">结束</el-button>
<el-button type="primary" size="small" @click="back">返回</el-button>
</el-button-group> </el-button-group>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { clearSimulation } from '@/api/simulation'; import { clearSimulation, executeScriptNew, simulationPause, exitRunPlan } from '@/api/simulation';
import { startTraining, endTraining, endTrainingStep } from '@/api/jmap/training'; import { startTraining, endTraining, endTrainingStep } from '@/api/jmap/training';
import TrainingJlmap from './trainingJlmap'; import TrainingJlmap from './trainingJlmap';
import MenuDemon from '@/views/trainingManage/demonMenu.vue'; import MenuDemon from '@/views/trainingManage/demonMenu.vue';
import TrainingTip from './trainingTip'; import TrainingTip from './trainingTip';
import { OperateMode } from '@/scripts/ConstDic';
export default { export default {
name: 'TrainingDesign', name: 'TrainingDesign',
@ -28,7 +33,8 @@ export default {
}, },
data() { data() {
return { return {
groupModel: '' groupModel: '',
faultMode: false
}; };
}, },
computed: { computed: {
@ -52,6 +58,9 @@ export default {
}, },
trainingDetail() { trainingDetail() {
return this.$store.state.trainingNew.trainingDetail; return this.$store.state.trainingNew.trainingDetail;
},
isPause() {
return this.$store.state.trainingNew.simulationPause;
} }
}, },
watch: { watch: {
@ -68,6 +77,47 @@ export default {
this.groupModel = this.$route.query.group; this.groupModel = this.$route.query.group;
}, },
methods: { methods: {
changeOperateMode() {
this.faultMode = !this.faultMode;
let mode = OperateMode.NORMAL;
if (this.faultMode) {
mode = OperateMode.FAULT;
}
this.$store.dispatch('training/changeOperateMode', { mode: mode });
},
init() {
this.loading = true;
exitRunPlan(this.group).then(() => {
this.$store.dispatch('training/over').then(() => {
this.$store.dispatch('training/setMapDefaultState').then(() => {
this.$store.dispatch('map/clearJlmapTrainView');
this.$store.dispatch('map/resetActiveTrainList', false);
this.$store.dispatch('map/setTrainWindowShow', false);
this.$store.dispatch('map/initSimulationButton');
});
});
setTimeout(() => {
this.loading = false;
}, 1500);
}).catch(() => {
this.loading = false;
this.$messageBox(this.$t('display.demon.endSimulationFail'));
});
},
pauseScript() {
simulationPause(this.group).then(resp => {
this.$store.dispatch('trainingNew/setSimulationPause', true);
}).catch(() => {
this.$messageBox(this.$t('scriptRecord.pauseFail'));
});
},
executePlayScript() {
executeScriptNew(this.group).then(resp => {
this.$store.dispatch('trainingNew/setSimulationPause', false);
}).catch(() => {
this.$messageBox(this.$t('scriptRecord.recoverFail'));
});
},
async back() { async back() {
if (this.$route.query.group) { if (this.$route.query.group) {
await clearSimulation(this.$route.query.group); await clearSimulation(this.$route.query.group);
@ -95,6 +145,7 @@ export default {
this.$store.dispatch('socket/clearTrainingStepTip'); this.$store.dispatch('socket/clearTrainingStepTip');
this.$store.dispatch('trainingNew/clearStepOrder'); this.$store.dispatch('trainingNew/clearStepOrder');
this.$store.dispatch('trainingNew/changeTeachMode', ''); this.$store.dispatch('trainingNew/changeTeachMode', '');
this.$store.dispatch('trainingNew/setSimulationPause', false);
}).catch(() => { }).catch(() => {
this.$message.error('结束实训失败!'); this.$message.error('结束实训失败!');
}); });
@ -125,4 +176,9 @@ export default {
bottom: 15px; bottom: 15px;
z-index: 19; z-index: 19;
} }
.fault-button{
position: absolute;
top: 15px;
right: 32px;
}
</style> </style>