修改代码

This commit is contained in:
ival 2021-04-09 14:37:43 +08:00
parent aab9cb8bed
commit f78fa04842
6 changed files with 15 additions and 8 deletions

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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:

View File

@ -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;

View File

@ -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={}) {

View File

@ -93,7 +93,7 @@ export default {
},
plugins: [
ShapeBuilder,
ShapeProperty
// ShapeProperty
]
});