修改实训加载顺序错误的问题

This commit is contained in:
ival 2019-08-19 15:59:04 +08:00
parent 2d8f94f47a
commit ae500285ba
11 changed files with 49 additions and 32 deletions

View File

@ -53,9 +53,9 @@ export function getTrainingTree() {
} }
/** 获取章节基本信息*/ /** 获取章节基本信息*/
export function getTrainingDetail(args) { export function getTrainingDetail(trainingId) {
return request({ return request({
url: `/api/training/${args.id}`, url: `/api/training/${trainingId}`,
method: 'get' method: 'get'
}); });
} }

View File

@ -3,6 +3,7 @@ export default {
createSimulationFailed: 'Failure to create simulation', createSimulationFailed: 'Failure to create simulation',
loadMapDataFailed: 'Failed to load map data', loadMapDataFailed: 'Failed to load map data',
getMapStepsFailed: 'Failed to get map step data', getMapStepsFailed: 'Failed to get map step data',
getMapDetailFailed: 'Failed to get map detail',
resetFailed: 'Reset failure', resetFailed: 'Reset failure',
startTrainingFailed: 'Failure to start training', startTrainingFailed: 'Failure to start training',
saveBackgroundFailed: 'Failed to save background', saveBackgroundFailed: 'Failed to save background',

View File

@ -2,7 +2,8 @@ export default {
refreshFailed: '刷新失败', refreshFailed: '刷新失败',
createSimulationFailed: '创建仿真失败', createSimulationFailed: '创建仿真失败',
loadMapDataFailed: '加载地图数据失败', loadMapDataFailed: '加载地图数据失败',
getMapStepsFailed: '获取地图步骤数据', getMapStepsFailed: '获取地图步骤数据失败',
getMapDetailFailed: '获取地图详细信息失败',
resetFailed: '重置失败', resetFailed: '重置失败',
startTrainingFailed: '开始实训失败', startTrainingFailed: '开始实训失败',
saveBackgroundFailed: '保存背景失败', saveBackgroundFailed: '保存背景失败',

View File

@ -248,7 +248,7 @@ class Jlmap {
}); });
// 状态后处理 // 状态后处理
this.postHandle(list); this.postHandle(list || []);
if (this.methods.stateUpdate instanceof Function) { this.methods.stateUpdate(list); } if (this.methods.stateUpdate instanceof Function) { this.methods.stateUpdate(list); }
} }

View File

