diff --git a/src/views/designPlatform/demonList.vue b/src/views/designPlatform/demonList.vue index de70d659f..568e1372d 100644 --- a/src/views/designPlatform/demonList.vue +++ b/src/views/designPlatform/demonList.vue @@ -148,11 +148,12 @@ export default { break; } case 'trainingPreview': { - const data = { mapId: obj.mapId, prdType: '01' }; + const data = { mapId: obj.mapId }; createSimulationNew(data).then(resp => { if (this.loadingProjectList.includes(this.project)) { this.$store.dispatch('app/transitionAnimations'); } + this.$store.dispatch('training/setPrdType', '02'); const query = { ...data, group: resp.data, scriptId: obj.id, lineCode:obj.lineCode}; this.$router.push({ path: `/trainingPreview`, query }); }).catch(error => { diff --git a/src/views/designPlatform/trainingList.vue b/src/views/designPlatform/trainingList.vue index bbca1a900..9123dd296 100644 --- a/src/views/designPlatform/trainingList.vue +++ b/src/views/designPlatform/trainingList.vue @@ -37,6 +37,14 @@ export default { reset: true, show:false }, + prdTypeMap: { + DISPATCHER: '02', + STATION_SUPERVISOR: '01', + STATION_ASSISTANT: '01', + DEPOT_DISPATCHER: '09', + DRIVER: '04', + RAIL_CTC: '10' + }, queryList: { query: this.queryFunction, selectCheckShow: false, @@ -112,10 +120,17 @@ export default { try { const detailResp = await getPublishTrainingDetail(data.id); this.training = detailResp.data; + const mapLocation = JSON.parse(detailResp.data.mapLocationJson); + const playerId = JSON.parse(detailResp.data.playerIdJson)[0]; + const member = this.$store.state.training.memberData[playerId]; + this.$store.dispatch('training/setPrdType', this.prdTypeMap[member.type]); + this.$store.dispatch('training/setRoles', member.type); + this.$jlmap.updateTransform(mapLocation.scale, {x:mapLocation.x, y:mapLocation.y}); this.$store.dispatch('trainingNew/setTrainingDetail', detailResp.data); await loadPublishTraining(this.group, data.id, {mode: this.teachMode}); this.$message.success('加载实训成功!'); } catch (e) { + console.error('ceshi', e); this.$message.error('加载实训失败!'); } }, diff --git a/src/views/designPlatform/trainingPreview.vue b/src/views/designPlatform/trainingPreview.vue index 9d8345bb0..6e15ffed2 100644 --- a/src/views/designPlatform/trainingPreview.vue +++ b/src/views/designPlatform/trainingPreview.vue @@ -31,6 +31,8 @@ import TrainingTip from './trainingTip'; import deviceType from '@/jmapNew/constant/deviceType.js'; import { EventBus } from '@/scripts/event-bus'; import { getDeviceMenuByDeviceType, MouseEvent } from '@/scripts/ConstDic'; +import { getSimulationMemberList, getAllSimulationUser } from '@/api/simulation'; +import { getMemberListCommon, getUserListCommon } from '@/api/rtSimulation'; export default { name: 'TrainingDesign', components: { @@ -127,6 +129,7 @@ export default { this.menus = this.$theme.loadMenuComponent(lineCode); // this.$store.commit('training/notifyGetCommandDefinition', lineCode); } + this.initMemberUserInfo(true); } }, async beforeDestroy() { @@ -135,7 +138,6 @@ export default { this.$store.dispatch('socket/clearTrainingOverCount'); }, mounted() { - this.$store.dispatch('training/setPrdType', '01'); this.setWindowSize(); this.initLoadData(); }, @@ -382,6 +384,32 @@ export default { } return device; + }, + initMemberUserInfo(isFirst = false) { + if (this.$route.query.newApi + '' === 'true') { + getMemberListCommon(this.$route.query.group).then(resp => { + this.$store.dispatch('training/setMemberList', { memberList: resp.data, userId: this.$store.state.user.id }); + getUserListCommon(this.$route.query.group).then(res => { + this.$store.dispatch('training/setSimulationUserList', res.data); + }).catch(() => { + this.$messageBox('获取所有仿真用户失败!'); + }); + }).catch(() => { + this.$messageBox('获取仿真成员列表失败!'); + }); + } else { + // 获取仿真成员列表 + getSimulationMemberList(this.group).then(resp => { + this.$store.dispatch('training/setMemberList', { memberList: resp.data, userId: this.$store.state.user.id }); + getAllSimulationUser(this.group).then(res => { + this.$store.dispatch('training/setSimulationUserList', res.data); + }).catch(() => { + this.$messageBox('获取所有仿真用户失败!'); + }); + }).catch(() => { + this.$messageBox('获取仿真成员列表失败!'); + }); + } } } };