From ebd2c2f5e4ad73ec128566d7690f2236b4c6ed7e Mon Sep 17 00:00:00 2001 From: liwenxuan <1298531568@qq.com> Date: Thu, 20 Feb 2025 16:53:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E8=81=94=E8=A1=A8=E5=8D=95=E4=B8=8D?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E8=83=BD=E9=80=89=E6=8B=A9=E6=9C=AC=E8=A1=A8?= =?UTF-8?q?=E5=8F=8A=E6=9C=AC=E8=A1=A8=E4=B9=8B=E4=B8=8B=E7=9A=84=E5=AD=90?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DesignForm/formControlPropertiNew.vue | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/components/DesignForm/formControlPropertiNew.vue b/src/components/DesignForm/formControlPropertiNew.vue index f8a6585..ca7851c 100644 --- a/src/components/DesignForm/formControlPropertiNew.vue +++ b/src/components/DesignForm/formControlPropertiNew.vue @@ -2577,10 +2577,39 @@ function getAssociatedFormsCurrentFieldTree1() { } }); } +function removeTreeNode(tree: any, targetId: any) { + // 深拷贝原始树结构避免污染原数据 + const clonedTree = JSON.parse(JSON.stringify(tree)); + + // 递归处理节点 + function processNode(node) { + // 命中目标节点时返回null进行过滤 + if (node.id === targetId) return null; + + // 递归处理子节点并过滤空值 + if (node.children?.length) { + node.children = node.children + .map(child => processNode(child)) + .filter(Boolean); + } + + return node; + } + + // 处理单根或多根树结构 + const result = Array.isArray(clonedTree) + ? clonedTree.map(node => processNode(node)).filter(Boolean) + : processNode(clonedTree); + + return result || null; +} const customerFormTree = ref(); getCustomerFormList().then(({ data }) => { - let resData = ref(data.children); + /* console.log(data.children) + console.log(props.customerformid) */ + let datachildrenWithoutSelf = removeTreeNode(data.children,props.customerformid) + let resData = ref(datachildrenWithoutSelf); customerFormTree.value = [ { id: data.id,