This commit is contained in:
joylink_cuiweidong 2021-04-09 18:36:25 +08:00
commit 45f9b1d9e2

View File

@ -38,7 +38,7 @@ export default {
}, },
{ {
label: '解组', label: '解组',
handler: this.unBinding, handler: this.doUnBinding,
disabledCb: e => { disabledCb: e => {
return this.selected.shapeType != shapeType.Compose; return this.selected.shapeType != shapeType.Compose;
} }
@ -50,6 +50,14 @@ export default {
const storage = this.$iscs.getController().getStorage(); const storage = this.$iscs.getController().getStorage();
return !storage.values().length; return !storage.values().length;
} }
},
{
label: '删除',
handler: this.doDelete,
disabledCb: e => {
const storage = this.$iscs.getController().getStorage();
return !storage.values().length;
}
} }
], ],
None: [ None: [
@ -105,7 +113,7 @@ export default {
this.$message.info('请选择两个及其以上数目元素'); this.$message.info('请选择两个及其以上数目元素');
} }
}, },
unBinding(el) { doUnBinding(el) {
console.log(this.selected); console.log(this.selected);
if (this.selected) { if (this.selected) {
this.$iscs.render([ this.$iscs.render([
@ -117,8 +125,51 @@ export default {
} }
}, },
doCopy(el) { doCopy(el) {
const storage = this.$iscs.getController().getStorage();
this.clipboardList = [...storage.values()];
}, },
doParse(el) { doParse(el) {
const renderList = [];
this.clipboardList.forEach(el => {
this.clone(el, utils.getUID(el.type), '', el => {
renderList.push({
model: utils.deepClone(el.model),
action: { order: orders.Add, shapeType: el.shapeType}
});
});
})
console.log(renderList);
this.$iscs.render(renderList);
},
doDelete(el) {
const storage = this.$iscs.getController().getStorage();
const renderList = storage.values().map(el => {
return {
model: el.model,
action: { order: orders.Delete, shapeType: el.shapeType }
}
});
this.$iscs.render(renderList);
},
clone(el, code='', composeCode='', cb) {
let model = utils.deepClone(el.model);
model.code = code;
model.composeCode = composeCode;
switch(el.shapeType) {
case shapeType.Element:
cb(el)
break;
case shapeType.Compose:
model.elementCodes = model.elementCodes.map(code => {
const shape = this.$iscs.getShapeByCode(code);
const tmpCode = utils.getUID(shape.type)
this.clone(shape, tmpCode, model.code, cb);
return tmpCode;
})
cb(el)
break;
}
} }
} }
}; };