diff --git a/src/store/modules/socket.js b/src/store/modules/socket.js index 7a3d6f300..9490c50b4 100644 --- a/src/store/modules/socket.js +++ b/src/store/modules/socket.js @@ -342,6 +342,7 @@ const socket = { deviceStateMessages: null, // 新版订阅设备状态消息 iscsStateMessages: null, // iscs设备状态消息 iscsStatePaMessages: null, // iscsPA设备状态消息 + iscsStatePisMessages: null, // iscsPIS设备状态消息 simulationSpeed: 1, // 仿真倍速 simulationPause: false, simulationPslStatus: [], // PSL面板按钮状态信息 @@ -429,6 +430,9 @@ const socket = { }, setIscsStatePaMessages: (state, speed) => { state.iscsStatePaMessages = speed; + }, + setIscsStatePisMessages: (state, speed) => { + state.iscsStatePisMessages = speed; } }, @@ -520,6 +524,9 @@ const socket = { }, handleIscsPaState:({ commit }, state) => { commit('setIscsStatePaMessages', state); + }, + handleIscsPisState:({ commit }, state) => { + commit('setIscsStatePisMessages', state); } } }; diff --git a/src/utils/stomp.js b/src/utils/stomp.js index 2a78a700b..c420e0fbb 100644 --- a/src/utils/stomp.js +++ b/src/utils/stomp.js @@ -60,6 +60,8 @@ function callback(Response) { store.dispatch('socket/handleIscsState', JSON.parse(Response.body)); } else if (Response.headers.destination.includes('iscs/pa')) { store.dispatch('socket/handleIscsPaState', JSON.parse(Response.body)); + } else if (Response.headers.destination.includes('iscs/pis')) { + store.dispatch('socket/handleIscsPisState', JSON.parse(Response.body)); } else { const data = JSON.parse(Response.body); store.dispatch('socket/setStomp', data); diff --git a/src/views/iscs/iscsSystem/config/pis/infoBroadcast.vue b/src/views/iscs/iscsSystem/config/pis/infoBroadcast.vue index 368699891..9f54b77c1 100644 --- a/src/views/iscs/iscsSystem/config/pis/infoBroadcast.vue +++ b/src/views/iscs/iscsSystem/config/pis/infoBroadcast.vue @@ -233,7 +233,17 @@ export default { }, releaseBroadcast() { this.visible = false; - if (this.resource) { + if (this.addModel.infoType === 'realTime') { + if (!this.addModel.infoTitle) { + this.$message.error('请输入实时信息标题!'); + } else if (!this.addModel.infoContent) { + this.$message.error('请输入实时信息内容!'); + } else { + this.$emit('releaseBroadcast', {name: this.addModel.infoTitle, content: this.addModel.infoContent }); + this.addModel.infoContent = ''; + this.addModel.infoTitle = ''; + } + } else if (this.resource) { this.$emit('releaseBroadcast', this.resource); } }, diff --git a/src/views/iscs/iscsSystem/config/pis/mainScreen.vue b/src/views/iscs/iscsSystem/config/pis/mainScreen.vue index a5b255fdd..5ceab6cc6 100644 --- a/src/views/iscs/iscsSystem/config/pis/mainScreen.vue +++ b/src/views/iscs/iscsSystem/config/pis/mainScreen.vue @@ -21,7 +21,7 @@
-
+
@@ -72,6 +72,8 @@ import { getByGroupStationList } from '@/api/jmap/map'; import { queryIscsDeviceCod } from '@/api/iscs'; import InfoBroadcast from './infoBroadcast'; import { sendCommandNew } from '@/api/jmap/training'; +import { creatSubscribe, clearSubscribe, getTopic } from '@/utils/stomp'; +import { getToken } from '@/utils/auth'; export default { name:'MainScreen', components: { @@ -92,9 +94,25 @@ export default { ], stationList:[], selectedAreaList: [], + iscsDeviceMap: {}, deviceMap: {} }; }, + watch: { + '$store.state.socket.iscsStatePisMessages': function (list) { + if (list && list.length) { + list.forEach(item => { + const index = this.iscsDeviceMap[item.code]; + if (index) { + this.$set(this.deviceMap[index], 'state', item.state); + const div = document.getElementById(index); + div.style.background = item.state === 'normal' ? '#2EFF74' : '#D4D4D4'; + } + }); + } + + } + }, async created () { // 请求当前线路车站列表 try { @@ -120,6 +138,7 @@ export default { if (station.code == item.station) { const index = positionMap[item.position]; children[index].status = 'default'; + this.iscsDeviceMap[item.code] = station.code + '-' + index; this.deviceMap[station.code + '-' + index] = item; } }); @@ -133,10 +152,13 @@ export default { } }); } + this.subscribe(); } catch (e) { this.$message.error('获取车站列表失败!'); } - + }, + beforeDestroy() { + this.clearSubscribe(); }, methods:{ showInfoBrroadcast() { @@ -173,10 +195,13 @@ export default { } const params = { resourceId: voice.id, - iscsDeviceCodes: iscsDeviceCodes + iscsDeviceCodes: iscsDeviceCodes, + name: voice.name, + content: voice.content }; + console.log(voice, '------', params); sendCommandNew(this.$route.query.group, 'ISCS_PIS_Play', params).then(resp => { - const voiceUrl = this.$store.state.user.resourcesUrl + voice.url; + const voiceUrl = this.$store.state.user.resourcesUrl + (voice.url || resp.data); const audio = document.getElementById('voice'); audio.src = voiceUrl; audio.play(); @@ -250,6 +275,15 @@ export default { } }); }); + }, + subscribe() { + this.clearSubscribe(); + const header = { group: this.$route.query.group || '', 'X-Token': getToken() }; + creatSubscribe(getTopic('ISCSPIS', this.$route.query.group ), header); + this.$store.dispatch('app/animationsClose'); + }, + clearSubscribe() { + clearSubscribe(getTopic('ISCSPIS', this.$route.query.group)); } } };