This commit is contained in:
fan 2020-11-25 10:29:14 +08:00
commit 9ef4299527
3 changed files with 48 additions and 28 deletions

View File

@ -118,7 +118,9 @@ export default {
} }
}, },
$route() { $route() {
this.initLoadData(); if (!this.isLesson) {
this.initLoadData();
}
} }
}, },
beforeDestroy() { beforeDestroy() {

View File

@ -38,7 +38,7 @@
<script> <script>
import { getPublishLessonTree } from '@/api/jmap/lesson'; import { getPublishLessonTree } from '@/api/jmap/lesson';
import { trainingNotifyNew } from '@/api/simulation'; // import { trainingNotifyNew } from '@/api/simulation';
import { launchFullscreen } from '@/utils/screen'; import { launchFullscreen } from '@/utils/screen';
import { UrlConfig } from '@/scripts/ConstDic'; import { UrlConfig } from '@/scripts/ConstDic';
export default { export default {
@ -92,16 +92,16 @@ export default {
if (obj && obj.type === 'Training') { if (obj && obj.type === 'Training') {
if (obj.valid) { if (obj.valid) {
this.disabled = true; this.disabled = true;
trainingNotifyNew({ trainingId: obj.id }).then(resp => { // trainingNotifyNew({ trainingId: obj.id }).then(resp => {
const query = { const query = {
group: resp.data, trainingId: obj.id, lessonId: this.$route.query.lessonId, mapId: this.$route.query.mapId, lineCode:this.$route.query.lineCode, noPreLogout: this.$route.query.noPreLogout group: this.$route.query.group, trainingId: obj.id, lessonId: this.$route.query.lessonId, mapId: this.$route.query.mapId, lineCode:this.$route.query.lineCode, noPreLogout: this.$route.query.noPreLogout
}; };
this.$router.replace({ path: `${UrlConfig.displayNew}/teach`, query: query }); this.$router.replace({ path: `${UrlConfig.displayNew}/teach`, query: query });
launchFullscreen(); launchFullscreen();
}).catch(error => { // }).catch(error => {
this.$messageBox(`${this.$t('tip.createSimulationFaild')} : ${error.message}`); // this.$messageBox(`${this.$t('tip.createSimulationFaild')} : ${error.message}`);
this.disabled = false; // this.disabled = false;
}); // });
} else { } else {
this.$confirm(this.$t('tip.accessCourseNo'), this.$t('tip.hint'), { this.$confirm(this.$t('tip.accessCourseNo'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'), confirmButtonText: this.$t('tip.confirm'),

View File

@ -34,6 +34,7 @@ import { trainingNotifyNew } from '@/api/simulation';
import { TrainingMode, UrlConfig } from '@/scripts/ConstDic'; import { TrainingMode, UrlConfig } from '@/scripts/ConstDic';
import { timeFormat } from '@/utils/date'; import { timeFormat } from '@/utils/date';
import { getTrainingStepsDetailNew } from '@/api/jmap/training'; import { getTrainingStepsDetailNew } from '@/api/jmap/training';
import { EventBus } from '@/scripts/event-bus';
export default { export default {
name: 'MenuLesson', name: 'MenuLesson',
@ -110,23 +111,15 @@ export default {
this.isDisable = false; this.isDisable = false;
}, },
'$store.state.map.mapViewLoadedCount': function (val) { '$store.state.map.mapViewLoadedCount': function (val) {
if (this.$route.query.trainingId) { this.getTrainingData();
//
getTrainingStepsDetailNew(this.$route.query.trainingId, { group: this.group }).then(resp => {
this.trainingObj = resp.data;
this.$store.dispatch('training/setTrainingData', this.trainingObj); //
}).catch(error => {
this.$messageBox(`初始化失败实训内容失败: ${error.message}`);
});
}
this.$store.dispatch('training/end', null);
this.$store.dispatch('training/reset');
this.$store.dispatch('training/emitTipFresh');
this.$store.dispatch('menuOperation/setButtonOperation', null);
this.isDisable = false;
}, },
'$store.state.training.operateErrMsg': function (val) { '$store.state.training.operateErrMsg': function (val) {
this.tipInfo({ color: val.color, message: val.errMsg }); this.tipInfo({ color: val.color, message: val.errMsg });
},
async $route() {
await this.initData();
await this.getTrainingData();
this.endViewLoading(true);
} }
}, },
mounted() { mounted() {
@ -143,6 +136,28 @@ export default {
}); });
} }
}, },
getTrainingData() {
if (this.$route.query.trainingId) {
//
getTrainingStepsDetailNew(this.$route.query.trainingId, { group: this.group }).then(resp => {
this.trainingObj = resp.data;
this.$store.dispatch('training/setTrainingData', this.trainingObj); //
const detail = resp.data;
this.$store.dispatch('training/setPrdType', this.prdTypeMap[detail.prdType]);
}).catch(error => {
this.$messageBox(`初始化失败实训内容失败: ${error.message}`);
});
}
this.$store.dispatch('training/end', null);
this.$store.dispatch('training/reset');
this.$store.dispatch('training/emitTipFresh');
this.$store.dispatch('menuOperation/setButtonOperation', null);
this.$store.dispatch('training/setStopCountTime');
this.$store.dispatch('training/setScore', 0);
this.$store.dispatch('training/setTrainingStart', false);
this.isDisable = false;
},
overallTranslation(flag) { overallTranslation(flag) {
const panel = document.getElementById('leftSlider'); const panel = document.getElementById('leftSlider');
if (flag) { if (flag) {
@ -262,8 +277,8 @@ export default {
const resp = await getTrainingDetailNew(this.$route.query.trainingId); const resp = await getTrainingDetailNew(this.$route.query.trainingId);
this.$store.dispatch('exam/setCenter', resp.data.locateDeviceCode); this.$store.dispatch('exam/setCenter', resp.data.locateDeviceCode);
if (resp && resp.code == 200) { if (resp && resp.code == 200) {
const detail = resp.data; // const detail = resp.data;
await this.$store.dispatch('training/setPrdType', this.prdTypeMap[detail.prdType]); // await this.$store.dispatch('training/setPrdType', this.prdTypeMap[detail.prdType]);
} else { } else {
this.$messageBox(`获取实训步骤数据失败`); this.$messageBox(`获取实训步骤数据失败`);
this.endViewLoading(); this.endViewLoading();
@ -277,6 +292,9 @@ export default {
if (!isSuccess) { if (!isSuccess) {
this.$store.dispatch('map/mapClear'); this.$store.dispatch('map/mapClear');
} }
this.$nextTick(() => {
EventBus.$emit('viewLoading', false);
});
} }
} }
}; };