实训列表调整2
This commit is contained in:
parent
75e70ef63f
commit
2ef24a51e2
@ -57,9 +57,9 @@ export default {
|
|||||||
initLoadPage() {
|
initLoadPage() {
|
||||||
const trainingType = this.$store.state.training.domConfig ? this.$store.state.training.domConfig.trainingType : '';
|
const trainingType = this.$store.state.training.domConfig ? this.$store.state.training.domConfig.trainingType : '';
|
||||||
console.log(trainingType, this.$store.state.training.domConfig);
|
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;
|
this.trainingList = response.data;
|
||||||
// EventBus.$emit('setTrainingList', this.trainingList);
|
EventBus.$emit('setTrainingList', this.trainingList);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
this.$message.error(this.$t('tip.failedCourse') + ':' + error.message);
|
this.$message.error(this.$t('tip.failedCourse') + ':' + error.message);
|
||||||
});
|
});
|
||||||
|
@ -44,6 +44,14 @@
|
|||||||
<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 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>
|
</el-scrollbar>
|
||||||
</div>
|
</div>
|
||||||
<div class="drag-right" />
|
<div class="drag-right" />
|
||||||
@ -60,7 +68,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ScriptMode } from '@/scripts/ConstDic';
|
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 ScenePlayRole from './scenePlayRole';
|
||||||
import TestResult from './testResult';
|
import TestResult from './testResult';
|
||||||
import { EventBus } from '@/scripts/event-bus';
|
import { EventBus } from '@/scripts/event-bus';
|
||||||
@ -83,7 +91,10 @@ export default {
|
|||||||
TrainingMode: ScriptMode,
|
TrainingMode: ScriptMode,
|
||||||
activeName: 'first',
|
activeName: 'first',
|
||||||
training: {},
|
training: {},
|
||||||
trainingDesign: false
|
trainingDesign: false,
|
||||||
|
trainingList: [],
|
||||||
|
nextTraining: null,
|
||||||
|
previousTraining: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -103,10 +114,24 @@ export default {
|
|||||||
return this.$route.query.mapId;
|
return this.$route.query.mapId;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
'$store.state.trainingNew.trainingDetail': function(val) {
|
||||||
|
this.initAdjacentTraining();
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
EventBus.$on('setTrainingList', (trainingList) => {
|
||||||
|
this.trainingList = trainingList;
|
||||||
|
this.initAdjacentTraining();
|
||||||
|
});
|
||||||
this.trainingDesign = this.$store.state.training.domConfig.trainingDesign;
|
this.trainingDesign = this.$store.state.training.domConfig.trainingDesign;
|
||||||
},
|
},
|
||||||
methods: {
|
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() {
|
shrink() {
|
||||||
if (this.isShrink) {
|
if (this.isShrink) {
|
||||||
this.isShrink = false;
|
this.isShrink = false;
|
||||||
@ -154,13 +179,41 @@ export default {
|
|||||||
},
|
},
|
||||||
trainingListShow() {
|
trainingListShow() {
|
||||||
EventBus.$emit('handleSliderShow');
|
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>
|
</script>
|
||||||
<style rel="stylesheet/scss" lang="scss" scoped>
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
||||||
@import "src/styles/mixin.scss";
|
@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 {
|
.tip-body-box {
|
||||||
height: 260px;
|
height: 260px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -200,7 +253,7 @@ export default {
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
font-size: 18px;
|
font-size: 16px;
|
||||||
|
|
||||||
.tip-title {
|
.tip-title {
|
||||||
width: 500px;
|
width: 500px;
|
||||||
|
Loading…
Reference in New Issue
Block a user