import Group from 'zrender/src/container/Group'; import Text from 'zrender/src/graphic/Text'; import LangStorage from '@/utils/lang'; class EMouse extends Group { constructor(device) { super(); this.device = device; this.create(); } create() { let destinationText = ''; switch (this.device.model.destinationStatus) { case '01': destinationText = LangStorage.getLang() == 'en' ? 'on time' : '准点'; break; case '02': destinationText = LangStorage.getLang() == 'en' ? 'early' : '早点'; break; case '03': destinationText = LangStorage.getLang() == 'en' ? 'early seriously' : '严重早点'; break; case '04': destinationText = LangStorage.getLang() == 'en' ? 'late' : '晚点'; break; case '05': destinationText = LangStorage.getLang() == 'en' ? 'late seriously ' : '严重晚点'; break; default: destinationText = LangStorage.getLang() == 'en' ? 'unknown' : '未知'; break; } let trainType = ''; switch (this.device.model.type) { case '01': trainType = LangStorage.getLang() == 'en' ? 'Plan the car' : '计划车'; break; case '02': trainType = LangStorage.getLang() == 'en' ? 'Head size car' : '头码车'; break; case '03': trainType = LangStorage.getLang() == 'en' ? 'Artificial car' : '人工车'; break; default: trainType = LangStorage.getLang() == 'en' ? 'unknown' : '未知'; break; } let text = ''; if (LangStorage.getLang() == 'en') { text = ` The planned train: ${trainType} \n Table No.: ${this.device.model.serviceNumber} \n Train Trip No.: ${this.device.model.tripNumber}\n Destination: ${this.device.model.targetCode ? this.device.model.targetCode : ''}\n Train No.: ${this.device.model.groupNumber}\n Early or late: ${destinationText}\n Direction: ${this.device.model.directionType == '02' ? 'up' : 'down'}\n Crew No.: \n Start Station: \n Terminal Station: \n Occupied Track: ${this.device.model.sectionModel ? this.device.model.sectionModel.name : ''}\n Current Station: \n Train-ground communication: normal \n Operation Speed level: 4 \n Detained: ${!this.device.model.hold ? 'Normal' : 'Detained'}\n \n 跳停状态: ${!this.device.model.jump ? 'Normal' : 'Skip to continue moving'}Stationary: ${!this.device.model.stop ? 'No' : 'Yes'}\n Blocked: No \n Speed: ${this.device.model.speed || 0} km/h \n Authorized Distance: ${this.device.model.maLen || 0} m`; } else { text = `列车类型: ${trainType} \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.name : ''}\n所在车站: \n车地通信: 正常\n运行等级: 4\n扣车状态: ${ !this.device.model.hold ? '正常' : '扣车'}\n 跳停状态: ${!this.device.model.jump ? '正常' : '跳停'} \n停稳状态: ${!this.device.model.stop ? '未停稳' : '停稳'}\n阻塞状态: 无\n列车速度: ${this.device.model.speed || 0} km/h\n列车移动授权距离: ${this.device.model.maLen || 0} m`; } // 文字描述 this.arrowText = new Text({ zlevel: this.device.model.zlevel, z: this.device.model.z + 10, style: { x: this.device.model.point.x + 50, y: this.device.model.point.y + 25, text: text, textFill: '#000', textAlign: 'letf', textFont: 10 + 'px consolas', textPadding: 3, textBackgroundColor: this.device.model.style.tipBackgroundColor } }); this.add(this.arrowText); this.arrowText.hide(); } mouseover() { this.device.deviceModel.down = true; this.arrowText.show(); } mouseout() { if (this.device.deviceModel.down) { this.arrowText.hide(); this.device.deviceModel.down = false; } } } export default EMouse;