diff --git a/src/assets/ibp_images/ibp_bg.png b/src/assets/ibp_images/ibp_bg.png index 6e48da514..e8bffd28e 100644 Binary files a/src/assets/ibp_images/ibp_bg.png and b/src/assets/ibp_images/ibp_bg.png differ diff --git a/src/ibp/constant/deviceType.js b/src/ibp/constant/deviceType.js index c31c54c19..a1d6f6172 100644 --- a/src/ibp/constant/deviceType.js +++ b/src/ibp/constant/deviceType.js @@ -1,7 +1,6 @@ const deviceType = { IbpText: 'IbpText', SquareButton: 'SquareButton', - WarnButton: 'WarnButton', Arrow: 'Arrow', RotatingButton: 'RotatingButton', TipBox: 'TipBox', diff --git a/src/ibp/constant/ibpData.js b/src/ibp/constant/ibpData.js index 0e74a3e8d..adf786159 100644 --- a/src/ibp/constant/ibpData.js +++ b/src/ibp/constant/ibpData.js @@ -1,53 +1,3 @@ -const ibpData = { - background: { - type: 'Background', - code: 'bg_0000' - }, - arrowList: [ - { - type: 'Arrow', - code: '1111_arrow', - point: { - x: 510, - y: 400 - }, - length: 488, - width: 10, - stroke: '#0000CD', - fill: '#0000CD', - lineWidth: 1, - direction: '上行', - stationstandDirection: '三桥方向' - }, - { - type: 'Arrow', - code: '1222_arrow', - point: { - x: 510, - y: 200 - }, - length: 488, - width: 10, - stroke: '#0000CD', - fill: '#0000CD', - lineWidth: 1, - direction: '下行', - stationstandDirection: '车辆段方向' - } - ], - circularLampList: [ - { - type: 'CircularLamp', - code: '1333_lamp', - point: { - x: 600, - y: 600 - }, - r: 40, - fillColor: '#332C22' - } - ] -}; - +const ibpData = {"background":{"type":"Background","code":"bg_0000","width":800,"height":600,"_type":"Background","zlevel":0},"arrowList":[{"zlevel":2,"z":1,"point":{"x":518,"y":273},"_type":"Arrow","code":"arrow_0001","orientation":"left","fill":"#0000CD","width":10,"length":488,"lineWidth":1},{"zlevel":2,"z":1,"point":{"x":518,"y":451},"_type":"Arrow","code":"arrow_0002","orientation":"right","fill":"#0000CD","width":10,"length":488,"lineWidth":1}],"circularLampList":[],"textList":[{"code":"text_0001","context":"隧 道 紧 急 通 风","fontFamily":"consolas","fontSize":38,"fontWeight":900,"point":{"x":452,"y":26},"textFill":"#000","z":1,"zlevel":2,"_type":"IbpText"},{"zlevel":2,"z":1,"point":{"x":40,"y":243},"code":"text_0002","_type":"IbpText","context":"车 辆 段 方 向","textFill":"#000","fontSize":22,"fontWeight":700,"fontFamily":"consolas"},{"zlevel":2,"z":1,"point":{"x":41,"y":287},"code":"text_0003","_type":"IbpText","context":"下 行","textFill":"#000","fontSize":22,"fontWeight":700,"fontFamily":"consolas"},{"zlevel":2,"z":1,"point":{"x":942,"y":422},"code":"text_0004","_type":"IbpText","context":"上 行","textFill":"#000","fontSize":22,"fontWeight":700,"fontFamily":"consolas"},{"zlevel":2,"z":1,"point":{"x":871,"y":466},"code":"text_0005","_type":"IbpText","context":"三 桥 方 向","textFill":"#000","fontSize":22,"fontWeight":700,"fontFamily":"consolas"},{"zlevel":2,"z":1,"point":{"x":88,"y":203},"code":"text_0006","_type":"IbpText","context":" DH14\n入段线车头","textFill":"#000","fontSize":8,"fontWeight":800,"fontFamily":"consolas"},{"zlevel":2,"z":1,"point":{"x":138,"y":202},"code":"text_0008","_type":"IbpText","context":" DH15\n入段线车尾","textFill":"#000","fontSize":8,"fontWeight":800,"fontFamily":"consolas"},{"zlevel":2,"z":1,"point":{"x":186,"y":200},"code":"text_0009","_type":"IbpText","context":" DH16\n入段线车中\n 进洞口\n疏散同行车","textFill":"#000","fontSize":8,"fontWeight":800,"fontFamily":"consolas"}],"squareButtonList":[{"zlevel":2,"z":1,"point":{"x":10,"y":7},"_type":"SquareButton","code":"button_0001","color":"red","status":"off","width":25,"height":30},{"zlevel":2,"z":1,"point":{"x":145,"y":169},"_type":"SquareButton","code":"button_0002","color":"red","status":"off","width":25,"height":1},{"zlevel":2,"z":1,"point":{"x":195,"y":168},"_type":"SquareButton","code":"button_0003","color":"red","status":"off","width":25,"height":1},{"zlevel":2,"z":1,"point":{"x":243,"y":169},"_type":"SquareButton","code":"button_0004","color":"red","status":"off","width":25,"height":1},{"zlevel":2,"z":1,"point":{"x":292,"y":168},"_type":"SquareButton","code":"button_0005","color":"red","status":"off","width":25,"height":1},{"zlevel":2,"z":1,"point":{"x":341,"y":169},"_type":"SquareButton","code":"button_0006","color":"red","status":"off","width":25,"height":1}]} export default ibpData; diff --git a/src/ibp/ibpPan.js b/src/ibp/ibpPan.js index 1d03e7739..c23384f9b 100644 --- a/src/ibp/ibpPan.js +++ b/src/ibp/ibpPan.js @@ -7,6 +7,7 @@ import Painter from './painter'; import deviceState from '../jmap/constant/deviceState'; import deviceType from './constant/deviceType'; import {calculateDCenter, createBoundingRect, modelFactory} from './utils/parser'; +import { updateIbpData } from './utils/parser'; const renderer = 'canvas'; const devicePixelRatio = 1; @@ -125,6 +126,7 @@ class IbpPan { (list || []).forEach(elem => { const code = elem.code; const type = elem._type; + updateIbpData(elem); const oDevice = this.ibpDevice[code] || {instance: null, event: null, model: modelFactory(type, elem)}; const nDevice = {instance: null, event: null, model: Object.assign(oDevice.model || {}, elem)}; this.$painter.delete(oDevice); diff --git a/src/ibp/shape/alarm.js b/src/ibp/shape/alarm.js index 535ac7077..ce3aebddc 100644 --- a/src/ibp/shape/alarm.js +++ b/src/ibp/shape/alarm.js @@ -1,6 +1,7 @@ import Group from 'zrender/src/container/Group'; import Image from 'zrender/src/graphic/Image'; import alarmpic from '@/assets/ibp_images/alarm.png'; +import store from '@/store'; export default class alarm extends Group { @@ -9,6 +10,8 @@ export default class alarm extends Group { this.model = device.model; this.event = device.event; this.zlevel = device.model.zlevel; + this.offsetX = 0; + this.offsetY = 0; this.create(); } @@ -26,17 +29,17 @@ export default class alarm extends Group { } }); this.add(this.imageBg); - this.transformScale(); + this.transformScale(); + } + /** 缩放按钮 */ + transformScale() { + this.imageBg.origin = [this.model.point.x, this.model.point.y]; + this.imageBg.scale =[this.model.width/71, this.model.width/71]; + this.imageBg.dirty(); } - /** 缩放按钮 */ - transformScale() { - this.imageBg.origin = [this.model.point.x, this.model.point.y]; - this.imageBg.scale =[this.model.width/71, this.model.width/71]; - this.imageBg.dirty(); - } setDraggable() { - this.arrow.attr('draggable', true); + this.imageBg.attr('draggable', true); this.createMouseEvent(); } createMouseEvent() { @@ -47,6 +50,11 @@ export default class alarm extends Group { mousedown(e) { this.event.disable(); + if (e.which == 3) { + store.dispatch('ibp/setUpdateDeviceData', this.model); + } + this.offsetX = e.offsetX; + this.offsetY = e.offsetY; } mousemove(e) { @@ -54,7 +62,7 @@ export default class alarm extends Group { mouseup(e) { this.event.enable(); - this.model.point.x = this.model.point.x + e.offsetX; - this.model.point.y = this.model.point.y + e.offsetY; + this.model.point.x = this.model.point.x + (e.offsetX - this.offsetX); + this.model.point.y = this.model.point.y + (e.offsetY - this.offsetY); } } diff --git a/src/ibp/shape/appendageBox.js b/src/ibp/shape/appendageBox.js index 2a84a0471..a4e6b2c29 100644 --- a/src/ibp/shape/appendageBox.js +++ b/src/ibp/shape/appendageBox.js @@ -1,6 +1,7 @@ import Group from 'zrender/src/container/Group'; import Image from 'zrender/src/graphic/Image'; import AppendageBoxImage from '@/assets/ibp_images/appendage_box.png'; +import store from '@/store'; export default class AppendageBox extends Group { constructor(device) { @@ -9,6 +10,8 @@ export default class AppendageBox extends Group { this.event = device.event; this.zlevel = device.model.zlevel; this.z = device.model.z; + this.offsetX = 0; + this.offsetY = 0; this.create(); } @@ -37,17 +40,19 @@ export default class AppendageBox extends Group { this.on('mousemove', this.mousemove, this); this.on('mouseup', this.mouseup, this); } - mousedown() { + mousedown(e) { this.event.disable(); - console.log('鼠标按下'); + if (e.which == 3) { + store.dispatch('ibp/setUpdateDeviceData', this.model); + } + this.offsetX = e.offsetX; + this.offsetY = e.offsetY; } mousemove() { - console.log('鼠标移动'); } mouseup(e) { this.event.enable(); - this.model.x = this.model.x + e.offsetX; - this.model.y = this.model.y + e.offsetY; - console.log('鼠标抬起'); + this.model.point.x = this.model.point.x + (e.offsetX - this.offsetX); + this.model.point.y = this.model.point.y + (e.offsetY - this.offsetY); } } diff --git a/src/ibp/shape/arrow.js b/src/ibp/shape/arrow.js index 9c88aed5a..7168b7937 100644 --- a/src/ibp/shape/arrow.js +++ b/src/ibp/shape/arrow.js @@ -2,12 +2,15 @@ import Polygon from 'zrender/src/graphic/shape/Polygon'; import Group from 'zrender/src/container/Group'; import {arrow} from '@/jmap/shape/utils/ShapePoints'; // import { updateIbpData } from '@/ibp/utils/parser'; +import store from '@/store'; class Arrow extends Group { constructor(device) { super(); this.event = device.event; this.model = device.model; + this.offsetX = 0; + this.offsetY = 0; this.create(); } @@ -71,18 +74,20 @@ class Arrow extends Group { this.on('mousemove', this.mousemove, this); this.on('mouseup', this.mouseup, this); } - mousedown() { + mousedown(e) { this.event.disable(); - console.log('鼠标按下'); + if (e.which == 3) { + store.dispatch('ibp/setUpdateDeviceData', this.model); + } + this.offsetX = e.offsetX; + this.offsetY = e.offsetY; } mousemove() { - console.log('鼠标移动'); } mouseup(e) { this.event.enable(); - this.model.point.x = this.model.point.x + e.offsetX; - this.model.point.y = this.model.point.y + e.offsetY; - console.log('鼠标抬起', this.model); + this.model.point.x = this.model.point.x + (e.offsetX - this.offsetX); + this.model.point.y = this.model.point.y + (e.offsetY - this.offsetY); } } diff --git a/src/ibp/shape/button.js b/src/ibp/shape/button.js index c0d5446c9..64f7e894a 100644 --- a/src/ibp/shape/button.js +++ b/src/ibp/shape/button.js @@ -10,6 +10,7 @@ import yellowButtonPic from '@/assets/ibp_images/yellow_button.png'; import yellowButtonPicOn from '@/assets/ibp_images/yellow_button_on.png'; import grayButtonPic from '@/assets/ibp_images/gray_button.png'; import grayButtonPicOn from '@/assets/ibp_images/gray_button_on.png'; +import store from '@/store'; export default class button extends Group { static colors = new Map([ @@ -29,6 +30,8 @@ export default class button extends Group { this.model = device.model; this.zlevel = device.model.zlevel; this.event = device.event; + this.offsetX = 0; + this.offsetY = 0; this.create(); } create() { @@ -105,17 +108,20 @@ export default class button extends Group { } } - mousedown() { + mousedown(e) { this.event.disable(); - console.log('鼠标按下'); + if (e.which == 3) { + store.dispatch('ibp/setUpdateDeviceData', this.model); + } + this.offsetX = e.offsetX; + this.offsetY = e.offsetY; } mousemove() { } mouseup(e) { this.event.enable(); - this.model.point.x = this.model.point.x + e.offsetX; - this.model.point.y = this.model.point.y + e.offsetY; - console.log('鼠标抬起', this.model); + this.model.point.x = this.model.point.x + (e.offsetX - this.offsetX); + this.model.point.y = this.model.point.y + (e.offsetY - this.offsetY); } // 关闭 close() { diff --git a/src/ibp/shape/circularLamp.js b/src/ibp/shape/circularLamp.js index de3f8e6c0..4260daeba 100644 --- a/src/ibp/shape/circularLamp.js +++ b/src/ibp/shape/circularLamp.js @@ -1,5 +1,6 @@ import Group from 'zrender/src/container/Group'; import Circle from 'zrender/src/graphic/shape/Circle'; +import store from '@/store'; export default class CircularLamp extends Group { constructor(device) { @@ -8,6 +9,8 @@ export default class CircularLamp extends Group { this.event = device.event; this.zlevel = device.model.zlevel; this.z = device.model.z; + this.offsetX = 0; + this.offsetY = 0; this.create(); } @@ -40,15 +43,19 @@ export default class CircularLamp extends Group { this.on('mousemove', this.mousemove, this); this.on('mouseup', this.mouseup, this); } - mousedown() { + mousedown(e) { this.event.disable(); - console.log('鼠标按下'); + if (e.which == 3) { + store.dispatch('ibp/setUpdateDeviceData', this.model); + } + this.offsetX = e.offsetX; + this.offsetY = e.offsetY; } mousemove() { - console.log('鼠标移动'); } - mouseup() { + mouseup(e) { this.event.enable(); - console.log('鼠标抬起'); + this.model.point.x = this.model.point.x + (e.offsetX - this.offsetX); + this.model.point.y = this.model.point.y + (e.offsetY - this.offsetY); } } diff --git a/src/ibp/shape/factory.js b/src/ibp/shape/factory.js index 17f1d4fcf..ccc4d6e01 100644 --- a/src/ibp/shape/factory.js +++ b/src/ibp/shape/factory.js @@ -8,6 +8,7 @@ import IbpLine from './ibpLine'; import Button from './button'; import TipBox from './ibpTipBox'; import AppendageBox from './appendageBox'; +import RotatingButton from './rotatingButton'; const ibpShape = {}; ibpShape[deviceType.Arrow] = Arrow; @@ -19,6 +20,7 @@ ibpShape[deviceType.IbpLine] = IbpLine; ibpShape[deviceType.SquareButton] = Button; ibpShape[deviceType.TipBox] = TipBox; ibpShape[deviceType.AppendageBox] = AppendageBox; +ibpShape[deviceType.RotatingButton] = RotatingButton; function shapefactory(device, ibp) { const type = device.model._type; diff --git a/src/ibp/shape/ibpLine.js b/src/ibp/shape/ibpLine.js index 2857b0777..65f1cfbbc 100644 --- a/src/ibp/shape/ibpLine.js +++ b/src/ibp/shape/ibpLine.js @@ -1,5 +1,6 @@ import Group from 'zrender/src/container/Group'; import Line from 'zrender/src/graphic/shape/Line'; +import store from '@/store'; export default class ibpLine extends Group { constructor(device) { @@ -8,6 +9,8 @@ export default class ibpLine extends Group { this.event = device.event; this.zlevel = device.model.zlevel; this.z = device.model.z; + this.offsetX = 0; + this.offsetY = 0; this.create(); } create() { @@ -38,19 +41,21 @@ export default class ibpLine extends Group { this.on('mousemove', this.mousemove, this); this.on('mouseup', this.mouseup, this); } - mousedown() { + mousedown(e) { this.event.disable(); - console.log('鼠标按下'); + if (e.which == 3) { + store.dispatch('ibp/setUpdateDeviceData', this.model); + } + this.offsetX = e.offsetX; + this.offsetY = e.offsetY; } mousemove() { - console.log('鼠标移动'); } mouseup(e) { this.event.enable(); - this.model.point1.x = this.model.point1.x + e.offsetX; - this.model.point1.y = this.model.point1.y + e.offsetY; - this.model.point2.x = this.model.point2.x + e.offsetX; - this.model.point2.y = this.model.point2.y + e.offsetY; - console.log('鼠标抬起', this.model); + this.model.point1.x = this.model.point1.x - this.offsetX + e.offsetX; + this.model.point1.y = this.model.point1.y - this.offsetY + e.offsetY; + this.model.point2.x = this.model.point2.x - this.offsetX + e.offsetX; + this.model.point2.y = this.model.point2.y - this.offsetY + e.offsetY; } } diff --git a/src/ibp/shape/ibpText.js b/src/ibp/shape/ibpText.js index 385c3f7f0..d3cf8963a 100644 --- a/src/ibp/shape/ibpText.js +++ b/src/ibp/shape/ibpText.js @@ -1,5 +1,6 @@ import Group from 'zrender/src/container/Group'; import Text from 'zrender/src/graphic/Text'; +import store from '@/store'; export default class ibpText extends Group { constructor(device) { @@ -8,6 +9,8 @@ export default class ibpText extends Group { this.event = device.event; this.zlevel = device.model.zlevel; this.z = device.model.z; + this.offsetX = 0; + this.offsetY = 0; this.create(); } create() { @@ -18,8 +21,8 @@ export default class ibpText extends Group { silent: model.silent || false, draggable: model.draggable || false, style: { - x: model.x, - y: model.y, + x: model.point.x, + y: model.point.y, fontWeight: model.fontWeight, fontSize: model.fontSize, fontFamily: model.fontFamily, @@ -42,17 +45,20 @@ export default class ibpText extends Group { this.on('mousemove', this.mousemove, this); this.on('mouseup', this.mouseup, this); } - mousedown() { + mousedown(e) { this.event.disable(); - console.log('鼠标按下'); + if (e.which == 3) { + store.dispatch('ibp/setUpdateDeviceData', this.model); + } + this.offsetX = e.offsetX; + this.offsetY = e.offsetY; } mousemove() { - console.log('鼠标移动'); } mouseup(e) { this.event.enable(); - this.model.x = this.model.x + e.offsetX; - this.model.y = this.model.y + e.offsetY; - console.log('鼠标抬起', this.model); + console.log('test', e); + this.model.point.x = this.model.point.x + (e.offsetX - this.offsetX); + this.model.point.y = this.model.point.y + (e.offsetY - this.offsetY); } } diff --git a/src/ibp/shape/ibpTipBox.js b/src/ibp/shape/ibpTipBox.js index ab2fa177c..88dc16697 100644 --- a/src/ibp/shape/ibpTipBox.js +++ b/src/ibp/shape/ibpTipBox.js @@ -1,5 +1,6 @@ import Group from 'zrender/src/container/Group'; import Rect from 'zrender/src/graphic/shape/Rect'; +import store from '@/store'; export default class ibpTipBox extends Group { constructor(device) { @@ -8,6 +9,8 @@ export default class ibpTipBox extends Group { this.event = device.event; this.zlevel = device.model.zlevel; this.z = device.model.z; + this.offsetX = 0; + this.offsetY = 0; this.create(); } create() { @@ -37,17 +40,19 @@ export default class ibpTipBox extends Group { this.on('mousemove', this.mousemove, this); this.on('mouseup', this.mouseup, this); } - mousedown() { + mousedown(e) { this.event.disable(); - console.log('鼠标按下'); + if (e.which == 3) { + store.dispatch('ibp/setUpdateDeviceData', this.model); + } + this.offsetX = e.offsetX; + this.offsetY = e.offsetY; } mousemove() { - console.log('鼠标移动'); } mouseup(e) { this.event.enable(); - this.model.x = this.model.x + e.offsetX; - this.model.y = this.model.y + e.offsetY; - console.log('鼠标抬起', this.model); + this.model.point.x = this.model.point.x + (e.offsetX - this.offsetX); + this.model.point.y = this.model.point.y + (e.offsetY - this.offsetY); } } diff --git a/src/ibp/shape/rotateTip.js b/src/ibp/shape/rotateTip.js index 35694691d..19fe0000a 100644 --- a/src/ibp/shape/rotateTip.js +++ b/src/ibp/shape/rotateTip.js @@ -2,6 +2,7 @@ import Group from 'zrender/src/container/Group'; import Image from 'zrender/src/graphic/Image'; import rotateBlack from '@/assets/ibp_images/rotate_black.png'; import rotateRed from '@/assets/ibp_images/rotate_red.png'; +import store from '@/store'; export default class rotateTip extends Group { @@ -9,6 +10,9 @@ export default class rotateTip extends Group { super(); this.model = device.model; this.zlevel = device.model.zlevel; + this.event = device.event; + this.offsetX = 0; + this.offsetY = 0; this.create(); } @@ -35,7 +39,7 @@ export default class rotateTip extends Group { this.imageBg.scale =[this.model.width/70, this.model.width/70]; this.imageBg.dirty(); } - + getRotateColor() { if (this.model.color) { switch (this.model.color) { @@ -63,6 +67,11 @@ export default class rotateTip extends Group { mousedown(e) { this.event.disable(); + if (e.which == 3) { + store.dispatch('ibp/setUpdateDeviceData', this.model); + } + this.offsetX = e.offsetX; + this.offsetY = e.offsetY; } mousemove(e) { @@ -70,7 +79,7 @@ export default class rotateTip extends Group { mouseup(e) { this.event.enable(); - this.model.point.x = this.model.point.x + e.offsetX; - this.model.point.y = this.model.point.y + e.offsetY; + this.model.point.x = this.model.point.x + (e.offsetX - this.offsetX); + this.model.point.y = this.model.point.y + (e.offsetY - this.offsetY); } } diff --git a/src/ibp/shape/rotatingButton.js b/src/ibp/shape/rotatingButton.js index e69de29bb..922cef484 100644 --- a/src/ibp/shape/rotatingButton.js +++ b/src/ibp/shape/rotatingButton.js @@ -0,0 +1,58 @@ +import Group from 'zrender/src/container/Group'; +import Image from 'zrender/src/graphic/Image'; +import Keyhole from '@/assets/ibp_images/keyhole.png'; +import store from '@/store'; + +export default class RotatingButton extends Group { + constructor(device) { + super(); + this.model = device.model; + this.event = device.event; + this.zlevel = device.model.zlevel; + this.z = device.model.z; + this.offsetX = 0; + this.offsetY = 0; + this.create(); + } + + create() { + this.rotatingButton = new Image({ + zlevel: this.zlevel, + z: this.z, + draggable: false, + style: { + image: Keyhole, + x: this.model.point.x, + y: this.model.point.y, + width: this.model.width, + height: this.model.height + } + }); + this.add(this.rotatingButton); + } + + setDraggable() { + this.rotatingButton.attr('draggable', true); + this.createMouseEvent(); + } + createMouseEvent() { + this.on('mousedown', this.mousedown, this); + this.on('mousemove', this.mousemove, this); + this.on('mouseup', this.mouseup, this); + } + mousedown(e) { + this.event.disable(); + if (e.which == 3) { + store.dispatch('ibp/setUpdateDeviceData', this.model); + } + this.offsetX = e.offsetX; + this.offsetY = e.offsetY; + } + mousemove() { + } + mouseup(e) { + this.event.enable(); + this.model.point.x = this.model.point.x + (e.offsetX - this.offsetX); + this.model.point.y = this.model.point.y + (e.offsetY - this.offsetY); + } +} diff --git a/src/ibp/utils/parser.js b/src/ibp/utils/parser.js index 7f3aa3ee4..d325a11f4 100644 --- a/src/ibp/utils/parser.js +++ b/src/ibp/utils/parser.js @@ -2,6 +2,7 @@ import * as zrUtil from 'zrender/src/core/util'; import * as matrix from 'zrender/src/core/matrix'; import deviceType from '../constant/deviceType'; import deviceRender from '../constant/deviceRender'; +import store from '@/store'; export function createTransform(opts) { let transform = matrix.create(); @@ -76,3 +77,166 @@ export function parser(data, config) { return ibpDevice; } +export function updateIbpData(device) { + const ibpData = store.getters['ibp/ibp']; + switch (device._type) { + 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 { + return state.updateDeviceData; } }, @@ -37,6 +41,13 @@ const ibp = { }, setIbpData: (state, ibp) => { state.ibp = ibp; + }, + setUpdateDeviceData: (state, model) => { + state.rightClickCount++; + state.updateDeviceData = model; + }, + deleteIbpDevices: (state, devices) => { + Vue.prototype.$ibp && Vue.prototype.$ibp.render(devices); } }, @@ -52,8 +63,17 @@ const ibp = { commit('ibpRender', models); resolve(models); }); + }, + setUpdateDeviceData: ({ commit }, models) => { + commit('setUpdateDeviceData', models); + }, + deleteIbpDevices: ({ commit }, models ) => { + models = Object.assign(models, {dispose: true}); + if (!(models instanceof Array)) { + models = [models]; + } + commit('deleteIbpDevices', models); } - } }; diff --git a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpAlarm.vue b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpAlarm.vue index f18511237..5507e7f57 100644 --- a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpAlarm.vue +++ b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpAlarm.vue @@ -2,7 +2,7 @@
- + @@ -11,8 +11,8 @@ - 立即创建 - 取消 + {{ buttonText }} + 删除
@@ -25,6 +25,13 @@ }, data() { return { + isUpdate: false, + buttonText: '立即创建', + showDeleteButton: false, + point: { + x: 10, + y: 10 + }, form: { code: '', alarmWidth: '', @@ -47,25 +54,61 @@ }, watch: { - + '$store.state.ibp.rightClickCount': function (val) { + const model = this.$store.getters['ibp/updateDeviceData']; + if (model._type === 'Alarm' ){ + this.buttonText = '修改'; + this.showDeleteButton = true; + this.isUpdate = true; + this.form.code = model.code; + this.form.alarmWidth = model.width; + this.form.alarmHeight = model.height; + this.point = model.point; + } + } }, mounted() { }, methods: { onSubmit() { const alarmModel = { - zlevel: 1, + zlevel: 2, z: 1, - point: { - x: 10, - y: 10 - }, + point: this.point, code: this.form.code, _type: 'Alarm', width: this.form .alarmWidth, height: this.form.alarmHeight }; - this.$emit('createAlarm', alarmModel) + this.$emit('createAlarm', alarmModel); + this.initPage(); + }, + deleteDevice() { + const alarmModel = { + zlevel: 2, + z: 1, + point: this.point, + code: this.form.code, + _type: 'Alarm', + width: this.form .alarmWidth, + height: this.form.alarmHeight + }; + this.$emit('deleteDataModel',alarmModel ); + this.initPage(); + }, + initPage() { + this.isUpdate = false; + this.buttonText = '立即创建'; + this.showDeleteButton = false; + this.form = { + code: '', + alarmWidth: '', + alarmHeight: '' + }; + this.point = { + x: 10, + y: 10 + }; } } }; diff --git a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpAppendageBox.vue b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpAppendageBox.vue index 779db1442..c97e40097 100644 --- a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpAppendageBox.vue +++ b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpAppendageBox.vue @@ -2,7 +2,7 @@
- + @@ -11,8 +11,8 @@ - 立即创建 - 取消 + {{ buttonText }} + 删除
@@ -25,6 +25,13 @@ }, data() { return { + isUpdate: false, + buttonText: '立即创建', + showDeleteButton: false, + point: { + x: 10, + y: 10 + }, form: { appendageBoxWidth: '', appendageBoxHeight: '' @@ -46,25 +53,61 @@ }, watch: { - + '$store.state.ibp.rightClickCount': function (val) { + const model = this.$store.getters['ibp/updateDeviceData']; + if (model._type === 'AppendageBox' ){ + this.buttonText = '修改'; + this.showDeleteButton = true; + this.isUpdate = true; + this.form.code = model.code; + this.form.appendageBoxWidth = model.width; + this.form.appendageBoxHeight = model.height; + this.point = model.point; + } + } }, mounted() { }, methods: { onSubmit() { const appendageBoxModel = { - zlevel: 1, + zlevel: 2, z: 1, - point: { - x: 10, - y: 10 - }, + point: this.point, _type: 'AppendageBox', code: this.form.code, width: this.form .appendageBoxWidth, height: this.form.appendageBoxHeight }; - this.$emit('createAppendageBox', appendageBoxModel) + this.$emit('createAppendageBox', appendageBoxModel); + this.initPage(); + }, + deleteDevice() { + const appendageBoxModel = { + zlevel: 2, + z: 1, + point: this.point, + _type: 'AppendageBox', + code: this.form.code, + width: this.form .appendageBoxWidth, + height: this.form.appendageBoxHeight + }; + this.$emit('deleteDataModel',appendageBoxModel ); + this.initPage(); + }, + initPage() { + this.isUpdate = false; + this.buttonText = '立即创建'; + this.showDeleteButton = false; + this.form = { + code: '', + appendageBoxWidth: '', + appendageBoxHeight: '' + }; + this.point = { + x: 10, + y: 10 + }; } } }; diff --git a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpArrow.vue b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpArrow.vue index f5c131559..8c79c9325 100644 --- a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpArrow.vue +++ b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpArrow.vue @@ -2,7 +2,7 @@
- + @@ -22,8 +22,8 @@ - 立即创建 - 取消 + {{ buttonText }} + 删除
@@ -36,6 +36,13 @@ }, data() { return { + isUpdate: false, + buttonText: '立即创建', + showDeleteButton: false, + point: { + x: 10, + y: 10 + }, form: { code: '', orientation: '', @@ -66,19 +73,29 @@ }, watch: { - + '$store.state.ibp.rightClickCount': function (val) { + const model = this.$store.getters['ibp/updateDeviceData']; + if (model._type === 'Arrow' ){ + this.buttonText = '修改'; + this.showDeleteButton = true; + this.isUpdate = true; + this.form.code = model.code; + this.form.orientation = model.orientation; + this.form.arrowLength = model.length; + this.form.arrowWidth = model.width; + this.form.fillColor = model.fill; + this.point = model.point; + } + } }, mounted() { }, methods: { onSubmit() { const arrowModel = { - zlevel: 1, + zlevel: 2, z: 1, - point: { - x: 10, - y: 10 - }, + point: this.point, _type: 'Arrow', code: this.form.code, orientation: this.form.orientation, @@ -87,7 +104,40 @@ length: this.form.arrowLength, lineWidth: 1 }; - this.$emit('createArrow', arrowModel) + this.$emit('createArrow', arrowModel); + this.initPage(); + }, + deleteDevice() { + const arrowModel = { + zlevel: 2, + z: 1, + point: this.point, + _type: 'Arrow', + code: this.form.code, + orientation: this.form.orientation, + fill: this.form.fillColor, + width: this.form .arrowWidth, + length: this.form.arrowLength, + lineWidth: 1 + }; + this.$emit('deleteDataModel',arrowModel); + this.initPage(); + }, + initPage() { + this.isUpdate = false; + this.buttonText = '立即创建'; + this.showDeleteButton = false; + this.form = { + code: '', + orientation: '', + arrowWidth: '', + arrowLength: '', + fillColor: '' + }; + this.point = { + x: 10, + y: 10 + }; } } }; diff --git a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpBg.vue b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpBg.vue index e158b92ca..c83499770 100644 --- a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpBg.vue +++ b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpBg.vue @@ -57,6 +57,8 @@ height: this.form.bgHeight }; this.$emit('createBg', bgModel) + }, + initPage(){ } } }; diff --git a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpButton.vue b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpButton.vue index 188fcbcd8..16949992c 100644 --- a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpButton.vue +++ b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpButton.vue @@ -2,7 +2,7 @@
- + @@ -19,8 +19,8 @@ - 立即创建 - 取消 + {{ buttonText }} + 删除
@@ -33,7 +33,15 @@ }, data() { return { + isUpdate: false, + buttonText: '立即创建', + showDeleteButton: false, + point: { + x: 10, + y: 10 + }, form: { + code: '', buttonColor: '', buttonWidth: '', buttonHeight: '' @@ -58,19 +66,28 @@ }, watch: { - + '$store.state.ibp.rightClickCount': function (val) { + const model = this.$store.getters['ibp/updateDeviceData']; + if (model._type === 'SquareButton' ){ + this.buttonText = '修改'; + this.showDeleteButton = true; + this.isUpdate = true; + this.form.code = model.code; + this.form.buttonColor = model.color; + this.form.buttonWidth = model.width; + this.form.buttonHeight = model.height; + this.point = model.point; + } + } }, mounted() { }, methods: { onSubmit() { const buttonModel = { - zlevel: 1, + zlevel: 2, z: 1, - point: { - x: 10, - y: 10, - }, + point: this.point, _type: 'SquareButton', code: this.form.code, color: this.form.buttonColor, @@ -78,7 +95,38 @@ width: this.form.buttonWidth, height: this.form.buttonHeight }; - this.$emit('createButton', buttonModel) + this.$emit('createButton', buttonModel); + this.initPage(); + }, + deleteDevice() { + const buttonModel = { + zlevel: 2, + z: 1, + point: this.point, + _type: 'SquareButton', + code: this.form.code, + color: this.form.buttonColor, + status: 'off', + width: this.form.buttonWidth, + height: this.form.buttonHeight + }; + this.$emit('deleteDataModel',buttonModel ); + this.initPage(); + }, + initPage() { + this.isUpdate = false; + this.buttonText = '立即创建'; + this.showDeleteButton = false; + this.form = { + code: '', + buttonColor: '', + buttonWidth: '', + buttonHeight: '' + }; + this.point = { + x: 10, + y: 10 + }; } } }; diff --git a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpLamp.vue b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpLamp.vue index 7de6f55d9..f3c772c7c 100644 --- a/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpLamp.vue +++ b/src/views/ibp/ibpDraft/ibpEdit/ibpOperate/ibpLamp.vue @@ -1,15 +1,15 @@