From 9b01aada152a4bf33656a53be4cb5447d17f9c99 Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Tue, 13 Apr 2021 10:56:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=BE=E7=BD=AEshape?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/iscs_new/factory/compose.js | 25 ++++++++++--------------- src/iscs_new/factory/element.js | 10 +++++----- src/iscs_new/factory/index.js | 4 ++-- src/iscs_new/map.js | 6 ++---- src/iscs_new/painter.js | 3 ++- src/views/iscs_new/iscsDesign/index.vue | 8 ++++++-- src/views/iscs_new/iscsDraw/index.vue | 10 +++++++--- 7 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/iscs_new/factory/compose.js b/src/iscs_new/factory/compose.js index 2171b9765..c56b1477c 100644 --- a/src/iscs_new/factory/compose.js +++ b/src/iscs_new/factory/compose.js @@ -75,14 +75,12 @@ class Compose extends AbstractShape { this.shapeFactory.hideHightLight(this); this.model.elementCodes.forEach(code => { const el = this.shapeFactory.getShapeByCode(code); - if (el) { + if (el && el.model) { this.shapeFactory.hideHightLight(el); - if (el.model) { - this.shapeFactory.removeFromLayer(el.type, el); - this.instance.add(el); - el.model.composeCode = this.code; - el.attr(el.model); - } + this.shapeFactory.removeFromLayer(el.type, el); + this.instance.add(el); + el.model.composeCode = this.code; + el.attr(el.model); } }) } @@ -93,15 +91,12 @@ class Compose extends AbstractShape { this.shapeFactory.hideHightLight(this); this.model.elementCodes.forEach(code => { const el = this.shapeFactory.getShapeByCode(code); - if (el) { + if (el && el.model) { this.shapeFactory.hideHightLight(el); - if (el.model && - el.model.composeCode) { - this.instance.remove(el); - this.shapeFactory.addToLayer(el.type, el); - el.model.composeCode = ''; - el.attr(el.model); - } + this.instance.remove(el); + this.shapeFactory.addToLayer(el.type, el); + el.model.composeCode = ''; + el.attr(el.model); } }) this.model.elementCodes = []; diff --git a/src/iscs_new/factory/element.js b/src/iscs_new/factory/element.js index acad5f5d5..0dbc8d265 100644 --- a/src/iscs_new/factory/element.js +++ b/src/iscs_new/factory/element.js @@ -77,10 +77,10 @@ class Element extends AbstractShape { compose.model && compose.model.elementCodes) { this.shapeFactory.hideHightLight(compose); - const index = compose.model.elementCodes.findIndex(this.type); + const index = compose.model.elementCodes.findIndex(this.code); if (index < 0) { - compose.model.elementCodes.push(this.type); - this.shapeFactory.removeFormLayer(el.type, this); + compose.model.elementCodes.push(this.code); + this.shapeFactory.removeFormLayer(this.type, this); compose.instance.add(this); compose.attr(compose.model); } @@ -96,12 +96,12 @@ class Element extends AbstractShape { compose.model && compose.model.elementCodes) { this.shapeFactory.hideHightLight(compose); - const index = compose.model.elementCodes.findIndex(this.type); + const index = compose.model.elementCodes.findIndex(this.code); if (index >= 0) { compose.model.elementCodes.splice(index, 1); compose.instance.remove(this); compose.attr(compose.model); - this.shapeFactory.addToLayer(el.type, this); + this.shapeFactory.addToLayer(this.type, this); } } } diff --git a/src/iscs_new/factory/index.js b/src/iscs_new/factory/index.js index 165e8cd52..ccddf3a2e 100644 --- a/src/iscs_new/factory/index.js +++ b/src/iscs_new/factory/index.js @@ -132,7 +132,6 @@ class ShapeFactory extends Eventful { addShape(shape) { if (shape && shape.code) { - this.hideHightLight(shape); this.mapShape[shape.code] = shape; shape.combine(); } @@ -141,7 +140,6 @@ class ShapeFactory extends Eventful { removeShape(shape) { if (shape && shape.code) { - this.hideHightLight(shape); shape.uncouple(); delete this.mapShape[shape.code]; } @@ -158,6 +156,7 @@ class ShapeFactory extends Eventful { showHightLight(shape) { const target = this.$controller.getTarget(); + if (shape.instanceHightLight) { shape.instanceHightLight.setShape(shape.getBoundingRect()) this.$painter.addToLayer(shapeLayer.HightLight, shape.instanceHightLight); @@ -176,6 +175,7 @@ class ShapeFactory extends Eventful { hideHightLight(shape) { const target = this.$controller.getTarget(); + if (shape.instanceHightLight) { this.$painter.removeFromLayer(shapeLayer.HightLight, shape.instanceHightLight); } diff --git a/src/iscs_new/map.js b/src/iscs_new/map.js index 11174a8d7..57e45977e 100644 --- a/src/iscs_new/map.js +++ b/src/iscs_new/map.js @@ -165,6 +165,7 @@ class JMap { let newShape = null; if (updateModel) { + this.$controller.clear(); switch(action.order) { case orders.Binding: case orders.Add: @@ -179,22 +180,19 @@ class JMap { if (updateModel) { curShape = this.$shapeFactory.getShapeByCode(updateModel.code); oldShape = this.$shapeFactory.removeShape(curShape); - this.$painter.removeFromLayer(oldShape.type, oldShape.instanceHightLight); this.$painter.remove(oldShape); } }); break; case orders.Update: oldShape = this.$shapeFactory.removeShape(curShape); + this.$painter.remove(oldShape); newShape = this.$shapeFactory.createShape(updateModel, action.shapeType); this.$shapeFactory.addShape(newShape) - this.$painter.removeFromLayer(oldShape.type, oldShape.instanceHightLight); - this.$painter.remove(oldShape); this.$painter.add(newShape); break; case orders.Unbinding: oldShape = this.$shapeFactory.removeShape(curShape); - this.$painter.removeFromLayer(oldShape.type, oldShape.instanceHightLight); this.$painter.remove(oldShape); this.$shapeFactory.addShape(oldShape); this.$painter.add(oldShape); diff --git a/src/iscs_new/painter.js b/src/iscs_new/painter.js index efa2066d0..1d6d0858d 100644 --- a/src/iscs_new/painter.js +++ b/src/iscs_new/painter.js @@ -60,11 +60,12 @@ class Painter extends Group { } add(shape) { + shape && this.removeFromLayer(shapeLayer.HightLight, shape.instanceHightLight); shape && this.addToLayer(shape.type, shape); - } remove(shape) { + shape && this.removeFromLayer(shapeLayer.HightLight, shape.instanceHightLight); shape && this.removeFromLayer(shape.type, shape); } diff --git a/src/views/iscs_new/iscsDesign/index.vue b/src/views/iscs_new/iscsDesign/index.vue index 3349a71dd..15e44881b 100644 --- a/src/views/iscs_new/iscsDesign/index.vue +++ b/src/views/iscs_new/iscsDesign/index.vue @@ -186,10 +186,14 @@ export default { }, getComposeElemList() { const source = this.$iscs.getSource(); - if (source.elementList) { + if (source && + source.elementList && + source.elementList.length) { this.composeElemList = source.elementList; this.statusTab = this.composeElemList[0].code; - } + } else { + this.composeElemList = []; + } } } diff --git a/src/views/iscs_new/iscsDraw/index.vue b/src/views/iscs_new/iscsDraw/index.vue index d336a54d9..33e1cc80f 100644 --- a/src/views/iscs_new/iscsDraw/index.vue +++ b/src/views/iscs_new/iscsDraw/index.vue @@ -194,15 +194,19 @@ export default { }, getComposeElemList() { const source = this.$iscs.getSource(); - if (source.elementList && source.elementLis.length > 0) { + if (source && + source.elementList && + source.elementList.length) { this.composeElemList = source.elementList; this.statusTab = this.composeElemList[0].code; - } + } else { + this.composeElemList = []; + } }, onSaveStatus() { this.$refs['tableform' + this.statusTab][0].$refs['form'].validate((valid) => { if (valid) { - const model = utils.deepClone(this.$refs['tableform' + this.statusTab][0].formModel); + const model = utils.deepClone(this.$refs['tableform' + this.statusTab][0].formModel); model.stateList.map(state=>{ delete state.defaultStyleSelect; delete state.defaultShapeSelect; }); this.$refs.iscsCanvas.doAction([{model, action: {shapeType: shapeType.Element, order: orders.Update}}]); this.onSave();