From 933f0c1bba7bf178c83c1c3f2c9271f765c95789 Mon Sep 17 00:00:00 2001 From: zyy <1787816799@qq.com> Date: Mon, 16 Mar 2020 16:06:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=BB=BC=E5=90=88=E6=BC=94?= =?UTF-8?q?=E7=BB=83ibp=E8=8E=B7=E5=8F=96=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ibp.js | 8 ++ .../ningbo_01/menus/dialog/stationControl.vue | 2 +- .../ningbo_01/menus/menuStationControl.vue | 10 +- src/views/ibp/create.vue | 38 ++++--- src/views/ibp/ibpsystem/index.vue | 104 +++++++++++------- 5 files changed, 99 insertions(+), 63 deletions(-) diff --git a/src/api/ibp.js b/src/api/ibp.js index eb651aa15..24f29775e 100644 --- a/src/api/ibp.js +++ b/src/api/ibp.js @@ -59,3 +59,11 @@ export function getIbpInfo(id) { method: 'get' }); } + +// 根据线路编码和车站编码查询IBP数据 +export function getIbpInfoByStation(mapId, stationCode) { + return request({ + url: `/api/ibp/query?mapId=${mapId}&stationCode=${stationCode}`, + method: 'get' + }); +} diff --git a/src/jmapNew/theme/ningbo_01/menus/dialog/stationControl.vue b/src/jmapNew/theme/ningbo_01/menus/dialog/stationControl.vue index b4ce94a54..3922cc33c 100644 --- a/src/jmapNew/theme/ningbo_01/menus/dialog/stationControl.vue +++ b/src/jmapNew/theme/ningbo_01/menus/dialog/stationControl.vue @@ -211,7 +211,7 @@ export default { operation: '', cmdType: '', param: { - stationList: list + stationCodes: list } }; if (this.controlMode == 'center') { diff --git a/src/jmapNew/theme/ningbo_01/menus/menuStationControl.vue b/src/jmapNew/theme/ningbo_01/menus/menuStationControl.vue index e139e138f..72b195cce 100644 --- a/src/jmapNew/theme/ningbo_01/menus/menuStationControl.vue +++ b/src/jmapNew/theme/ningbo_01/menus/menuStationControl.vue @@ -115,10 +115,7 @@ export default { const step = { start: true, code: this.selected.code, - operation: OperationEvent.StationControl.requestCentralControl.menu.operation, - param: { - stationControlCode: this.selected.code - } + operation: OperationEvent.StationControl.requestCentralControl.menu.operation }; this.$store.dispatch('training/nextNew', step).then(({ valid }) => { if (valid) { @@ -131,10 +128,7 @@ export default { const step = { start: true, code: this.selected.code, - operation: OperationEvent.StationControl.requestStationControl.menu.operation, - param: { - stationControlCode: this.selected.code - } + operation: OperationEvent.StationControl.requestStationControl.menu.operation }; this.$store.dispatch('training/nextNew', step).then(({ valid }) => { if (valid) { diff --git a/src/views/ibp/create.vue b/src/views/ibp/create.vue index 7747eb17b..89847eaed 100644 --- a/src/views/ibp/create.vue +++ b/src/views/ibp/create.vue @@ -53,24 +53,32 @@ export default { return crules; } }, - async created () { - try { - const res = await getStationList(this.$route.params.mapId); - this.stationList = []; - if (res.code == 200) { - res.data.forEach(station => { - const param = { - label: station.name, - value: station.code - }; - this.stationList.push(param); - }); - } - } catch (error) { - console.log(error); + watch: { + '$route.params.mapId': function() { + this.getStationLIst(); } }, + async created () { + this.getStationLIst(); + }, methods: { + async getStationLIst() { + try { + const res = await getStationList(this.$route.params.mapId); + this.stationList = []; + if (res.code == 200) { + res.data.forEach(station => { + const param = { + label: station.name, + value: station.code + }; + this.stationList.push(param); + }); + } + } catch (error) { + console.log(error); + } + }, doShow(data) { if (data) { this.formModel.stationCode = data.stationCode; diff --git a/src/views/ibp/ibpsystem/index.vue b/src/views/ibp/ibpsystem/index.vue index 199c7dfd5..6d4bfef82 100644 --- a/src/views/ibp/ibpsystem/index.vue +++ b/src/views/ibp/ibpsystem/index.vue @@ -9,12 +9,13 @@ import Vue from 'vue'; import IbpPan from '@/ibp/ibpPan'; import { parser } from '@/ibp/utils/parser'; -import ibpData from '@/ibp/constant/ibpData'; +// import ibpData from '@/ibp/constant/ibpData'; import { mapGetters } from 'vuex'; import { exitFullscreen } from '@/utils/screen'; import { putJointTrainingSimulationUser } from '@/api/chat'; import { handlerIbpEvent } from '@/api/simulation'; import { IbpOperation } from '@/scripts/ConstDic'; +import { getIbpInfoByStation } from '@/api/ibp'; export default { name: 'Ibp', @@ -90,7 +91,7 @@ export default { this.ibpDestroy(); }, methods: { - initIbp() { + initIbp(offsetX = 0) { this.ibpDestroy(); this.loading = true; this.$ibp = new IbpPan({ @@ -102,7 +103,7 @@ export default { }, options: { scaleRate: 1, - offsetX: 0, + offsetX: offsetX, offsetY: 0 }, methods: { @@ -115,29 +116,52 @@ export default { this.$ibp.on('selected', this.onSelected, this); } }, - show (deviceCode) { + async show (deviceCode, ibpPart) { if (!deviceCode) { return; } - this.stationCode = deviceCode; - document.getElementById(this.ibpId).oncontextmenu = function (e) { - return false; - }; - // let offsetX = 0; - // if (ibpPart === 'left') { - // offsetX = 0; - // } else if (ibpPart === 'right') { - // offsetX = 1920; - // } - const data = parser(ibpData[deviceCode], {width: this.canvasWidth, height: this.canvasHeight}); + // console.log(deviceCode); + // const ibpDatas = ibpData[deviceCode]; + try { + const res = await getIbpInfoByStation(this.$route.query.mapId, deviceCode); + if (res.data.data) { + const ibpDatas = JSON.parse(res.data.data).drawData; + this.stationCode = deviceCode; + document.getElementById(this.ibpId).oncontextmenu = function (e) { + return false; + }; + let offsetX = 0; + if (ibpPart === 'left') { + offsetX = 0; + } else if (ibpPart === 'right') { + offsetX = 1920; + } + const data = parser(ibpDatas, {width: this.canvasWidth, height: this.canvasHeight}); // ibp 绘图编译数据 + this.initIbp(offsetX); - this.setIbp(data, ibpData[deviceCode]); - this.$store.dispatch('ibp/setIbpData', ibpData[deviceCode]); - this.handleBanOpenScreenDoorStatus(); - this.initClockTime(this.initTime); + this.setIbp(data, ibpDatas); + this.$store.dispatch('ibp/setIbpData', ibpDatas); + this.handleBanOpenScreenDoorStatus(); + this.initClockTime(this.initTime); + } else { + // 无数据 + this.loading = false; + this.$alert('当前ibp盘数据不存在', '信息', { + confirmButtonText: '确定', + callback: action => {} + }); + } + } catch (error) { + this.loading = false; + this.$alert('当前ibp盘数据不存在', '信息', { + confirmButtonText: '确定', + callback: action => {} + }); + } window.document.oncontextmenu = function () { return false; }; + }, setIbp(data, oldData) { this.$ibp.setIbp(oldData, data); @@ -154,31 +178,33 @@ export default { // 点击选择事件 onSelected(em) { if (em.deviceModel.mean) { - switch (IbpOperation[em.deviceModel.mean].event) { - case 'UpHoldTrain': - case 'UpCancelHoldTrain': - case 'DownHoldTrain': - case 'DownCancelHoldTrain': - handlerIbpEvent(this.$route.query.group, {operate:IbpOperation[em.deviceModel.mean].operate, stationCode: this.stationCode}); - break; - case 'BanUpOpenScreenDoor': - this.banUpOpenScreenDoor = !this.banUpOpenScreenDoor; - break; - case 'BanDownOpenScreenDoor': - this.banDownOpenScreenDoor = !this.banDownOpenScreenDoor; - break; - case 'UpOpenScreenDoor': - this.openScreenDoor(this.banUpOpenScreenDoor, IbpOperation[em.deviceModel.mean].operate); - break; - case 'DownOpenScreenDoor': - this.openScreenDoor(this.banDownOpenScreenDoor, IbpOperation[em.deviceModel.mean].operate); - break; + if (IbpOperation[em.deviceModel.mean]) { + switch (IbpOperation[em.deviceModel.mean].event) { + case 'UpHoldTrain': + case 'UpCancelHoldTrain': + case 'DownHoldTrain': + case 'DownCancelHoldTrain': + handlerIbpEvent(this.$route.query.group, {operate: IbpOperation[em.deviceModel.mean].operate, stationCode: this.stationCode}); + break; + case 'BanUpOpenScreenDoor': + this.banUpOpenScreenDoor = !this.banUpOpenScreenDoor; + break; + case 'BanDownOpenScreenDoor': + this.banDownOpenScreenDoor = !this.banDownOpenScreenDoor; + break; + case 'UpOpenScreenDoor': + this.openScreenDoor(this.banUpOpenScreenDoor, IbpOperation[em.deviceModel.mean].operate); + break; + case 'DownOpenScreenDoor': + this.openScreenDoor(this.banDownOpenScreenDoor, IbpOperation[em.deviceModel.mean].operate); + break; + } } } }, openScreenDoor(flag, operate) { if (flag) { - handlerIbpEvent(this.$route.query.group, {operate: operate, stationCode:this.stationCode}); + handlerIbpEvent(this.$route.query.group, {operate: operate, stationCode: this.stationCode}); } }, // 右键点击事件