宁波三号线 控制权状态 代码处理

This commit is contained in:
joylink_cuiweidong 2021-02-23 16:37:42 +08:00
parent f0a3e0005d
commit 2ffc9e0781
3 changed files with 83 additions and 30 deletions

View File

@ -499,6 +499,7 @@ export default class Station extends Group {
this.substationArrowsControl && this.substationArrowsControl.setColor(this.style.Station.StationControl.lamp.grayColor); this.substationArrowsControl && this.substationArrowsControl.setColor(this.style.Station.StationControl.lamp.grayColor);
this.emergencyArrowsControl && this.emergencyArrowsControl.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.style.Station.stationText.isSpecialType) {
// if()
this.stationText.setColor(this.style.Station.stationText.noneModeColor); this.stationText.setColor(this.style.Station.stationText.noneModeColor);
// sationEle.controller // sationEle.controller
} else { } else {
@ -522,12 +523,14 @@ export default class Station extends Group {
// }); // });
// // // //
// } // }
// console.log(model.controller, model.centralized, '5555555555555');
model.controller && this.handleComplexControl(model.controller); model.controller && this.handleComplexControl(model.controller);
if (this.style.Station.syncCentralizeStation && (model.controlMode || model.controller) && model.centralized) { if (this.style.Station.syncCentralizeStation && (model.controlMode || model.controller) && model.centralized) {
model.chargeStationCodeList.forEach(item => { model.chargeStationCodeList.forEach(item => {
const device = store.getters['map/getDeviceByCode'](item); const device = store.getters['map/getDeviceByCode'](item);
device && device.instance && device.instance.recover(); device && device.instance && device.instance.recover();
if (model.controller) { if (model.controller) {
device.controller = model.controller;
device && device.instance && device.instance.handleComplexControl(model.controller); device && device.instance && device.instance.handleComplexControl(model.controller);
} else { } else {
device.controlMode = model.controlMode; device.controlMode = model.controlMode;
@ -546,18 +549,21 @@ export default class Station extends Group {
} }
handleComplexControl(controller) { handleComplexControl(controller) {
// const controller = model.controller;
const memberData = store.state.training.memberData; const memberData = store.state.training.memberData;
if (memberData[controller].userId) { console.log(controller, memberData[controller], memberData[controller].userId, store.state.user.id, '88888888');
if (memberData[controller].userId == store.state.user.id) { if (memberData[controller].userId && memberData[controller].userId == store.state.user.id) {
this.stationText.setColor(this.style.Station.stationText.currentModeColor); this.stationText.setColor(this.style.Station.stationText.currentModeColor);
} else { } else {
if (memberData[controller].type == 'DISPATCHER') { if (memberData[controller].type == 'DISPATCHER') {
this.stationText.setColor(this.style.Station.stationText.dispatherColor); this.stationText.setColor(this.style.Station.stationText.dispatherColor);
} else if (memberData[controller].type == 'STATION_SUPERVISOR') { } else if (memberData[controller].type == 'STATION_SUPERVISOR') {
const deviceCode = memberData[controller].deviceCode; const deviceCode = memberData[controller].deviceCode;
// console.log(deviceCode, '999999999');
if (deviceCode) { if (deviceCode) {
const device = store.getters['map/getDeviceByCode'](deviceCode); const device = store.getters['map/getDeviceByCode'](deviceCode);
if (device.centralized) { if (device.centralized) {
// console.log(device.centralized, '666666666');
this.stationText.setColor(this.style.Station.stationText.centralizedColor); this.stationText.setColor(this.style.Station.stationText.centralizedColor);
} else { } else {
this.stationText.setColor(this.style.Station.stationText.noCentralizedColor); this.stationText.setColor(this.style.Station.stationText.noCentralizedColor);
@ -566,7 +572,6 @@ export default class Station extends Group {
} }
} }
} }
}
// setState(model) { // setState(model) {
// if (!this.isShowShape) return; // if (!this.isShowShape) return;

View File

@ -261,6 +261,7 @@ export default {
tempClassB: -1, tempClassB: -1,
valid: true, valid: true,
menu: [], menu: [],
beCentralizedStation:{},
menuNormal: { menuNormal: {
Local: [ Local: [
// { // {
@ -1340,29 +1341,65 @@ export default {
'$store.state.training.prdType': function () { '$store.state.training.prdType': function () {
this.initMenu(); this.initMenu();
}, },
'$store.state.socket.simulationRoleList':function(list) { '$store.state.training.changeRoleInfo':function(newval, oldval) {
if (list && list.length) { // if (list && list.length) {
this.checkRoleChange(list); this.checkRoleChange(oldval, newval);
} // }
} }
}, },
mounted() { mounted() {
this.initMenu(); this.initMenu();
//
this.stationList.forEach(data=>{
if (data.centralized) {
data.chargeStationCodeList.forEach(charge=>{
this.beCentralizedStation[charge] = data.code;
});
}
});
}, },
methods: { methods: {
checkRoleChange(list) { checkRoleChange(oldval, newval) {
list.forEach(item => { this.$nextTick(()=>{
// || item.messageType == 'ONLINE' const memberData = this.$store.state.training.memberData;
if ((item.messageType === 'PLAY_CHANGE') && item.userId == this.userId ) { if (oldval && newval) {
if (item.memberId && item.type) { const oldMemberId = oldval.split(':')[0];
// this.$store.dispatch('training/setCurrentRoleInfo', {memberId:item.memberId,type:item.type,deviceCode:}); 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;
} }
// currentRole centerStation && centerStation.instance && centerStation.instance.handleComplexControl(newStation.controller);
// this.$store.state; centerStation.chargeStationCodeList.forEach(item => {
// this.switchShowStation(this.centralizedMap[item.deviceCode]); const device = this.$store.getters['map/getDeviceByCode'](item);
// "memberId":"1","type":"DISPATCHER","deviceCode":"Station10002" device && device.instance && device.instance.handleComplexControl(newStation.controller);
});
} }
}
}
// if (oldMember.type == 'DISPATCHER' && newMember.type == 'DISPATCHER') {
// }else if(oldMember.type == 'DISPATCHER' && newMember.type == 'DISPATCHER'){
// }
}
}
// else if (oldval) {
// } else {
// }
}); });
}, },

View File

@ -35,6 +35,7 @@ const training = {
roles: '', // 角色权限类型 roles: '', // 角色权限类型
roleDeviceCode:'', // 当前角色对应的deviceCode roleDeviceCode:'', // 当前角色对应的deviceCode
centerStationCode:'', // 当前居中的集中站code centerStationCode:'', // 当前居中的集中站code
changeRoleInfo:'', // 切换角色的信息()
memberList: [], // 综合仿真成员列表 memberList: [], // 综合仿真成员列表
memberData: {}, // 综合仿真成员列表 memberData: {}, // 综合仿真成员列表
simulationUserList: [], // 综合仿真用户列表 simulationUserList: [], // 综合仿真用户列表
@ -258,10 +259,20 @@ const training = {
} else if (item.messageType === 'KICK_OUT' && memberIndex > -1) { } else if (item.messageType === 'KICK_OUT' && memberIndex > -1) {
state.simulationUserList.splice(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) { } catch (e) {
console.error(e); console.error(e);
} }
}); });
}, },
setRoleDeviceCode :(state, roleDeviceCode) => { setRoleDeviceCode :(state, roleDeviceCode) => {
state.roleDeviceCode = roleDeviceCode; state.roleDeviceCode = roleDeviceCode;