竞赛流程调整暂提

This commit is contained in:
fan 2024-03-04 14:26:45 +08:00
parent c60127798c
commit 303837765a
4 changed files with 73 additions and 11 deletions

View File

@ -15,3 +15,20 @@ export function selectQuestionTypeNum(companyId) {
method: 'get' method: 'get'
}); });
} }
/** 加载场景 */
export function loadRace(simulationId, sceneId) {
return request({
url: `/api/race/${simulationId}/load/${sceneId}`,
method: 'put'
});
}
/** 完成任务 */
export function overTask(taskId, data) {
return request({
url: `/api/race/${taskId}/finish`,
method: 'put',
data
});
}

View File

@ -154,6 +154,8 @@ export default {
project: 'dsxl', project: 'dsxl',
paperId: this.$route.query.paperId, paperId: this.$route.query.paperId,
moduleId: this.$route.query.moduleId, moduleId: this.$route.query.moduleId,
sceneId: this.nowData.sceneId,
taskId: this.nowData.id,
nowKey: this.nowKey nowKey: this.nowKey
}; };
this.$router.push({ path: '/display/demon', query: query }); this.$router.push({ path: '/display/demon', query: query });

View File

@ -126,6 +126,15 @@ export default {
this.stepIndex = data.index; this.stepIndex = data.index;
this.stepDetail = data.data; this.stepDetail = data.data;
this.trainingType = data.type; this.trainingType = data.type;
if (!this.stepDetail.operations) {
this.stepDetail.operations = [];
}
if (!this.stepDetail.simCommands) {
this.stepDetail.simCommands = [];
}
if (!this.stepDetail.tipPosition) {
this.stepDetail.tipPosition = {};
}
}, },
clearOperation() { clearOperation() {
this.$confirm('清除操作将清除所有关联操作', '提示', { this.$confirm('清除操作将清除所有关联操作', '提示', {

View File

@ -44,11 +44,11 @@
<el-button v-if="trainingSwitch" size="small" type="danger" @click="handlerEnd">结束</el-button> <el-button v-if="trainingSwitch" size="small" type="danger" @click="handlerEnd">结束</el-button>
</span> </span>
</p> </p>
<p v-if="!examSwitch && simulationCreator" class="list-item"> <p v-if="!examSwitch && simulationCreator && !isRace" class="list-item">
<span class="list-label"> </span> <span class="list-label"> </span>
<span class="list-elem elem-span training-box" @click="loadTraining(previousTraining)">{{ previousTraining? previousTraining.name: '' }}</span> <span class="list-elem elem-span training-box" @click="loadTraining(previousTraining)">{{ previousTraining? previousTraining.name: '' }}</span>
</p> </p>
<p v-if="!examSwitch && simulationCreator" class="list-item"> <p v-if="!examSwitch && simulationCreator && !isRace" class="list-item">
<span class="list-label"> </span> <span class="list-label"> </span>
<span class="list-elem elem-span training-box" @click="loadTraining(nextTraining)">{{ nextTraining? nextTraining.name:'' }}</span> <span class="list-elem elem-span training-box" @click="loadTraining(nextTraining)">{{ nextTraining? nextTraining.name:'' }}</span>
</p> </p>
@ -69,6 +69,8 @@
<script> <script>
import { ScriptMode } from '@/scripts/ConstDic'; import { ScriptMode } from '@/scripts/ConstDic';
import { startTraining, endTraining, getPublishTrainingDetail, loadPublishTraining, prepareScene } from '@/api/jmap/training'; import { startTraining, endTraining, getPublishTrainingDetail, loadPublishTraining, prepareScene } from '@/api/jmap/training';
import { loadRace, overTask } from '@/api/race';
import { getContextSenceDetail } from '@/api/contest';
import ScenePlayRole from './scenePlayRole'; import ScenePlayRole from './scenePlayRole';
import TestResult from './testResult'; import TestResult from './testResult';
import { EventBus } from '@/scripts/event-bus'; import { EventBus } from '@/scripts/event-bus';
@ -119,11 +121,14 @@ export default {
}, },
simulationCreator() { simulationCreator() {
return this.$store.state.training.simulationCreator; return this.$store.state.training.simulationCreator;
},
isRace() {
return this.$route.query.paperId;
} }
}, },
watch: { watch: {
'$store.state.map.mapViewLoadedCount': function (val) { '$store.state.map.mapViewLoadedCount': function (val) {
// this.loadTraining({ id: 12483 }); this.loadRaceScene(this.$route.query.sceneId);
}, },
'$store.state.trainingNew.trainingDetail': function(val) { '$store.state.trainingNew.trainingDetail': function(val) {
this.initAdjacentTraining(); this.initAdjacentTraining();
@ -204,6 +209,15 @@ export default {
trainDetail: this.$store.state.trainingNew.stepRecord trainDetail: this.$store.state.trainingNew.stepRecord
}; };
EventBus.$emit('trainExamSubmit', data); EventBus.$emit('trainExamSubmit', data);
} else {
if (this.isRace) {
overTask(this.$route.query.taskId, {simulationId: this.group, scoreList: this.$store.state.trainingNew.stepRecord }).then((resp) => {
if (this.demoMode === ScriptMode.TEST) {
this.$refs.testResult.doShow(resp.data);
}
}).catch((e) => {
this.$message.error('结束任务失败!');
});
} else { } else {
endTraining(this.group, this.$store.state.trainingNew.stepRecord).then((resp) => { endTraining(this.group, this.$store.state.trainingNew.stepRecord).then((resp) => {
if (this.demoMode === ScriptMode.TEST) { if (this.demoMode === ScriptMode.TEST) {
@ -214,10 +228,30 @@ export default {
this.$message.error('结束实训失败!'); this.$message.error('结束实训失败!');
}); });
} }
}
}, },
trainingListShow() { trainingListShow() {
EventBus.$emit('handleSliderShow'); EventBus.$emit('handleSliderShow');
}, },
async loadRaceScene(sceneId) {
if (this.trainingSwitch) {
this.$message.error('请先结束当前实训后再加载新的实训!');
return;
}
try {
const detailResp = await getContextSenceDetail(sceneId);
this.training = detailResp.data.scene.storageSimulation;
if (this.training.mapLocationJson) {
const mapLocation = JSON.parse(this.training.mapLocationJson);
this.$jlmap.updateTransform(mapLocation.scale, {x:mapLocation.x, y:mapLocation.y});
}
this.$store.dispatch('trainingNew/setTrainingDetail', this.training);
await loadRace(this.group, sceneId, {mode: ''});
this.$message.success('加载场景成功!');
} catch (e) {
this.$message.error('加载场景失败!');
}
},
async loadTraining(training) { async loadTraining(training) {
if (this.trainingSwitch) { if (this.trainingSwitch) {
this.$message.error('请先结束当前实训后再加载新的实训!'); this.$message.error('请先结束当前实训后再加载新的实训!');