From e6fad0d514c5b15e795d0234935209b8dac36eb2 Mon Sep 17 00:00:00 2001 From: cxx Date: Thu, 9 May 2024 10:31:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E8=A1=A8=E5=8D=95=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/tpl/formItemListGenerator.html | 35 +++++++++++++++++-- app/view/component/tpl/tplFormDesign.html | 7 ++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/app/view/component/tpl/formItemListGenerator.html b/app/view/component/tpl/formItemListGenerator.html index 575d3d7..95f9e45 100644 --- a/app/view/component/tpl/formItemListGenerator.html +++ b/app/view/component/tpl/formItemListGenerator.html @@ -64,7 +64,7 @@ mdi-content-copy复制 + @click.stop="doUiAction('formItemDelete', formItem)"> mdi-delete-outline删除 @@ -166,6 +166,11 @@ Vue.component("form-item-list-generator", { default: [], required: true, }, + workflow: { + type: Object, + default: {}, + required: true, + }, }, data: () => ({ componentList: [ @@ -199,6 +204,17 @@ Vue.component("form-item-list-generator", { async created() { }, methods: { + async doUiAction(uiActionId, uiActionData) { + switch (uiActionId) { + case 'formItemDelete': + await this.confirmFormItemDeleteDialog(uiActionData); + await this.formItemDelete(uiActionData); + break; + default: + console.error("[doUiAction] uiActionId not find", {uiActionId}); + break; + } + }, cloneComponent(component) { this.tempComponent = component; }, @@ -235,7 +251,22 @@ Vue.component("form-item-list-generator", { emptyCanva() { this.formItemList.splice(0, this.formItemList.length); }, - formItemDelete(id) { + async confirmFormItemDeleteDialog({id}) { + const { nodeList } = this.workflow + var hasItem = false + + hasItem = nodeList.some(node => { + const conditionList = node.properties.conditionList; + return _.some(conditionList, c => c.id === id); // 使用lodash的some方法 + }); + + if(hasItem){ + await window.vtoast.fail('流程设置存在条件节点使用该题目!') + throw new Error("[confirmFormItemDeleteDialog] 流程设置存在条件节点使用该题目!"); + } + + }, + formItemDelete({id}) { const index = this.formItemList.findIndex((item) => item.id === id); if (index > -1) { this.formItemList.splice(index, 1); diff --git a/app/view/component/tpl/tplFormDesign.html b/app/view/component/tpl/tplFormDesign.html index fa5c697..629189c 100644 --- a/app/view/component/tpl/tplFormDesign.html +++ b/app/view/component/tpl/tplFormDesign.html @@ -3,6 +3,7 @@
@@ -18,6 +19,12 @@ default: () => { return [] } + }, + workflow: { + type: Object, + default: () => { + return {} + } } }, data: () => ({