From f78fa048422ed30fa033935b59c6f9559ccd9c8b Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Fri, 9 Apr 2021 14:37:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/iscs_new/core/abstractShape.js | 6 +++++- src/iscs_new/factory/element.js | 2 ++ src/iscs_new/factory/index.js | 2 +- src/views/iscs_new/iscsDraw/index.vue | 8 ++++---- src/views/iscs_new/iscsDraw/iscsCanvas.vue | 3 ++- src/views/test/index.vue | 2 +- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/iscs_new/core/abstractShape.js b/src/iscs_new/core/abstractShape.js index 8721b09e0..113b7b69e 100644 --- a/src/iscs_new/core/abstractShape.js +++ b/src/iscs_new/core/abstractShape.js @@ -42,12 +42,16 @@ class AbstractShape extends Group { drift({dx, dy}) { this.model.base.position[0] = this.model.base.position[0] + dx; this.model.base.position[1] = this.model.base.position[1] + dy; + this.instance.scale = this.model.base.scale; + this.instance.position = this.model.base.position; + this.instance.rotation = this.model.base.rotation*Math.PI/180; this.instance.origin = utils.createOrigin(this.instance); + console.log(this.model.base.position, this.model.base.rotation); this.instance.transform = utils.createTransform({scale: this.model.base.scale, position: this.model.base.position, rotation: this.model.base.rotation*Math.PI/180}); this.setInvisible(this.model.base.hide) } - // 修改属性 + // 修改状态 attr(attrs) { if (this.instance) { this.instance.attr(attrs); diff --git a/src/iscs_new/factory/element.js b/src/iscs_new/factory/element.js index f82c95eeb..bc10b0bd0 100644 --- a/src/iscs_new/factory/element.js +++ b/src/iscs_new/factory/element.js @@ -82,6 +82,7 @@ class Element extends AbstractShape { compose.model.elementCodes.push(this.type); this.shapeFactory.removeFormLayer(el.type, this); compose.instance.add(this); + compose.attr(compose.model); } } } @@ -99,6 +100,7 @@ class Element extends AbstractShape { if (index >= 0) { compose.model.elementCodes.splice(index, 1); compose.instance.remove(this); + compose.attr(compose.model); this.shapeFactory.addToLayer(el.type)(this); } } diff --git a/src/iscs_new/factory/index.js b/src/iscs_new/factory/index.js index 22a3201b0..6e865a63e 100644 --- a/src/iscs_new/factory/index.js +++ b/src/iscs_new/factory/index.js @@ -246,7 +246,7 @@ function update2List(source, model, action, name='') { switch(action.order) { case orders.Binding: case orders.Add: - list.push(model); + i < 0 && list.push(model); break; case orders.Unbinding: case orders.Delete: diff --git a/src/views/iscs_new/iscsDraw/index.vue b/src/views/iscs_new/iscsDraw/index.vue index a4087caa6..67d7b75ee 100644 --- a/src/views/iscs_new/iscsDraw/index.vue +++ b/src/views/iscs_new/iscsDraw/index.vue @@ -105,7 +105,7 @@ export default { }, onSelected(em) { if (em.model) { - this.selected = JSON.parse(JSON.stringify(em.model)); + this.selected = utils.deepClone(em.model); const elem = this.elementList.find(el => el.code == this.selected.type); if (elem) { elem.model = this.selected; @@ -119,7 +119,7 @@ export default { this.$refs['dataform'+this.enabledTab][0].$refs['form'].validate((valid) => { if (valid) { const formModel = this.$refs['dataform' + this.enabledTab][0].formModel; - const newModel = JSON.parse(JSON.stringify(formModel)); + const newModel = utils.deepClone(formModel); newModel.code = utils.getUID(this.enabledTab); newModel.type = this.enabledTab; newModel.name = '<名称>'; @@ -132,7 +132,7 @@ export default { onModify() { this.$refs['dataform' + this.enabledTab][0].$refs['form'].validate((valid) => { if (valid) { - const model = this.$refs['dataform' + this.enabledTab][0].formModel; + const model = utils.deepClone(this.$refs['dataform' + this.enabledTab][0].formModel); model.code = this.selected.code; model.type = this.selected.type; model.name = this.selected.name; @@ -144,7 +144,7 @@ export default { onDelete() { this.$refs['dataform' + this.enabledTab][0].$refs['form'].validate((valid) => { if (valid) { - const model = this.$refs['dataform' + this.enabledTab][0].formModel; + const model = utils.deepClone(this.$refs['dataform' + this.enabledTab][0].formModel); model.code = this.selected.code; model.type = this.selected.type; model.name = this.selected.name; diff --git a/src/views/iscs_new/iscsDraw/iscsCanvas.vue b/src/views/iscs_new/iscsDraw/iscsCanvas.vue index 55e3de03b..34bd551e9 100644 --- a/src/views/iscs_new/iscsDraw/iscsCanvas.vue +++ b/src/views/iscs_new/iscsDraw/iscsCanvas.vue @@ -81,7 +81,7 @@ export default { offsetY: 0 }, plugins: [ - ShapeBuilder, + // ShapeBuilder, // ShapeProperty ] }); @@ -135,6 +135,7 @@ export default { }, // 点击选择事件 onClick(em={}) { + console.log(em); this.$emit('selected', em); }, onReflect(em={}) { diff --git a/src/views/test/index.vue b/src/views/test/index.vue index 09f3492e6..f1e225046 100644 --- a/src/views/test/index.vue +++ b/src/views/test/index.vue @@ -93,7 +93,7 @@ export default { }, plugins: [ ShapeBuilder, - ShapeProperty + // ShapeProperty ] });