diff --git a/src/jmap/shape/Switch/index.js b/src/jmap/shape/Switch/index.js index 6e5adb86a..3b30aaf60 100644 --- a/src/jmap/shape/Switch/index.js +++ b/src/jmap/shape/Switch/index.js @@ -350,12 +350,13 @@ export default class Switch extends Group { } getBoundingRect() { - return this.name.getNameText().getBoundingRect(); + return this.name.getBoundingRect(); } getShapeTipPoint() { - const rect = this.name.getNameText().getBoundingRect(); - if (rect) { + const text = this.name.getNameText(); + if (text) { + const rect = text.getBoundingRect(); return { x: rect.x + rect.width / 2, y: rect.y diff --git a/src/jmap/shape/TrainWindow/index.js b/src/jmap/shape/TrainWindow/index.js index 5047036ee..32b6e91d7 100644 --- a/src/jmap/shape/TrainWindow/index.js +++ b/src/jmap/shape/TrainWindow/index.js @@ -1,6 +1,7 @@ /* 车次窗*/ import Polygon from 'zrender/src/graphic/shape/Polygon'; import Group from 'zrender/src/container/Group'; +import store from '@/store'; class TrainWindow extends Group { constructor(model, style) { @@ -11,15 +12,13 @@ class TrainWindow extends Group { this.model = model; this.style = style; this.z = 1; + this.prdType = store.state.training.prdType; this._create(model); this.setState(model); } _create(model) { - const prdType = '02';// store.model.training.prdType; - if (prdType !== '01') { + if (this.prdType !== '01') { this.createTrainWindow(); - this.setTrainWindowEventShow(model.trainWindowShow); - this.setState(model); } } @@ -45,7 +44,9 @@ class TrainWindow extends Group { lineWidth: this.style.TrainWindow.trainWindowLineWidth, stroke: this.style.TrainWindow.trainWindowColor, fill: this.style.transparentColor - } + }, + onmouseover: () => { if (this.prdType != '') this.setTrainWindowEventShow(true); }, + onmouseout: () => { if (this.prdType != '') this.setTrainWindowEventShow(false); } }); this.add(this.trainRect); } @@ -60,7 +61,8 @@ class TrainWindow extends Group { } // 设置状态 - setState() { + setState(model) { + this.setTrainWindowEventShow(model.trainWindowShow); } setTrainWindowEventShow(show) { const lineWidth = show ? 1 : 0; diff --git a/src/jmap/theme/factory.js b/src/jmap/theme/factory.js index 6d79383cb..ba9e24a9c 100644 --- a/src/jmap/theme/factory.js +++ b/src/jmap/theme/factory.js @@ -26,16 +26,7 @@ class Theme { // 共有字段转换 loadPropConvert(code) { - var convert = require(`./${this._mapMenu[code || this._code]}/model`) || {}; - - if (!convert.hasOwnProperty('initPublicProps')) { - convert.initPublicProps = (model) => { return model; }; - } - if (!convert.hasOwnProperty('initPrivateProps')) { - convert.initPrivateProps = (model) => { return model; }; - } - - return convert; + return require(`./${this._mapMenu[code || this._code]}/model`).default; } } diff --git a/src/jmap/utils/parser.js b/src/jmap/utils/parser.js index cd2a705ae..81ac1c13f 100644 --- a/src/jmap/utils/parser.js +++ b/src/jmap/utils/parser.js @@ -36,79 +36,78 @@ export function deviceFactory(type, elem) { export function parser(data, jmap) { var mapDevice = {}; var propConvert = Vue.prototype.$theme.loadPropConvert(jmap.skinStyle); - if (data) { zrUtil.each(data.linkList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.Link, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.Link, elem)); }, this); zrUtil.each(data.sectionList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.Section, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.Section, elem)); }, this); zrUtil.each(data.signalList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.Signal, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.Signal, elem)); }, this); zrUtil.each(data.stationList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.Station, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.Station, elem)); }, this); zrUtil.each(data.stationStandList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.StationStand, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.StationStand, elem)); }, this); zrUtil.each(data.stationControlList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.StationControl, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.StationControl, elem)); }, this); zrUtil.each(data.counterList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.StationCounter, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.StationCounter, elem)); }, this); zrUtil.each(data.delayShowList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.StationDelayUnlock, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.StationDelayUnlock, elem)); }, this); zrUtil.each(data.lineList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.Line, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.Line, elem)); }, this); zrUtil.each(data.textList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.Text, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.Text, elem)); }, this); zrUtil.each(data.zcList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.ZcControl, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.ZcControl, elem)); }, this); zrUtil.each(data.lcList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.LcControl, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.LcControl, elem)); }, this); zrUtil.each(data.tempSpeedLimitList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.LimitControl, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.LimitControl, elem)); }, this); zrUtil.each(data.resourceList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.ImageControl, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.ImageControl, elem)); }, this); zrUtil.each(data.trainList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.Train, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.Train, elem)); }, this); zrUtil.each(data.trainWindowList || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.TrainWindow, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.TrainWindow, elem)); }, this); zrUtil.each(data.Line || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.Line, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.Line, elem)); }, this); zrUtil.each(data.Text || [], elem => { - mapDevice[elem.code] = deviceFactory(deviceType.Text, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.Text, elem)); }, this); zrUtil.each(data.switchList || [], elem => { @@ -147,7 +146,7 @@ export function parser(data, jmap) { rnodeSection['layer'] = -1; } - mapDevice[elem.code] = deviceFactory(deviceType.Switch, propConvert.initPrivateProps(elem)); + mapDevice[elem.code] = propConvert.initPrivateProps(deviceFactory(deviceType.Switch, elem)); }, this); }