From 1985b51f98ad354fdbb69b6bcf3f1da8de330a8a Mon Sep 17 00:00:00 2001 From: ival <610568032@qq.com> Date: Fri, 9 Apr 2021 18:33:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=8D=E5=88=B6=E7=B2=98?= =?UTF-8?q?=E8=B4=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/shapeContextMenu/entry.vue | 55 ++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) 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; + } } } };