diff --git a/src/ibp/constant/deviceRender.js b/src/ibp/constant/deviceRender.js index f202bef70..d807262b8 100644 --- a/src/ibp/constant/deviceRender.js +++ b/src/ibp/constant/deviceRender.js @@ -4,78 +4,99 @@ const deviceRender = {}; /** IbpText渲染配置*/ deviceRender[deviceType.IbpText] = { + _type: deviceType.IbpText, zlevel: 3 }; /** SquareButton渲染配置*/ deviceRender[deviceType.SquareButton] = { + _type: deviceType.SquareButton, zlevel: 3 }; /** WarnButton渲染配置*/ deviceRender[deviceType.WarnButton] = { + _type: deviceType.WarnButton, zlevel: 3 }; /** Arrow渲染配置*/ deviceRender[deviceType.Arrow] = { + _type: deviceType.Arrow, zlevel: 2 }; /** RotatingButton渲染配置*/ deviceRender[deviceType.RotatingButton] = { + _type: deviceType.RotatingButton, zlevel: 3 }; /** TipBox渲染配置*/ deviceRender[deviceType.TipBox] = { + _type: deviceType.TipBox, zlevel: 2, z: 2 }; /** BackGround渲染配置*/ deviceRender[deviceType.Background] = { + _type: deviceType.Background, zlevel: 0 }; /** CircularLamp渲染配置 */ deviceRender[deviceType.CircularLamp] = { + _type: deviceType.CircularLamp, zlevel: 3 }; /** AppendageBox渲染配置 */ deviceRender[deviceType.AppendageBox] = { + _type: deviceType.AppendageBox, zlevel: 1 }; /** IbpLine渲染配置 */ deviceRender[deviceType.IbpLine] = { + _type: deviceType.IbpLine, zlevel: 1 }; /** Elevator 渲染配置 */ deviceRender[deviceType.Elevator] = { + _type: deviceType.Elevator, zlevel: 2, z: 1 }; /** Key 渲染配置 */ deviceRender[deviceType.Key] = { + _type: deviceType.Key, zlevel: 4 }; /** TeleTerminal 渲染配置 */ deviceRender[deviceType.TeleTerminal] = { + _type: deviceType.TeleTerminal, zlevel: 3 }; /** Clock 渲染配置*/ deviceRender[deviceType.Clock] = { + _type: deviceType.Clock, zlevel: 3 }; /** RotateTip 渲染配置 */ deviceRender[deviceType.RotateTip] = { + _type: deviceType.RotateTip, + zlevel: 3 +}; + +/** Alarm */ +deviceRender[deviceType.Alarm] = { + _type: deviceType.Alarm, zlevel: 3 }; diff --git a/src/ibp/ibpPan.js b/src/ibp/ibpPan.js index 11c80092a..891ba74b4 100644 --- a/src/ibp/ibpPan.js +++ b/src/ibp/ibpPan.js @@ -6,7 +6,7 @@ import MouseController from './mouseController'; import Painter from './painter'; import deviceState from '../jmap/constant/deviceState'; import deviceType from './constant/deviceType'; -import {calculateDCenter, createBoundingRect, modelFactory} from './utils/parser'; +import {calculateDCenter, createBoundingRect, deviceFactory} from './utils/parser'; import { updateIbpData } from './utils/parser'; const renderer = 'canvas'; @@ -135,7 +135,7 @@ class IbpPan { const code = elem.code; const type = elem._type; updateIbpData(elem); - const oDevice = this.ibpDevice[code] || {instance: null, event: null, model: modelFactory(type, elem)}; + const oDevice = this.ibpDevice[code] || {instance: null, event: null, model: deviceFactory(type, elem)}; const nDevice = {instance: null, event: null, model: Object.assign(oDevice.model || {}, elem)}; this.$painter.delete(oDevice); if (!elem._dispose) { diff --git a/src/ibp/painter.js b/src/ibp/painter.js index 21925723e..7be06a48e 100644 --- a/src/ibp/painter.js +++ b/src/ibp/painter.js @@ -59,13 +59,17 @@ class Painter { * @param {*} device */ add(device, draggable) { - device = Object.assign(device, { event: this.$ibp.$mouseController }); - const instance = shapefactory(device, this.$ibp); - if (instance) { - device.instance = instance; - draggable?instance.setDraggable():''; - this.$transformHandle.transformView(instance); - this.ibpInstanceLevel[device.model._type].add(instance); + try { + device = Object.assign(device, { event: this.$ibp.$mouseController }); + const instance = shapefactory(device, this.$ibp); + if (instance) { + device.instance = instance; + draggable?instance.setDraggable():''; + this.$transformHandle.transformView(instance); + this.ibpInstanceLevel[device.model._type].add(instance); + } + } catch (error) { + console.error(error); } } diff --git a/src/ibp/utils/parser.js b/src/ibp/utils/parser.js index d81d83cf8..b948fa3fb 100644 --- a/src/ibp/utils/parser.js +++ b/src/ibp/utils/parser.js @@ -29,324 +29,139 @@ export function calculateDCenter(viewRect, zrbound) { return { dx: dx, dy: dy }; } -export function modelFactory(type, elem) { - return Object.assign(elem, { _type: type }, deviceRender[type]); -} - -export function createModel(type, model, propConvert) { - const tempModel = modelFactory(type, model); - return { instance: null, event: null, model: propConvert ? propConvert.initPrivateProps(tempModel) : tempModel }; +export function deviceFactory(type, elem) { + return Object.assign({instance: null, event: null, model: Object(elem, deviceRender[type])}); } export function parser(data) { var ibpDevice = {}; - const propConvert = null; - // var propConvert = skinCode ? Vue.prototype.$theme.loadPropConvert(skinCode): null; if (data) { Object.assign(data.background); - ibpDevice[data.background.code] = createModel(deviceType.Background, data.background, propConvert); + ibpDevice[data.background.code] = deviceFactory(deviceType.Background, data.background); zrUtil.each(data.textList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.IbpText, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.IbpText, elem); }, this); zrUtil.each(data.squareButtonList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.SquareButton, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.SquareButton, elem); }, this); zrUtil.each(data.circularLampList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.CircularLamp, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.CircularLamp, elem); }, this); zrUtil.each(data.alarmList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.Alarm, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.Alarm, elem); }, this); zrUtil.each(data.arrowList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.Arrow, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.Arrow, elem); }, this); zrUtil.each(data.rotatingButtonList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.RotatingButton, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.RotatingButton, elem); }, this); zrUtil.each(data.tipBoxList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.TipBox, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.TipBox, elem); }, this); zrUtil.each(data.ibpLineList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.IbpLine, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.IbpLine, elem); }, this); zrUtil.each(data.appendageBoxList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.AppendageBox, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.AppendageBox, elem); }, this); zrUtil.each(data.elevatorList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.Elevator, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.Elevator, elem); }, this); zrUtil.each(data.keyList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.Key, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.Key, elem); }, this); zrUtil.each(data.teleTerminalList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.TeleTerminal, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.TeleTerminal, elem); }, this); zrUtil.each(data.clockList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.Clock, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.Clock, elem); }); zrUtil.each(data.rotateTipList || [], elem => { - ibpDevice[elem.code] = createModel(deviceType.RotateTip, elem, propConvert); + ibpDevice[elem.code] = deviceFactory(deviceType.RotateTip, elem); }); } return ibpDevice; } + +function updateIbpListByDevice(ibp, name, device) { + var list = ibp[name]; + if (list) { + const index = list.findIndex(elem => { return elem.code == device.code; }); + if (index >= 0) { + list[index].dispose ? list.splice(index, 1) : list[index] = device; + } else { + list.push(device); + } + } else { + ibp[name] = [device]; + } + + return list; +} + export function updateIbpData(device) { const ibpData = store.getters['ibp/ibp']; switch (device._type) { - case deviceType.Background : { + case deviceType.Background : ibpData.background = device; break; - } - case deviceType.IbpText : { - if (ibpData.textList && ibpData.textList.length > 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i 0) { - let newDevice = true; - for (let i=0; i
- IBP盘 + IBP盘 司机视角