修改复制粘贴的问题

This commit is contained in:
ival 2021-04-09 18:33:27 +08:00
parent fce6f58eb0
commit 1985b51f98

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