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() {
this.initLoadData();
if (!this.isLesson) {
this.initLoadData();
}
}
},
beforeDestroy() {

View File

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

View File

@ -34,6 +34,7 @@ import { trainingNotifyNew } from '@/api/simulation';
import { TrainingMode, UrlConfig } from '@/scripts/ConstDic';
import { timeFormat } from '@/utils/date';
import { getTrainingStepsDetailNew } from '@/api/jmap/training';
import { EventBus } from '@/scripts/event-bus';
export default {
name: 'MenuLesson',
@ -110,23 +111,15 @@ export default {
this.isDisable = false;
},
'$store.state.map.mapViewLoadedCount': function (val) {
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); //
}).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;
this.getTrainingData();
},
'$store.state.training.operateErrMsg': function (val) {
this.tipInfo({ color: val.color, message: val.errMsg });
},
async $route() {
await this.initData();
await this.getTrainingData();
this.endViewLoading(true);
}
},
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) {
const panel = document.getElementById('leftSlider');
if (flag) {
@ -262,8 +277,8 @@ export default {
const resp = await getTrainingDetailNew(this.$route.query.trainingId);
this.$store.dispatch('exam/setCenter', resp.data.locateDeviceCode);
if (resp && resp.code == 200) {
const detail = resp.data;
await this.$store.dispatch('training/setPrdType', this.prdTypeMap[detail.prdType]);
// const detail = resp.data;
// await this.$store.dispatch('training/setPrdType', this.prdTypeMap[detail.prdType]);
} else {
this.$messageBox(`获取实训步骤数据失败`);
this.endViewLoading();
@ -277,6 +292,9 @@ export default {
if (!isSuccess) {
this.$store.dispatch('map/mapClear');
}
this.$nextTick(() => {
EventBus.$emit('viewLoading', false);
});
}
}
};