From 2ffc9e07814819e0074704fa0315c147f4321845 Mon Sep 17 00:00:00 2001 From: joylink_cuiweidong <364937672@qq.com> Date: Tue, 23 Feb 2021 16:37:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=81=E6=B3=A2=E4=B8=89=E5=8F=B7=E7=BA=BF?= =?UTF-8?q?=20=E6=8E=A7=E5=88=B6=E6=9D=83=E7=8A=B6=E6=80=81=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmapNew/shape/Station/index.js | 35 +++++----- src/jmapNew/theme/ningbo_03/menus/menuBar.vue | 67 ++++++++++++++----- src/store/modules/training.js | 11 +++ 3 files changed, 83 insertions(+), 30 deletions(-) diff --git a/src/jmapNew/shape/Station/index.js b/src/jmapNew/shape/Station/index.js index cf5d1a42a..782d430be 100644 --- a/src/jmapNew/shape/Station/index.js +++ b/src/jmapNew/shape/Station/index.js @@ -499,6 +499,7 @@ export default class Station extends Group { this.substationArrowsControl && this.substationArrowsControl.setColor(this.style.Station.StationControl.lamp.grayColor); this.emergencyArrowsControl && this.emergencyArrowsControl.setColor(this.style.Station.StationControl.lamp.grayColor); if (this.style.Station.stationText.isSpecialType) { + // if() this.stationText.setColor(this.style.Station.stationText.noneModeColor); // sationEle.controller } else { @@ -522,12 +523,14 @@ export default class Station extends Group { // }); // // // } + // console.log(model.controller, model.centralized, '5555555555555'); model.controller && this.handleComplexControl(model.controller); if (this.style.Station.syncCentralizeStation && (model.controlMode || model.controller) && model.centralized) { model.chargeStationCodeList.forEach(item => { const device = store.getters['map/getDeviceByCode'](item); device && device.instance && device.instance.recover(); if (model.controller) { + device.controller = model.controller; device && device.instance && device.instance.handleComplexControl(model.controller); } else { device.controlMode = model.controlMode; @@ -546,22 +549,24 @@ export default class Station extends Group { } handleComplexControl(controller) { + // const controller = model.controller; const memberData = store.state.training.memberData; - if (memberData[controller].userId) { - if (memberData[controller].userId == store.state.user.id) { - this.stationText.setColor(this.style.Station.stationText.currentModeColor); - } else { - if (memberData[controller].type == 'DISPATCHER') { - this.stationText.setColor(this.style.Station.stationText.dispatherColor); - } else if (memberData[controller].type == 'STATION_SUPERVISOR') { - const deviceCode = memberData[controller].deviceCode; - if (deviceCode) { - const device = store.getters['map/getDeviceByCode'](deviceCode); - if (device.centralized) { - this.stationText.setColor(this.style.Station.stationText.centralizedColor); - } else { - this.stationText.setColor(this.style.Station.stationText.noCentralizedColor); - } + console.log(controller, memberData[controller], memberData[controller].userId, store.state.user.id, '88888888'); + if (memberData[controller].userId && memberData[controller].userId == store.state.user.id) { + this.stationText.setColor(this.style.Station.stationText.currentModeColor); + } else { + if (memberData[controller].type == 'DISPATCHER') { + this.stationText.setColor(this.style.Station.stationText.dispatherColor); + } else if (memberData[controller].type == 'STATION_SUPERVISOR') { + const deviceCode = memberData[controller].deviceCode; + // console.log(deviceCode, '999999999'); + if (deviceCode) { + const device = store.getters['map/getDeviceByCode'](deviceCode); + if (device.centralized) { + // console.log(device.centralized, '666666666'); + this.stationText.setColor(this.style.Station.stationText.centralizedColor); + } else { + this.stationText.setColor(this.style.Station.stationText.noCentralizedColor); } } } diff --git a/src/jmapNew/theme/ningbo_03/menus/menuBar.vue b/src/jmapNew/theme/ningbo_03/menus/menuBar.vue index 535b58138..f67b786d9 100644 --- a/src/jmapNew/theme/ningbo_03/menus/menuBar.vue +++ b/src/jmapNew/theme/ningbo_03/menus/menuBar.vue @@ -261,6 +261,7 @@ export default { tempClassB: -1, valid: true, menu: [], + beCentralizedStation:{}, menuNormal: { Local: [ // { @@ -430,7 +431,7 @@ export default { { title: '开放/关闭', click: this.standOpenOrClose, - operate: OperationEvent.Command.commandNingBo3.line_stand_openOrClose + operate: OperationEvent.Command.commandNingBo3.line_stand_openOrClose }, { title: '设置/取消扣车', @@ -1340,29 +1341,65 @@ export default { '$store.state.training.prdType': function () { this.initMenu(); }, - '$store.state.socket.simulationRoleList':function(list) { - if (list && list.length) { - this.checkRoleChange(list); - } + '$store.state.training.changeRoleInfo':function(newval, oldval) { + // if (list && list.length) { + this.checkRoleChange(oldval, newval); + // } } }, mounted() { this.initMenu(); + // 被控制的车站数据 + this.stationList.forEach(data=>{ + if (data.centralized) { + data.chargeStationCodeList.forEach(charge=>{ + this.beCentralizedStation[charge] = data.code; + }); + } + }); }, methods: { - checkRoleChange(list) { - list.forEach(item => { - // || item.messageType == 'ONLINE' - if ((item.messageType === 'PLAY_CHANGE') && item.userId == this.userId ) { - if (item.memberId && item.type) { - // this.$store.dispatch('training/setCurrentRoleInfo', {memberId:item.memberId,type:item.type,deviceCode:}); + checkRoleChange(oldval, newval) { + this.$nextTick(()=>{ + const memberData = this.$store.state.training.memberData; + if (oldval && newval) { + const oldMemberId = oldval.split(':')[0]; + const newMemberId = newval.split(':')[1]; + if (oldMemberId && oldMemberId != newMemberId) { + const oldMember = memberData[oldMemberId]; + const newMember = memberData[newMemberId]; + if (oldMember.type == 'STATION_SUPERVISOR' && newMember.type == 'STATION_SUPERVISOR') { + const oldStation = this.$store.getters['map/getDeviceByCode'](oldMember.deviceCode); + const newStation = this.$store.getters['map/getDeviceByCode'](newMember.deviceCode); + if (oldStation.controller || newStation.controller) { + console.log(9999999999, oldStation.controller, newStation.controller); + if (newStation.controller) { + let centerStation; + if (newStation.centralized) { + centerStation = newStation; + } else { + const newCenter = this.$store.getters['map/getDeviceByCode'](this.beCentralizedStation[newMember.deviceCode]); + centerStation = newCenter; + } + centerStation && centerStation.instance && centerStation.instance.handleComplexControl(newStation.controller); + centerStation.chargeStationCodeList.forEach(item => { + const device = this.$store.getters['map/getDeviceByCode'](item); + device && device.instance && device.instance.handleComplexControl(newStation.controller); + }); + } + } + } + // if (oldMember.type == 'DISPATCHER' && newMember.type == 'DISPATCHER') { + // }else if(oldMember.type == 'DISPATCHER' && newMember.type == 'DISPATCHER'){ + // } } - // currentRole - // this.$store.state; - // this.switchShowStation(this.centralizedMap[item.deviceCode]); - // "memberId":"1","type":"DISPATCHER","deviceCode":"Station10002" } + // else if (oldval) { + + // } else { + + // } }); }, diff --git a/src/store/modules/training.js b/src/store/modules/training.js index f6f1a4e7c..978b6a401 100644 --- a/src/store/modules/training.js +++ b/src/store/modules/training.js @@ -35,6 +35,7 @@ const training = { roles: '', // 角色权限类型 roleDeviceCode:'', // 当前角色对应的deviceCode centerStationCode:'', // 当前居中的集中站code + changeRoleInfo:'', // 切换角色的信息() memberList: [], // 综合仿真成员列表 memberData: {}, // 综合仿真成员列表 simulationUserList: [], // 综合仿真用户列表 @@ -258,10 +259,20 @@ const training = { } else if (item.messageType === 'KICK_OUT' && memberIndex > -1) { state.simulationUserList.splice(memberIndex, 1); } + + if (item.messageType === 'PLAY_CHANGE') { + if (item.memberId) { + state.changeRoleInfo = ':' + item.memberId; + } else { + state.changeRoleInfo = memberId + ':'; + } + } + } catch (e) { console.error(e); } }); + }, setRoleDeviceCode :(state, roleDeviceCode) => { state.roleDeviceCode = roleDeviceCode;