@ -70,7 +70,7 @@ import MenuScript from '@/views/display/menuScript';
import WindowResizeHandler from '@/mixin/WindowResizeHandler'; import WindowResizeHandler from '@/mixin/WindowResizeHandler';
import AddQuest from './demon/addQuest'; import AddQuest from './demon/addQuest';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { getTrainingStepsDetail } from '@/api/jmap/training'; import { getTrainingDetail, getTrainingStepsDetail } from '@/api/jmap/training';
import { setGoodsTryUse } from '@/api/management/goods'; import { setGoodsTryUse } from '@/api/management/goods';
import { getProductDetail } from '@/api/management/mapprd'; import { getProductDetail } from '@/api/management/mapprd';
import { runDiagramQuit, loadScript, getSimulationInfo } from '@/api/simulation'; import { runDiagramQuit, loadScript, getSimulationInfo } from '@/api/simulation';
@ -181,6 +181,14 @@ export default {
'$store.state.map.mapViewLoadedCount': function (val) { '$store.state.map.mapViewLoadedCount': function (val) {
this.mapBoxP = document.getElementById(this.canvasId).children[0]; this.mapBoxP = document.getElementById(this.canvasId).children[0];
this.mapBox = document.getElementsByTagName('canvas'); 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 () { '$store.state.socket.permissionOver': function () {
this.$alert('用户权限已被收回', '提示', { this.$alert('用户权限已被收回', '提示', {
@ -349,14 +357,14 @@ export default {
if (parseInt(this.trainingId)) { if (parseInt(this.trainingId)) {
// //
// //
const resp = await getTrainingStepsDetail(this.trainingId, { group: this.group }); const resp = await getTrainingDetail(this.trainingId);
if (resp && resp.code == 200) { if (resp && resp.code == 200) {
const stepdData = this.trainingObj = resp.data; const detail = resp.data;
const rest = await getProductDetail(stepdData.prdCode); const rest = await getProductDetail(detail.prdCode);
if (rest && rest.code == 200) { if (rest && rest.code == 200) {
await this.$store.dispatch('training/setPrdType', rest.data.prdType); const data = rest.data;
await this.loadMapData(resp.data.skinCode); await this.$store.dispatch('training/setPrdType', data.prdType);
await this.$store.dispatch('training/setTrainingData', stepdData); await this.loadMapData(detail.skinCode);
} }
} else { } else {
this.$messageBox(`获取实训步骤数据失败`); this.$messageBox(`获取实训步骤数据失败`);

View File

@ -140,10 +140,8 @@ export default {
} }
}); });
if (obj) { if (obj) {
const that = this; getTrainingDetail(obj.trainingId ).then(res => {
const data = { id: obj.trainingId }; this.courseModel = {
getTrainingDetail(data).then(res => {
that.courseModel = {
id: res.data.id, id: res.data.id,
name: res.data.name, name: res.data.name,
maxDuration: res.data.maxDuration, maxDuration: res.data.maxDuration,
@ -152,7 +150,7 @@ export default {
updateTime: res.data.updateTime updateTime: res.data.updateTime
}; };
}).catch(error => { }).catch(error => {
that.$message.error('获取试题息失败:' + error.message); this.$message.error('获取试题息失败:' + error.message);
}); });
} }

View File

@ -78,9 +78,9 @@ export default {
this.height = this._clientHeight; this.height = this._clientHeight;
}, },
initLoadPage() { initLoadPage() {
const data = { id: this.$route.query.trainingId }; const trainingId = this.$route.query.trainingId;
if (parseInt(data.id)) { if (parseInt(trainingId)) {
getTrainingDetail(data).then(res => { getTrainingDetail(trainingId).then(res => {
this.courseModel = { this.courseModel = {
id: res.data.id, id: res.data.id,
name: res.data.name, name: res.data.name,

View File

@ -210,7 +210,7 @@ export default {
this.operateModel.id = node.data.id; this.operateModel.id = node.data.id;
this.operateModel.name = node.data.name; 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.minDuration = response.data.minDuration;
this.operateModel.maxDuration = response.data.maxDuration; this.operateModel.maxDuration = response.data.maxDuration;
this.operateModel.operateType = response.data.operateType; this.operateModel.operateType = response.data.operateType;

View File

@ -47,7 +47,6 @@ export default {
}, },
$route() { $route() {
this.resizeHandler(); this.resizeHandler();
this.$;
} }
}, },
mounted() { mounted() {

View File

@ -15,7 +15,7 @@
import MapSystemDraft from '@/views/mapsystem/index'; import MapSystemDraft from '@/views/mapsystem/index';
import StepManage from './stepmanage/index'; import StepManage from './stepmanage/index';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import { getTrainingStepsDetail } from '@/api/jmap/training'; import { getTrainingDetail, getTrainingStepsDetail } from '@/api/jmap/training';
import { getProductDetail } from '@/api/management/mapprd'; import { getProductDetail } from '@/api/management/mapprd';
import { TrainingMode, OperateMode } from '@/scripts/ConstDic'; import { TrainingMode, OperateMode } from '@/scripts/ConstDic';
import { loadMapData } from '@/utils/loaddata'; import { loadMapData } from '@/utils/loaddata';
@ -49,6 +49,16 @@ export default {
watch: { watch: {
$route(newVal) { $route(newVal) {
this.initLoadData(); 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() { mounted() {
@ -77,19 +87,19 @@ export default {
// //
// //
// //
getTrainingStepsDetail(this.trainingId, { group: this.group }).then(response => { getTrainingDetail(this.trainingId).then(resp => {
const stepdData = response.data; const detail = resp.data;
getProductDetail(stepdData.prdCode).then(res => { getProductDetail(detail.prdCode).then(rest => {
loadMapData(stepdData.skinCode).then(() => { const data = rest.data;
this.$store.dispatch('training/setPrdType', res.data.prdType); loadMapData(detail.skinCode).then(() => {
this.$store.dispatch('training/setTrainingData', stepdData); this.$store.dispatch('training/setPrdType', data.prdType);
}).catch(() => { }).catch(() => {
this.$messageBox(this.$t('error.loadMapDataFailed')); this.$messageBox(this.$t('error.loadMapDataFailed'));
this.endViewLoading(); this.endViewLoading();
}); });
}); });
}).catch(() => { }).catch(() => {
this.$messageBox(this.$t('error.getMapStepsFailed')); this.$messageBox(this.$t('error.getMapDetailFailed'));
this.endViewLoading(); this.endViewLoading();
}); });
} else { } else {

View File

@ -67,9 +67,9 @@ export default {
this.height = this._clientHeight - 50; this.height = this._clientHeight - 50;
}, },
initLoadPage() { initLoadPage() {
const data = { id: this.$route.params.trainingId }; const trainingId = this.$route.params.trainingId;
if (parseInt(data.id)) { if (parseInt(trainingId)) {
getTrainingDetail(data) getTrainingDetail(trainingId)
.then(res => { .then(res => {
this.courseModel = { this.courseModel = {
id: res.data.id, id: res.data.id,