修改列车详情显示问题
This commit is contained in:
parent
f492d38c47
commit
83faa429fe
@ -166,7 +166,7 @@ class Jlmap {
|
||||
}
|
||||
|
||||
// 中间处理
|
||||
hookHandle(elem) {
|
||||
hookHandle(oDevice, elem) {
|
||||
const code = elem.code;
|
||||
const type = elem._type;
|
||||
// 如果是延时计时,需要保存计数值到全局
|
||||
@ -179,7 +179,14 @@ class Jlmap {
|
||||
localStore(code, val);
|
||||
}
|
||||
|
||||
return elem;
|
||||
for (var prop in elem) {
|
||||
if (elem[prop] != oDevice[prop]) {
|
||||
Object.assign(oDevice, elem);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 后处理
|
||||
@ -234,8 +241,9 @@ class Jlmap {
|
||||
if (elem.dispose) {
|
||||
this.$painter.delete(oDevice);
|
||||
} else {
|
||||
const nDevice = Object.assign(oDevice, this.hookHandle(elem));
|
||||
this.$painter.update(nDevice);
|
||||
if (this.hookHandle(oDevice, elem)) {
|
||||
this.$painter.update(oDevice);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -152,12 +152,10 @@ class MouseController extends Eventful {
|
||||
moveEvent(e) {
|
||||
const newEm = new EventModel(e);
|
||||
const trainDetails = store.state.map.trainDetails;
|
||||
if (trainDetails && trainDetails.model) {
|
||||
if (newEm.deviceType != deviceType.Train || trainDetails.model._code != newEm.deviceCode) {
|
||||
var model = trainDetails.model;
|
||||
var instances = (this._viewRepo.__getViewInstancesByDeviceType(deviceType.Train) || {})._instances || {};
|
||||
var device = instances[model._code] || {};
|
||||
device.removeTrainDetail && device.removeTrainDetail();
|
||||
if (trainDetails) {
|
||||
if (newEm.deviceType != deviceType.Train || trainDetails.code != newEm.deviceCode) {
|
||||
var instance = (this.$jmap.getDeviceByCode(trainDetails.code) || {} ).instance;
|
||||
instance && instance.removeTrainDetail && instance.removeTrainDetail();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ export default class EMouse extends Group {
|
||||
constructor(device) {
|
||||
super();
|
||||
this.device = device;
|
||||
this.down = false;
|
||||
this.create();
|
||||
}
|
||||
create() {
|
||||
@ -40,7 +39,7 @@ export default class EMouse extends Group {
|
||||
}
|
||||
|
||||
mouseout(e) {
|
||||
if (!this.down) {
|
||||
if (!this.device.model.down) {
|
||||
if (e.target && e.target._subType == 'Text') {
|
||||
this.text.hide();
|
||||
} else {
|
||||
|
@ -5,7 +5,6 @@ export default class EMouse extends Group {
|
||||
constructor(device) {
|
||||
super();
|
||||
this.device = device;
|
||||
this.down = false;
|
||||
this.create();
|
||||
}
|
||||
create() {
|
||||
@ -41,7 +40,7 @@ export default class EMouse extends Group {
|
||||
}
|
||||
|
||||
mouseout(e) {
|
||||
if (!this.down) {
|
||||
if (!this.device.model.down) {
|
||||
if (e.target && e.target._subType == 'Text') {
|
||||
this.text.hide();
|
||||
} else {
|
||||
|
@ -5,7 +5,6 @@ export default class EMouse extends Group {
|
||||
constructor(device) {
|
||||
super();
|
||||
this.device = device;
|
||||
this.down = false;
|
||||
this.create();
|
||||
}
|
||||
create() {
|
||||
@ -56,7 +55,7 @@ export default class EMouse extends Group {
|
||||
}
|
||||
|
||||
mouseout(e) {
|
||||
if (!this.down) {
|
||||
if (!this.device.model.down) {
|
||||
this.text.hide();
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ export default class EMouse extends Group {
|
||||
this.device = device;
|
||||
this.zlevel = device.zlevel;
|
||||
this.style = device.style;
|
||||
this.down = false;
|
||||
this.create();
|
||||
}
|
||||
|
||||
@ -32,7 +31,7 @@ export default class EMouse extends Group {
|
||||
}
|
||||
|
||||
mouseout(e) {
|
||||
if (!this.down) {
|
||||
if (!this.device.model.down) {
|
||||
this.border.hide();
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import store from '@/store';
|
||||
class EMouse extends Group {
|
||||
constructor(device) {
|
||||
super();
|
||||
this.down = false;
|
||||
this.device = device;
|
||||
this.create();
|
||||
this.craeteSwitchBorder();
|
||||
@ -73,7 +72,7 @@ class EMouse extends Group {
|
||||
}
|
||||
|
||||
mouseout(e) {
|
||||
if (!this.down) {
|
||||
if (!this.device.model.down) {
|
||||
this.switchBorder && this.switchBorder.hide();
|
||||
this.device.setTextStyle({
|
||||
textFill: this.device.style.backgroundColor
|
||||
|
@ -2,15 +2,14 @@ import Group from 'zrender/src/container/Group';
|
||||
import Text from 'zrender/src/graphic/Text';
|
||||
|
||||
class EMouse extends Group {
|
||||
constructor(device, style) {
|
||||
constructor(device) {
|
||||
super();
|
||||
this.down = false;
|
||||
this.device = device;
|
||||
this.create();
|
||||
}
|
||||
create() {
|
||||
let destinationText = '';
|
||||
switch (this.device.destinationStatus) {
|
||||
switch (this.device.model.destinationStatus) {
|
||||
case '01': destinationText = '准点'; break;
|
||||
case '02': destinationText = '早点'; break;
|
||||
case '03': destinationText = '严重早点'; break;
|
||||
@ -20,17 +19,17 @@ class EMouse extends Group {
|
||||
}
|
||||
// 文字描述
|
||||
this.arrowText = new Text({
|
||||
zlevel: this.device.zlevel,
|
||||
z: this.device.z,
|
||||
zlevel: this.device.model.zlevel,
|
||||
z: this.device.model.z,
|
||||
style: {
|
||||
x: this.device.point.x + 50,
|
||||
y: this.device.point.y + 25,
|
||||
text: `列车类型: 计划车\n表\0\0\0\0号: ${this.device.serviceNumber}\n车\0次\0号: ${this.device.tripNumber}\n目的地号: ${this.device.targetCode ? this.device.targetCode : ''}\n车\0组\0号: ${this.device.groupNumber}\n早\0晚\0点: ${destinationText}\n运行方向: ${this.device.directionType == '02' ? '上行' : '下行'}\n乘务组号: \n起点站名: \n终点站名: \n占用轨道: ${this.device.sectionModel ? this.device.sectionModel.trackName : ''}\n所在车站: \n车地通信: 正常\n运行等级: 4\n扣车状态: ${this.device.runControlStatus == '01' ? '正常' : this.device.runControlStatus == '03' ? '跳停' : '扣车'}\n停稳状态: ${this.device.runStatus == '02' ? '未停稳' : '停稳'}\n阻塞状态: 无\n列车速度: ${this.device.speed || 0} km/h\n列车移动授权距离: ${this.device.maLen || 0} m`,
|
||||
x: this.device.model.point.x + 50,
|
||||
y: this.device.model.point.y + 25,
|
||||
text: `列车类型: 计划车\n表\0\0\0\0号: ${this.device.model.serviceNumber}\n车\0次\0号: ${this.device.model.tripNumber}\n目的地号: ${this.device.model.targetCode ? this.device.model.targetCode : ''}\n车\0组\0号: ${this.device.model.groupNumber}\n早\0晚\0点: ${destinationText}\n运行方向: ${this.device.model.directionType == '02' ? '上行' : '下行'}\n乘务组号: \n起点站名: \n终点站名: \n占用轨道: ${this.device.model.sectionModel ? this.device.model.sectionModel.trackName : ''}\n所在车站: \n车地通信: 正常\n运行等级: 4\n扣车状态: ${this.device.model.runControlStatus == '01' ? '正常' : this.device.model.runControlStatus == '03' ? '跳停' : '扣车'}\n停稳状态: ${this.device.model.runStatus == '02' ? '未停稳' : '停稳'}\n阻塞状态: 无\n列车速度: ${this.device.model.speed || 0} km/h\n列车移动授权距离: ${this.device.model.maLen || 0} m`,
|
||||
textFill: '#000',
|
||||
textAlign: 'letf',
|
||||
textFont: 10 + 'px consolas',
|
||||
textPadding: 3,
|
||||
textBackgroundColor: this.device.style.tipBackgroundColor
|
||||
textBackgroundColor: this.device.model.style.tipBackgroundColor
|
||||
}
|
||||
});
|
||||
this.add(this.arrowText);
|
||||
@ -38,11 +37,15 @@ class EMouse extends Group {
|
||||
}
|
||||
|
||||
mouseover() {
|
||||
this.device.deviceModel.down = true;
|
||||
this.arrowText.show();
|
||||
}
|
||||
|
||||
mouseout() {
|
||||
this.arrowText.hide();
|
||||
if (this.device.deviceModel.down) {
|
||||
this.arrowText.hide();
|
||||
this.device.deviceModel.down = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,16 +14,21 @@ export default class TrainBody extends Group {
|
||||
constructor(model) {
|
||||
super();
|
||||
this.model = model;
|
||||
this.deviceModel = model.model;
|
||||
this.create();
|
||||
console.log(this.model);
|
||||
this.createMouse(); // 鼠标事件
|
||||
}
|
||||
|
||||
createMouse() {
|
||||
this.mouseEvent = new EMouse(this.model);
|
||||
this.mouseEvent = new EMouse(this);
|
||||
this.add(this.mouseEvent);
|
||||
if (this.deviceModel.down) {
|
||||
store.dispatch('map/setTrainDetails', this.deviceModel);
|
||||
this.mouseEvent.mouseover();
|
||||
}
|
||||
|
||||
this.on('mouseover', () => {
|
||||
store.dispatch('map/setTrainDetails', true);
|
||||
store.dispatch('map/setTrainDetails', this.deviceModel);
|
||||
this.mouseEvent.mouseover();
|
||||
});
|
||||
this.on('mouseout', () => {
|
||||
@ -139,6 +144,7 @@ export default class TrainBody extends Group {
|
||||
removeTrainDetail() {
|
||||
this.mouseEvent.mouseout();
|
||||
store.dispatch('map/setTrainDetails', null);
|
||||
this.deviceModel.down = false;
|
||||
}
|
||||
setTrainColor(color) {
|
||||
this.train && this.train.setColor('fill', color);
|
||||
|
@ -69,7 +69,8 @@ export default class Train extends Group {
|
||||
fontSize: this.fontSize,
|
||||
type: model.type,
|
||||
speed: model.speed,
|
||||
maLen: model.maLen
|
||||
maLen: model.maLen,
|
||||
model: model
|
||||
});
|
||||
this.trainL = new TrainHead({
|
||||
style: style,
|
||||
|
@ -5,7 +5,6 @@ export default class EMouse extends Group {
|
||||
constructor(device) {
|
||||
super();
|
||||
this.device = device;
|
||||
this.down = false;
|
||||
this.create();
|
||||
}
|
||||
create() {
|
||||
@ -41,7 +40,7 @@ export default class EMouse extends Group {
|
||||
}
|
||||
|
||||
mouseout(e) {
|
||||
if (!this.down) {
|
||||
if (!this.device.model.down) {
|
||||
if (e.target && e.target._subType == 'Text') {
|
||||
this.text.hide();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user