From ae500285ba44178564813a8ff6e2d1dd2eb97681 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Mon, 19 Aug 2019 15:59:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=9E=E8=AE=AD=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E9=A1=BA=E5=BA=8F=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/jmap/training.js | 4 +-- src/i18n/langs/en/error.js | 1 + src/i18n/langs/zh/error.js | 3 ++- src/jmap/map.js | 2 +- src/views/display/index.vue | 22 +++++++++++----- src/views/display/tipExamList.vue | 8 +++--- src/views/exam/detail/questionDetail.vue | 6 ++--- .../lesson/trainingrecord/category/draft.vue | 2 +- src/views/lesson/trainingrecord/index.vue | 1 - .../lesson/trainingrecord/manage/index.vue | 26 +++++++++++++------ src/views/teach/practical/index.vue | 6 ++--- 11 files changed, 49 insertions(+), 32 deletions(-) diff --git a/src/api/jmap/training.js b/src/api/jmap/training.js index 4b4b16e5c..516158387 100644 --- a/src/api/jmap/training.js +++ b/src/api/jmap/training.js @@ -53,9 +53,9 @@ export function getTrainingTree() { } /** 获取章节基本信息*/ -export function getTrainingDetail(args) { +export function getTrainingDetail(trainingId) { return request({ - url: `/api/training/${args.id}`, + url: `/api/training/${trainingId}`, method: 'get' }); } diff --git a/src/i18n/langs/en/error.js b/src/i18n/langs/en/error.js index 37c3bf268..9211cff3a 100644 --- a/src/i18n/langs/en/error.js +++ b/src/i18n/langs/en/error.js @@ -3,6 +3,7 @@ export default { createSimulationFailed: 'Failure to create simulation', loadMapDataFailed: 'Failed to load map data', getMapStepsFailed: 'Failed to get map step data', + getMapDetailFailed: 'Failed to get map detail', resetFailed: 'Reset failure', startTrainingFailed: 'Failure to start training', saveBackgroundFailed: 'Failed to save background', diff --git a/src/i18n/langs/zh/error.js b/src/i18n/langs/zh/error.js index 1b35b669c..73d0d7695 100644 --- a/src/i18n/langs/zh/error.js +++ b/src/i18n/langs/zh/error.js @@ -2,7 +2,8 @@ export default { refreshFailed: '刷新失败', createSimulationFailed: '创建仿真失败', loadMapDataFailed: '加载地图数据失败', - getMapStepsFailed: '获取地图步骤数据', + getMapStepsFailed: '获取地图步骤数据失败', + getMapDetailFailed: '获取地图详细信息失败', resetFailed: '重置失败', startTrainingFailed: '开始实训失败', saveBackgroundFailed: '保存背景失败', diff --git a/src/jmap/map.js b/src/jmap/map.js index 8ccc23e9c..9e1e77b74 100644 --- a/src/jmap/map.js +++ b/src/jmap/map.js @@ -248,7 +248,7 @@ class Jlmap { }); // 状态后处理 - this.postHandle(list); + this.postHandle(list || []); if (this.methods.stateUpdate instanceof Function) { this.methods.stateUpdate(list); } } diff --git a/src/views/display/index.vue b/src/views/display/index.vue index 1e705151f..ceba25c88 100644 --- a/src/views/display/index.vue +++ b/src/views/display/index.vue @@ -70,7 +70,7 @@ import MenuScript from '@/views/display/menuScript'; import WindowResizeHandler from '@/mixin/WindowResizeHandler'; import AddQuest from './demon/addQuest'; import { mapGetters } from 'vuex'; -import { getTrainingStepsDetail } from '@/api/jmap/training'; +import { getTrainingDetail, getTrainingStepsDetail } from '@/api/jmap/training'; import { setGoodsTryUse } from '@/api/management/goods'; import { getProductDetail } from '@/api/management/mapprd'; import { runDiagramQuit, loadScript, getSimulationInfo } from '@/api/simulation'; @@ -181,6 +181,14 @@ export default { '$store.state.map.mapViewLoadedCount': function (val) { this.mapBoxP = document.getElementById(this.canvasId).children[0]; this.mapBox = document.getElementsByTagName('canvas'); + + if (this.trainingId) { + getTrainingStepsDetail(this.trainingId, { group: this.group }).then(resp => { + this.trainingObj = resp.data; + this.$store.dispatch('training/setTrainingData', this.trainingObj); + }); + } + }, '$store.state.socket.permissionOver': function () { this.$alert('用户权限已被收回', '提示', { @@ -349,14 +357,14 @@ export default { if (parseInt(this.trainingId)) { // 设置地图数据 // 设置实训数据 - const resp = await getTrainingStepsDetail(this.trainingId, { group: this.group }); + const resp = await getTrainingDetail(this.trainingId); if (resp && resp.code == 200) { - const stepdData = this.trainingObj = resp.data; - const rest = await getProductDetail(stepdData.prdCode); + const detail = resp.data; + const rest = await getProductDetail(detail.prdCode); if (rest && rest.code == 200) { - await this.$store.dispatch('training/setPrdType', rest.data.prdType); - await this.loadMapData(resp.data.skinCode); - await this.$store.dispatch('training/setTrainingData', stepdData); + const data = rest.data; + await this.$store.dispatch('training/setPrdType', data.prdType); + await this.loadMapData(detail.skinCode); } } else { this.$messageBox(`获取实训步骤数据失败`); diff --git a/src/views/display/tipExamList.vue b/src/views/display/tipExamList.vue index aa889654f..c6fbe9f82 100644 --- a/src/views/display/tipExamList.vue +++ b/src/views/display/tipExamList.vue @@ -140,10 +140,8 @@ export default { } }); if (obj) { - const that = this; - const data = { id: obj.trainingId }; - getTrainingDetail(data).then(res => { - that.courseModel = { + getTrainingDetail(obj.trainingId ).then(res => { + this.courseModel = { id: res.data.id, name: res.data.name, maxDuration: res.data.maxDuration, @@ -152,7 +150,7 @@ export default { updateTime: res.data.updateTime }; }).catch(error => { - that.$message.error('获取试题息失败:' + error.message); + this.$message.error('获取试题息失败:' + error.message); }); } diff --git a/src/views/exam/detail/questionDetail.vue b/src/views/exam/detail/questionDetail.vue index f6a531a2a..0af3c608a 100644 --- a/src/views/exam/detail/questionDetail.vue +++ b/src/views/exam/detail/questionDetail.vue @@ -78,9 +78,9 @@ export default { this.height = this._clientHeight; }, initLoadPage() { - const data = { id: this.$route.query.trainingId }; - if (parseInt(data.id)) { - getTrainingDetail(data).then(res => { + const trainingId = this.$route.query.trainingId; + if (parseInt(trainingId)) { + getTrainingDetail(trainingId).then(res => { this.courseModel = { id: res.data.id, name: res.data.name, diff --git a/src/views/lesson/trainingrecord/category/draft.vue b/src/views/lesson/trainingrecord/category/draft.vue index 99de0b45e..65bad1203 100644 --- a/src/views/lesson/trainingrecord/category/draft.vue +++ b/src/views/lesson/trainingrecord/category/draft.vue @@ -210,7 +210,7 @@ export default { this.operateModel.id = node.data.id; this.operateModel.name = node.data.name; - getTrainingDetail({ id: node.data.id }).then(response => { + getTrainingDetail(node.data.id).then(response => { this.operateModel.minDuration = response.data.minDuration; this.operateModel.maxDuration = response.data.maxDuration; this.operateModel.operateType = response.data.operateType; diff --git a/src/views/lesson/trainingrecord/index.vue b/src/views/lesson/trainingrecord/index.vue index 72054c1b2..bbf07c652 100644 --- a/src/views/lesson/trainingrecord/index.vue +++ b/src/views/lesson/trainingrecord/index.vue @@ -47,7 +47,6 @@ export default { }, $route() { this.resizeHandler(); - this.$; } }, mounted() { diff --git a/src/views/lesson/trainingrecord/manage/index.vue b/src/views/lesson/trainingrecord/manage/index.vue index ef87ee053..a03a35e16 100644 --- a/src/views/lesson/trainingrecord/manage/index.vue +++ b/src/views/lesson/trainingrecord/manage/index.vue @@ -15,7 +15,7 @@ import MapSystemDraft from '@/views/mapsystem/index'; import StepManage from './stepmanage/index'; import { mapGetters } from 'vuex'; -import { getTrainingStepsDetail } from '@/api/jmap/training'; +import { getTrainingDetail, getTrainingStepsDetail } from '@/api/jmap/training'; import { getProductDetail } from '@/api/management/mapprd'; import { TrainingMode, OperateMode } from '@/scripts/ConstDic'; import { loadMapData } from '@/utils/loaddata'; @@ -49,6 +49,16 @@ export default { watch: { $route(newVal) { this.initLoadData(); + }, + '$store.state.map.mapViewLoadedCount': function() { + if (this.trainingId) { + getTrainingStepsDetail(this.trainingId, { group: this.group }).then(response => { + this.$store.dispatch('training/setTrainingData', response.data); + }).catch(() => { + this.$messageBox(this.$t('error.getMapStepsFailed')); + this.endViewLoading(); + }); + } } }, mounted() { @@ -77,19 +87,19 @@ export default { // 获取实训的详细数据 // 加载地图数据 // 设置实训数据 - getTrainingStepsDetail(this.trainingId, { group: this.group }).then(response => { - const stepdData = response.data; - getProductDetail(stepdData.prdCode).then(res => { - loadMapData(stepdData.skinCode).then(() => { - this.$store.dispatch('training/setPrdType', res.data.prdType); - this.$store.dispatch('training/setTrainingData', stepdData); + getTrainingDetail(this.trainingId).then(resp => { + const detail = resp.data; + getProductDetail(detail.prdCode).then(rest => { + const data = rest.data; + loadMapData(detail.skinCode).then(() => { + this.$store.dispatch('training/setPrdType', data.prdType); }).catch(() => { this.$messageBox(this.$t('error.loadMapDataFailed')); this.endViewLoading(); }); }); }).catch(() => { - this.$messageBox(this.$t('error.getMapStepsFailed')); + this.$messageBox(this.$t('error.getMapDetailFailed')); this.endViewLoading(); }); } else { diff --git a/src/views/teach/practical/index.vue b/src/views/teach/practical/index.vue index 25c0b4288..8a845fbe5 100644 --- a/src/views/teach/practical/index.vue +++ b/src/views/teach/practical/index.vue @@ -67,9 +67,9 @@ export default { this.height = this._clientHeight - 50; }, initLoadPage() { - const data = { id: this.$route.params.trainingId }; - if (parseInt(data.id)) { - getTrainingDetail(data) + const trainingId = this.$route.params.trainingId; + if (parseInt(trainingId)) { + getTrainingDetail(trainingId) .then(res => { this.courseModel = { id: res.data.id,