修改代码

This commit is contained in:
ival 2021-04-09 17:48:42 +08:00
parent 5f62a24f08
commit 18a51e7c26

View File

@ -98,24 +98,28 @@ export default {
},
onSave() {
const id = this.$route.query.id;
const name = this.$route.query.name || '<模型名称>';
const type = this.$route.query.type || '<模型类型>';
const source = this.$iscs.getSource();
if (id && source) {
const elementList = source.elementList.map(el => {
return this.$iscs.getShapeByCode(el.code);
});
const shapeList = elementList.map(el => el.model);
const rect = elementList.reduce(
(temp, el) => el && temp ? temp.union(el.getBoundingRect().clone()) : el.getBoundingRect(), null);
const position = rect ? [(rect.x + rect.width) / 2, (rect.y + rect.height) / 2] : [0, 0];
const model = { id, name, type, shapeList, position };
Idb.delete('composeList', model.id);
Idb.write('composeList', model);
Idb.list('composeList').then(list => {
console.log(list);
});
}
const name = this.$route.query.name||"<模型名称>";
const type = this.$route.query.type||"<模型类型>";
const source = this.$iscs.getSource();
if (id && source) {
const elementList = source.elementList.map(el => {
return this.$iscs.getShapeByCode(el.code).model;
});
const composeList = source.composeList.map(el => {
return this.$iscs.getShapeByCode(el.code).model;
});
const rect = elementList.reduce((temp,el) => {
const shape = this.$iscs.getShapeByCode(el.code);
return shape&&temp? temp.union(shape.getBoundingRect().clone()): shape.getBoundingRect()
}, null);
const position = rect? [(rect.x + rect.width)/2, (rect.y + rect.height)/2]: [0,0];
const model = { id, name, type, elementList, composeList, position };
Idb.delete('composeList', model.id);
Idb.write('composeList', model);
Idb.list('composeList').then(list => {
console.log(list)
})
}
},
onSelectTab() {
this.selected = null;