From 357635d085ed335ec0a7a788f17b97e2a8e0f806 Mon Sep 17 00:00:00 2001 From: fan Date: Tue, 18 Oct 2022 17:25:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A6=E6=B1=898=E5=8F=B7=E7=BA=BF=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmapNew/mouseController.js | 9 +- src/jmapNew/shape/graph/Train/EMouse.js | 43 ++++- src/jmapNew/shape/graph/Train/TrainBody.js | 6 + src/jmapNew/shape/graph/Train/index.js | 1 + src/utils/baseUrl.js | 2 +- src/views/designPlatform/bigScreen.vue | 9 +- src/views/designPlatform/voiceCommand.vue | 208 +++++++++++++++++++++ src/views/designPlatform/whTrainList.vue | 24 +-- 8 files changed, 282 insertions(+), 20 deletions(-) create mode 100644 src/views/designPlatform/voiceCommand.vue diff --git a/src/jmapNew/mouseController.js b/src/jmapNew/mouseController.js index 7566f75e4..08c2dd787 100644 --- a/src/jmapNew/mouseController.js +++ b/src/jmapNew/mouseController.js @@ -198,7 +198,6 @@ class MouseController extends Eventful { var newDevice = this.$jmap.getDeviceByCode(newEm.deviceCode) || {}; var oldInstance = (this.$jmap.getDeviceByCode(oldEm.deviceCode) || {}).instance || {}; var newInstance = (this.$jmap.getDeviceByCode(newEm.deviceCode) || {}).instance || {}; - // 如果之前和当前选中的实例不一致 if (oldInstance != newInstance) { // 如果实例有取消选择函数并且被点击,则执行取消选中函数 @@ -207,12 +206,20 @@ class MouseController extends Eventful { oldDevice.instance['__down'] = false; oldInstance.mouseEvent['mouseout'](e); } + if (oldInstance._type === 'Train' && oldInstance.trainB && oldInstance.trainB.mouseEvent) { + oldDevice.instance['__click'] = false; + oldInstance.trainB.mouseEvent['cancelMouseClick'](e); + } // 如果实例有选中函数并且被点击,则执行选中函数 if (e.which == 3 && newInstance.mouseEvent && newInstance.mouseEvent.mouseover) { newDevice.instance['__down'] = true; newInstance.mouseEvent['mouseover'](e); } + if (e.which == 1 && newInstance.mouseEvent && newInstance.mouseEvent.mouseClick) { + newDevice.instance['__click'] = true; + newInstance.mouseEvent['mouseClick'](e); + } } // 保存当前实例到全局 diff --git a/src/jmapNew/shape/graph/Train/EMouse.js b/src/jmapNew/shape/graph/Train/EMouse.js index 1bf92b0f0..851eed68f 100644 --- a/src/jmapNew/shape/graph/Train/EMouse.js +++ b/src/jmapNew/shape/graph/Train/EMouse.js @@ -3,6 +3,7 @@ import Text from 'zrender/src/graphic/Text'; import LangStorage from '@/utils/lang'; import Rect from 'zrender/src/graphic/shape/Rect'; import store from '@/store/index'; +import { getSessionStorage } from '@/utils/auth'; class EMouse extends Group { constructor(device) { @@ -105,7 +106,9 @@ class EMouse extends Group { // \nNumber of people: ${this.device.model.num ? this.device.model.num : 0} const path = window.location.href; const stationNames = new Map(store.state.map.map.stationList.map(s=>[s.code, s.name])); - if (!path.includes('/practiceDisplay')) { + if (getSessionStorage('project') === 'yjddzh') { + text = `列车号:${this.device.model.groupNumber}\n位置:${this.device.model.locationKM}\n速度:${this.device.model.speed || 0} km/h\n方向:${this.device.model.right == 1 ? '下行' : '上行'}`; + } else if (!path.includes('/practiceDisplay')) { 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.destinationCode ? this.device.model.destinationCode : ''}\n Train No.: ${this.device.model.groupNumber}\n Early or late: ${destinationText}\n Direction: ${direction ? 'up' : 'down'}\n Crew No.: \n Start Station: \n Terminal Station: \n Occupied Track: ${this.device.model.sectionModel ? (this.device.model.sectionModel.parentName ? this.device.model.sectionModel.parentName : this.device.model.sectionModel.name) : ''}\n Current Station: \n Train-ground communication: normal \n Operation Speed level: 4 \n Detained: ${this.device.model.hold ? 'Detained' : 'Normal'}\n \n 跳停状态: ${this.device.model.jump ? 'Skip to continue moving' : 'Normal'}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 { @@ -120,7 +123,7 @@ class EMouse extends Group { } const trainTip = this.device.style.Train.common.trainTip; - if (trainTip) { + if (trainTip || getSessionStorage('project') === 'yjddzh') { // 文字描述 this.arrowText = new Text({ zlevel: this.device.model.zlevel, @@ -210,7 +213,41 @@ class EMouse extends Group { this.trainBorder.show(); } } - + mouseClick() { + const scaleRate = parseFloat(this.device.model.model.zrOptions.scaleRate); + const zrRect = { + x: this.device.model.model.zrOptions.offsetX / scaleRate, + y: this.device.model.model.zrOptions.offsetY / scaleRate, + width: store.state.config.width / scaleRate, + height: store.state.config.height / scaleRate + }; + this.device.deviceModel.__click = true; + const arrowTextRect = this.arrowText.getBoundingRect(); + const zrRectX = zrRect.x + zrRect.width; + const zrRectY = zrRect.y + zrRect.height; + const arrowTextRectX = arrowTextRect.x + arrowTextRect.width; + const arrowTextRectY = arrowTextRect.y + arrowTextRect.height; + if (arrowTextRectX > zrRectX || arrowTextRectY > zrRectY) { + const offsetX = arrowTextRectX > zrRectX ? arrowTextRectX - zrRectX : 0; + const offsetY = arrowTextRectY > zrRectY ? arrowTextRectY - zrRectY : 0; + this.arrowText.setStyle({ x: this.device.model.point.x + 50 - offsetX, y: this.device.model.point.y + 25 - offsetY }); + } + this.arrowText.show(); + if (this.device.style.Train.mouseOverStyle) { + this.device.deviceModel.__click = true; + this.trainBorder.show(); + } + } + cancelMouseClick() { + if (this.device.deviceModel.__click) { + this.arrowText.hide(); + this.device.deviceModel.__click = false; + } + if (this.device.style.Train.mouseOverStyle && this.device.deviceModel.__click) { + this.trainBorder.hide(); + this.device.deviceModel.__click = false; + } + } mouseout() { if (this.device.model.style.Train.common.trainTip && this.device.deviceModel.__down) { this.arrowText.hide(); diff --git a/src/jmapNew/shape/graph/Train/TrainBody.js b/src/jmapNew/shape/graph/Train/TrainBody.js index ae4acceaf..ab2881de3 100644 --- a/src/jmapNew/shape/graph/Train/TrainBody.js +++ b/src/jmapNew/shape/graph/Train/TrainBody.js @@ -27,6 +27,9 @@ export default class TrainBody extends Group { store.dispatch('map/setTrainDetails', this.deviceModel); this.mouseEvent.mouseover(); } + if (this.deviceModel.__click) { + this.mouseEvent.mouseClick(); + } this.on('mouseover', () => { store.dispatch('map/setTrainDetails', this.deviceModel); this.mouseEvent.mouseover(); @@ -35,6 +38,9 @@ export default class TrainBody extends Group { store.dispatch('map/setTrainDetails', null); this.mouseEvent.mouseout(); }); + this.on('click', () => { + this.mouseEvent.mouseClick(); + }); } create() { diff --git a/src/jmapNew/shape/graph/Train/index.js b/src/jmapNew/shape/graph/Train/index.js index 4bd545f5c..772baca6e 100644 --- a/src/jmapNew/shape/graph/Train/index.js +++ b/src/jmapNew/shape/graph/Train/index.js @@ -101,6 +101,7 @@ export default class Train extends Group { stationCode: model.stationCode, runLevel: model.runLevel, preselectionMode: model.preselectionMode, + locationKM: model.locationKM, model: model }); const rect = this.trainB.getBoundingRectOfFont().clone(); diff --git a/src/utils/baseUrl.js b/src/utils/baseUrl.js index 0c6bfc252..e6d6f27f7 100644 --- a/src/utils/baseUrl.js +++ b/src/utils/baseUrl.js @@ -27,7 +27,7 @@ export function handlerUrl(data) { BASE_API = 'https://test.joylink.club/jlcloud'; // BASE_API = 'http://192.168.3.233/rtss-server'; // BASE_API = 'http://114.116.51.125/jlcloud'; - // BASE_API = 'http://192.168.3.90:9100'; // 周寅 + BASE_API = 'http://192.168.3.90:9000'; // 周寅 // BASE_API = 'http://192.168.3.94:9000'; // 旭强 // BASE_API = 'http://192.168.3.15:9000'; // 张赛 // BASE_API = 'http://192.168.3.5:9000'; // 夏增彬 diff --git a/src/views/designPlatform/bigScreen.vue b/src/views/designPlatform/bigScreen.vue index 7daf8fed9..b784bf194 100644 --- a/src/views/designPlatform/bigScreen.vue +++ b/src/views/designPlatform/bigScreen.vue @@ -3,6 +3,7 @@
+
返回 @@ -19,12 +20,14 @@ import { creatSubscribe, clearSubscribe, displayTopic} from '@/utils/stomp'; import { getToken } from '@/utils/auth'; import { TrainingMode } from '@/scripts/ConstDic'; import WhTrainList from './whTrainList'; +import VoiceCommand from './voiceCommand'; export default { name: 'BigScreen', components: { JlmapVisual, - WhTrainList + WhTrainList, + VoiceCommand }, props: { widthLeft: { @@ -190,14 +193,14 @@ export default { const header = { group: this.$route.query.group || '', 'X-Token': getToken() }; creatSubscribe(`${displayTopic}\/${this.$route.query.group}`, header); if (this.prdType === '10') { - creatSubscribe(`/topic/yjddzh/trainPosition`, header); + creatSubscribe(`/topic/yjddzh/trainPosition/simulation/${this.$route.query.group}`, header); } // await this.$store.dispatch('training/setHasSubscribed'); }, clearSubscribe() { clearSubscribe(`${displayTopic}\/${this.$route.query.group}`); if (this.prdType === '10') { - clearSubscribe(`/topic/yjddzh/trainPosition`); + clearSubscribe(`/topic/yjddzh/trainPosition/simulation/${this.$route.query.group}`); } } } diff --git a/src/views/designPlatform/voiceCommand.vue b/src/views/designPlatform/voiceCommand.vue new file mode 100644 index 000000000..22b57de42 --- /dev/null +++ b/src/views/designPlatform/voiceCommand.vue @@ -0,0 +1,208 @@ + + + + + diff --git a/src/views/designPlatform/whTrainList.vue b/src/views/designPlatform/whTrainList.vue index 44e4c4cf6..f34bf7d05 100644 --- a/src/views/designPlatform/whTrainList.vue +++ b/src/views/designPlatform/whTrainList.vue @@ -4,9 +4,10 @@ @@ -33,15 +34,15 @@ export default { } }, watch:{ - '$store.state.socket.whTrainInfo': function (val) { - if (val) { - this.trainMap.set(val.groupNum, {groupNum: val.groupNum, direction: val.roadType === 'RIGHT' ? '右' : '左', location: val.location}); - const trainList = []; - for (const [key, value] of this.trainMap) { - trainList.push(value); + '$store.state.map.activeTrainListUpdate': function (val) { + this.trainList = []; + const activeTrainList = this.$store.state.map.activeTrainList; + activeTrainList.forEach((trainCode)=>{ + const train = this.$store.getters['map/getDeviceByCode'](trainCode); + if (train && train.sectionCode) { + this.trainList.push({groupNum: train.code, direction: train.right == 1 ? '下行' : '上行', location: train.locationKM, speed: train.speed}); } - this.trainList = trainList; - } + }); } }, mounted() { @@ -86,7 +87,6 @@ export default { display: flex; flex-direction: column; align-items: center; - text-align: center; justify-content: center; padding: 7px 4px; width: 23px;