diff --git a/src/iscs_new/plugins/shapeContextMenu/entry.vue b/src/iscs_new/plugins/shapeContextMenu/entry.vue index 6f461df6b..4ea71b255 100644 --- a/src/iscs_new/plugins/shapeContextMenu/entry.vue +++ b/src/iscs_new/plugins/shapeContextMenu/entry.vue @@ -38,7 +38,7 @@ export default { }, { label: '解组', - handler: this.unBinding, + handler: this.doUnBinding, disabledCb: e => { return this.selected.shapeType != shapeType.Compose; } @@ -50,6 +50,14 @@ export default { const storage = this.$iscs.getController().getStorage(); return !storage.values().length; } + }, + { + label: '删除', + handler: this.doDelete, + disabledCb: e => { + const storage = this.$iscs.getController().getStorage(); + return !storage.values().length; + } } ], None: [ @@ -105,7 +113,7 @@ export default { this.$message.info('请选择两个及其以上数目元素'); } }, - unBinding(el) { + doUnBinding(el) { console.log(this.selected); if (this.selected) { this.$iscs.render([ @@ -117,8 +125,51 @@ export default { } }, doCopy(el) { + const storage = this.$iscs.getController().getStorage(); + this.clipboardList = [...storage.values()]; }, 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; + } } } };