实训列表调整2

This commit is contained in:
fan 2022-12-07 10:15:21 +08:00
parent 75e70ef63f
commit 2ef24a51e2
2 changed files with 59 additions and 6 deletions

View File

@ -57,9 +57,9 @@ export default {
initLoadPage() {
const trainingType = this.$store.state.training.domConfig ? this.$store.state.training.domConfig.trainingType : '';
console.log(trainingType, this.$store.state.training.domConfig);
getPublishTrainingListInOrg({mapId: this.mapId, type: trainingType.toLowerCase() + 's'}).then(response => {
getPublishTrainingListInOrg({mapId: this.mapId, type: trainingType.toLowerCase()}).then(response => {
this.trainingList = response.data;
// EventBus.$emit('setTrainingList', this.trainingList);
EventBus.$emit('setTrainingList', this.trainingList);
}).catch(error => {
this.$message.error(this.$t('tip.failedCourse') + ':' + error.message);
});

View File

@ -44,6 +44,14 @@
<el-button v-if="trainingSwitch" size="small" type="danger" @click="handlerEnd">结束</el-button>
</span>
</p>
<p class="list-item">
<span class="list-label"> </span>
<span class="list-elem elem-span training-box" @click="loadTraining(previousTraining)">{{ previousTraining? previousTraining.name: '' }}</span>
</p>
<p class="list-item">
<span class="list-label"> </span>
<span class="list-elem elem-span training-box" @click="loadTraining(nextTraining)">{{ nextTraining? nextTraining.name:'' }}</span>
</p>
</el-scrollbar>
</div>
<div class="drag-right" />
@ -60,7 +68,7 @@
<script>
import { ScriptMode } from '@/scripts/ConstDic';
import { startTraining, endTraining } from '@/api/jmap/training';
import { startTraining, endTraining, getPublishTrainingDetail, loadPublishTraining } from '@/api/jmap/training';
import ScenePlayRole from './scenePlayRole';
import TestResult from './testResult';
import { EventBus } from '@/scripts/event-bus';
@ -83,7 +91,10 @@ export default {
TrainingMode: ScriptMode,
activeName: 'first',
training: {},
trainingDesign: false
trainingDesign: false,
trainingList: [],
nextTraining: null,
previousTraining: null
};
},
computed: {
@ -103,10 +114,24 @@ export default {
return this.$route.query.mapId;
}
},
watch: {
'$store.state.trainingNew.trainingDetail': function(val) {
this.initAdjacentTraining();
}
},
mounted() {
EventBus.$on('setTrainingList', (trainingList) => {
this.trainingList = trainingList;
this.initAdjacentTraining();
});
this.trainingDesign = this.$store.state.training.domConfig.trainingDesign;
},
methods: {
initAdjacentTraining() {
const index = this.trainingList.findIndex(training => this.trainingDetail && training.id === this.trainingDetail.id);
this.previousTraining = this.trainingList[index - 1];
this.nextTraining = this.trainingList[index + 1];
},
shrink() {
if (this.isShrink) {
this.isShrink = false;
@ -154,13 +179,41 @@ export default {
},
trainingListShow() {
EventBus.$emit('handleSliderShow');
},
async loadTraining(training) {
if (this.trainingSwitch) {
this.$message.error('请先结束当前实训后再加载新的实训!');
return;
}
try {
const detailResp = await getPublishTrainingDetail(training.id);
this.training = detailResp.data;
if (detailResp.data.mapLocationJson) {
const mapLocation = JSON.parse(detailResp.data.mapLocationJson);
this.$jlmap.updateTransform(mapLocation.scale, {x:mapLocation.x, y:mapLocation.y});
}
this.$store.dispatch('trainingNew/setTrainingDetail', detailResp.data);
await loadPublishTraining(this.group, training.id, {mode: ''});
this.$message.success('加载实训成功!');
} catch (e) {
this.$message.error('加载实训失败!');
}
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.list-item{
margin-top: 15px;
margin-bottom: 15px;
}
.training-box{
cursor: pointer;
}
.training-box:hover{
color: dodgerblue;
}
.tip-body-box {
height: 260px;
position: absolute;
@ -200,7 +253,7 @@ export default {
border-radius: 5px;
overflow: hidden;
z-index: 10;
font-size: 18px;
font-size: 16px;
.tip-title {
width: 500px;