From 19c6087141f3d83498b27d66ec964c70abf601f7 Mon Sep 17 00:00:00 2001 From: fan Date: Mon, 12 Dec 2022 16:27:28 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E3=80=90=E5=93=88=E5=B0=94=E6=BB=A8?= =?UTF-8?q?=E4=B8=80=E5=8F=B7=E7=BA=BF=E3=80=91=E7=82=B9=E5=87=BB=E8=BD=A6?= =?UTF-8?q?=E7=AB=99=E5=90=8D=E6=97=A0=E6=B3=95=E5=88=87=E6=8D=A2=E8=BD=A6?= =?UTF-8?q?=E7=AB=99=E3=80=91&&=E5=88=87=E6=8D=A2=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=98=AF=E5=9B=A0=E8=A7=92=E8=89=B2=E5=8F=98=E5=8C=96=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=AE=9A=E4=BD=8D=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../haerbin_01/menus/localWorkMenuBar.vue | 32 +++++++------------ .../theme/haerbin_01/menus/menuButton.vue | 12 ++++--- src/views/newMap/display/terminals/index.vue | 5 +++ .../display/trainingList/trainingMenu.vue | 3 +- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/jmapNew/theme/haerbin_01/menus/localWorkMenuBar.vue b/src/jmapNew/theme/haerbin_01/menus/localWorkMenuBar.vue index fc30381b9..9e659b38c 100644 --- a/src/jmapNew/theme/haerbin_01/menus/localWorkMenuBar.vue +++ b/src/jmapNew/theme/haerbin_01/menus/localWorkMenuBar.vue @@ -86,6 +86,7 @@ import AlarmTableHmi from './menuDialog/alarmTableHmi'; import AlarmTableLow from './menuDialog/alarmTableLow'; import TrainControl from './dialog/trainControl'; import LogDetail from './menuDialog/logDetail'; +import { assignUsersPlayRoles } from '@/api/jointSimulation'; export default { name: 'MenuBar', @@ -190,10 +191,8 @@ export default { this.stationCode = code; } }, - '$store.state.socket.simulationRoleList':function(list) { - if (list && list.length) { - this.checkRoleChange(list); - } + '$store.state.training.roleDeviceCode': function(val) { + this.stationCode = this.centralizedMap[val]; }, '$store.state.socket.simulationAlarmInfo': function(val) { (val || []).forEach(item => { @@ -247,10 +246,6 @@ export default { mounted() { this.version = this.$store.state.map.version; this.initMenu(); - /* 由于修改角色现行是先取消人员仿真角色后赋予,故menuBar会在仿真角色取消时销毁,在赋予特定角色是挂载,故此处处理 */ - if (this.$store.state.socket.simulationRoleList && this.$store.state.socket.simulationRoleList.length) { - this.checkRoleChange(this.$store.state.socket.simulationRoleList); - } }, methods: { handleAlarm(val) { @@ -281,17 +276,21 @@ export default { }); this.colsNum = 24 / this.centralizedStationList1.length; if (centralizedStationList.length) { - if (this.$store.state.map.showCentralizedStationCode) { - this.stationCode = this.$store.state.map.showCentralizedStationCode; + if (this.$store.state.training.roleDeviceCode) { + this.stationCode = this.centralizedMap[this.$store.state.training.roleDeviceCode]; } else { this.stationCode = centralizedStationList[0].code; } } }, switchShowStation(stationCode) { - this.stationCode = stationCode; - this.$store.dispatch('map/setShowCentralizedStationNum'); - this.$store.dispatch('map/setShowCentralizedStationCode', stationCode); + const member = this.$store.state.training.memberList.find(member => member.type === 'STATION_SUPERVISOR' && member.deviceCode === stationCode); + const data = [{userId: this.userId, memberId:member.id}]; + assignUsersPlayRoles(data, this.$route.query.group).then(() => { + console.log('切换角色!'); + }).catch(e => { + this.$message.error('切换车站失败!'); + }); }, undeveloped() { this.doClose(); @@ -333,13 +332,6 @@ export default { EventBus.$emit('closeMenu'); }); }, - checkRoleChange(list) { - list.forEach(item => { - if (item.messageType === 'PLAY_CHANGE' && item.userId == this.userId && item.type === 'STATION_SUPERVISOR') { - this.switchShowStation(this.centralizedMap[item.deviceCode]); - } - }); - }, showLowAlarm(level) { this.$refs.alarmTableLow.doShow(level); }, diff --git a/src/jmapNew/theme/haerbin_01/menus/menuButton.vue b/src/jmapNew/theme/haerbin_01/menus/menuButton.vue index 57c964a55..006a70bed 100644 --- a/src/jmapNew/theme/haerbin_01/menus/menuButton.vue +++ b/src/jmapNew/theme/haerbin_01/menus/menuButton.vue @@ -369,6 +369,9 @@ export default { if (!val) { this.doClose(); } + }, + '$store.state.training.roleDeviceCode': function (val) { + this.handleBasicMenu(); } }, mounted() { @@ -631,11 +634,12 @@ export default { this.centralizedStationList[index] = basic; }); this.tempData = []; - const station = this.$store.getters['map/getDeviceByCode'](this.$store.state.map.showCentralizedStationCode); + const station = this.$store.getters['map/getDeviceByCode'](this.$store.state.training.roleDeviceCode); this.tempData.push(station); + const code = station ? station.stationCode : ''; this.param = { - stationCode: this.$store.state.map.showCentralizedStationCode, - stationCodes: [this.$store.state.map.showCentralizedStationCode] + stationCode: code, + stationCodes: [code] }; }, handleStationMenu() { @@ -688,7 +692,7 @@ export default { this.param.routeCodeList = routeCodeList; } if (this.cmdType == CMD.Station.CMD_STATION_SET_CI_AUTO_TRIGGER || this.cmdType == CMD.Station.CMD_STATION_CANCEL_CI_AUTO_TRIGGER) { - this.param = { stationCode: this.selectedObj.code || this.$store.state.map.showCentralizedStationCode }; + this.param = { stationCode: this.selectedObj.code || this.$store.state.training.roleDeviceCode }; } if (this.cmdType == CMD.Section.CMD_SECTION_SET_LIMIT_SPEED || this.cmdType == CMD.Switch.CMD_SWITCH_SET_LIMIT_SPEED) { this.param.speedLimitValue = this.speedLimitValue; diff --git a/src/views/newMap/display/terminals/index.vue b/src/views/newMap/display/terminals/index.vue index 31c0f04d3..143c548f8 100644 --- a/src/views/newMap/display/terminals/index.vue +++ b/src/views/newMap/display/terminals/index.vue @@ -148,6 +148,11 @@ export default { this.$store.dispatch('training/setMapDefaultState'); this.isFirst = false; } + const trainingDetail = this.$store.state.trainingNew.trainingDetail; + if (trainingDetail && trainingDetail.mapLocationJson) { // 客户端切换后如有实训重新定位 + const mapLocation = JSON.parse(trainingDetail.mapLocationJson); + this.$jlmap.updateTransform(mapLocation.scale, {x:mapLocation.x, y:mapLocation.y}); + } }, '$store.state.socket.memberChangeCount': function () { // 仿真成员变更 this.initMemberUserInfo(); diff --git a/src/views/newMap/display/trainingList/trainingMenu.vue b/src/views/newMap/display/trainingList/trainingMenu.vue index dcd575034..24db8f11b 100644 --- a/src/views/newMap/display/trainingList/trainingMenu.vue +++ b/src/views/newMap/display/trainingList/trainingMenu.vue @@ -186,6 +186,7 @@ export default { return; } try { + await loadPublishTraining(this.group, training.id, {mode: ''}); const detailResp = await getPublishTrainingDetail(training.id); this.training = detailResp.data; if (detailResp.data.mapLocationJson) { @@ -193,9 +194,9 @@ export default { this.$jlmap.updateTransform(mapLocation.scale, {x:mapLocation.x, y:mapLocation.y}); } this.$store.dispatch('trainingNew/setTrainingDetail', detailResp.data); - await loadPublishTraining(this.group, training.id, {mode: ''}); this.$message.success('加载实训成功!'); } catch (e) { + console.error(e, '-----------'); this.$message.error('加载实训失败!'); } }