From c2f6cf46567457dce90c3f23b26adb86b1178cf9 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Thu, 29 Aug 2019 09:30:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=A7=BB=E9=99=A4jlmap=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=8E=9F=E5=A7=8B=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/map.js | 55 +---------------------------------- src/store/modules/map.js | 63 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 57 deletions(-) diff --git a/src/jmap/map.js b/src/jmap/map.js index 966b7771a..47d7e3833 100644 --- a/src/jmap/map.js +++ b/src/jmap/map.js @@ -20,9 +20,6 @@ class Jlmap { // 鼠标事件 this.events = { __Pan: 'pan', __Zoom: 'zoom', Selected: 'selected', Contextmenu: 'contextmenu', DataZoom: 'dataZoom'}; - // 原始数据 - this.data = {}; - // 皮肤参数 this.skinCode = ''; @@ -83,12 +80,10 @@ class Jlmap { this.$options.scaleRate = map.skinVO.scaling || 1; this.$options.offsetX = map.skinVO.origin ? map.skinVO.origin.x : 0; this.$options.offsetY = map.skinVO.origin ? map.skinVO.origin.y : 0; + // 更新视图大小 this.$painter.updateTransform({ scaleRate: this.$options.scaleRate, offsetX: this.$options.offsetX, offsetY: this.$options.offsetY }); } - // 保存原始数据 - this.data = map; - // 解析地图数据 this.mapDevice = mapDevice; @@ -103,7 +98,6 @@ class Jlmap { // 视图加载完成 回调 if (this.methods.viewLoaded instanceof Function) { this.methods.viewLoaded(this.mapDevice); } - } setDefaultState() { @@ -158,7 +152,6 @@ class Jlmap { const type = elem._type; const oDevice = this.mapDevice[code] || deviceFactory(type, elem); const nDevice = Object.assign(oDevice || {}, elem); - this.dataSync(nDevice); this.$painter.delete(oDevice); if (!elem._dispose) { this.mapDevice[code] = nDevice; @@ -275,52 +268,6 @@ class Jlmap { return payload || {}; } - dataSync(model) { - var prop = null; - var type = model._type; - var code = model.code; - - switch (type) { - case deviceType.Link: prop = 'linkList'; break; - case deviceType.Section: prop = 'sectionList'; break; - case deviceType.Switch: prop = 'switchList'; break; - case deviceType.Signal: prop = 'signalList'; break; - case deviceType.Station: prop = 'stationList'; break; - case deviceType.StationStand: prop = 'stationStandList'; break; - case deviceType.StationControl: prop = 'stationControlList'; break; - case deviceType.StationCounter: prop = 'stationCounterList'; break; - case deviceType.ZcControl: prop = 'zcControlList'; break; - case deviceType.StationDelayUnlock: prop = 'stationDelayUnlockList'; break; - case deviceType.LcControl: prop = 'lcControlList'; break; - case deviceType.ButtonControl: prop = 'buttonList'; break; - case deviceType.LimitControl: prop = 'tempSpeedLimitList'; break; - case deviceType.ImageControl: prop = 'imageControl'; break; - case deviceType.Train: prop = 'trainList'; break; - case deviceType.TrainWindow: prop = 'trainWindowList'; break; - case deviceType.Line: prop = 'lineList'; break; - case deviceType.Text: prop = 'textList'; break; - } - - const list = this.data[prop] || []; - const idex = list.findIndex(elem => { return elem.code == code; }); - if (list) { - if (model._dispose) { - idex >= 0 && list.splice(idex, 1); - } else { - const elem = list[idex]; - if (elem) { - Object.keys(model).forEach(key => { - if (key != 'instance') { - elem[key] = model[key]; - } - }); - } else { - list.push(Object.assign({}, model)); - } - } - } - } - getZr() { return this.$zr; } diff --git a/src/store/modules/map.js b/src/store/modules/map.js index bcb7e8071..dc63b3d2f 100644 --- a/src/store/modules/map.js +++ b/src/store/modules/map.js @@ -191,6 +191,53 @@ function saveMapDeviceDefaultRelations(state) { } } +// 同步绘制数据到原始数据 +function dataSync(model, map) { + var prop = null; + var type = model._type; + var code = model.code; + + switch (type) { + case deviceType.Link: prop = 'linkList'; break; + case deviceType.Section: prop = 'sectionList'; break; + case deviceType.Switch: prop = 'switchList'; break; + case deviceType.Signal: prop = 'signalList'; break; + case deviceType.Station: prop = 'stationList'; break; + case deviceType.StationStand: prop = 'stationStandList'; break; + case deviceType.StationControl: prop = 'stationControlList'; break; + case deviceType.StationCounter: prop = 'stationCounterList'; break; + case deviceType.ZcControl: prop = 'zcControlList'; break; + case deviceType.StationDelayUnlock: prop = 'stationDelayUnlockList'; break; + case deviceType.LcControl: prop = 'lcControlList'; break; + case deviceType.ButtonControl: prop = 'buttonList'; break; + case deviceType.LimitControl: prop = 'tempSpeedLimitList'; break; + case deviceType.ImageControl: prop = 'imageControl'; break; + case deviceType.Train: prop = 'trainList'; break; + case deviceType.TrainWindow: prop = 'trainWindowList'; break; + case deviceType.Line: prop = 'lineList'; break; + case deviceType.Text: prop = 'textList'; break; + } + + const list = map[prop] || []; + const idex = list.findIndex(elem => { return elem.code == code; }); + if (list) { + if (model._dispose) { + idex >= 0 && list.splice(idex, 1); + } else { + const elem = list[idex]; + if (elem) { + Object.keys(model).forEach(key => { + if (key != 'instance') { + elem[key] = model[key]; + } + }); + } else { + list.push(Object.assign({}, model)); + } + } + } +} + /** * 实训状态数据 */ @@ -435,7 +482,13 @@ const map = { state.dataZoom = dataZoom; }, mapRender: (state, devices) => { - Vue.prototype.$jlmap && Vue.prototype.$jlmap.render(devices); + if (state.map) { + devices.forEach(elem => { dataSync(elem, state.map); }); + } + + if (Vue.prototype.$jlmap) { + Vue.prototype.$jlmap.render(devices); + } }, setTrainDetails: (state, details) => { state.trainDetails = details; @@ -474,14 +527,18 @@ const map = { } }); - Vue.prototype.$jlmap && Vue.prototype.$jlmap.render(trainList); + if (Vue.prototype.$jlmap) { + Vue.prototype.$jlmap.render(trainList); + } } } }, mapClear: (state) => { state.map = null; state.mapDevice = {}; - Vue.prototype.$jlmap && Vue.prototype.$jlmap.clear(); + if (Vue.prototype.$jlmap) { + Vue.prototype.$jlmap.clear(); + } } }, From faf772a2bb3e8cd5eefda98cf55e6195cb9c624b Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Thu, 29 Aug 2019 09:32:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/baseUrl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/baseUrl.js b/src/utils/baseUrl.js index 72be3b2f1..2e575c51e 100644 --- a/src/utils/baseUrl.js +++ b/src/utils/baseUrl.js @@ -3,8 +3,8 @@ export function getBaseUrl() { let BASE_API; if (process.env.NODE_ENV === 'development') { // BASE_API = 'https://joylink.club/jlcloud'; - // BASE_API = 'https://test.joylink.club/jlcloud'; - BASE_API = 'http://192.168.3.5:9000'; // 袁琪 + BASE_API = 'https://test.joylink.club/jlcloud'; + // BASE_API = 'http://192.168.3.5:9000'; // 袁琪 // BASE_API = 'http://192.168.3.6:9000'; // 旭强 // BASE_API = 'http://192.168.3.4:9000' // 琰培 } else {