修改代码
This commit is contained in:
parent
5f62a24f08
commit
18a51e7c26
@ -98,23 +98,27 @@ export default {
|
||||
},
|
||||
onSave() {
|
||||
const id = this.$route.query.id;
|
||||
const name = this.$route.query.name || '<模型名称>';
|
||||
const type = this.$route.query.type || '<模型类型>';
|
||||
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);
|
||||
return this.$iscs.getShapeByCode(el.code).model;
|
||||
});
|
||||
const shapeList = elementList.map(el => el.model);
|
||||
const rect = elementList.reduce(
|
||||
(temp, el) => el && temp ? temp.union(el.getBoundingRect().clone()) : el.getBoundingRect(), null);
|
||||
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, shapeList, position };
|
||||
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);
|
||||
});
|
||||
console.log(list)
|
||||
})
|
||||
}
|
||||
},
|
||||
onSelectTab() {
|
||||
|
Loading…
Reference in New Issue
Block a user