From ddd20a11268c53d804e87c9ed2bde5afaf6144af Mon Sep 17 00:00:00 2001 From: liwenxuan <1298531568@qq.com> Date: Thu, 15 Jan 2026 14:28:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=9F=A9=E9=98=B5=E5=A1=AB?= =?UTF-8?q?=E5=85=85bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DesignForm/formControlPropertiNew.vue | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/components/DesignForm/formControlPropertiNew.vue b/src/components/DesignForm/formControlPropertiNew.vue index 04be234..a311287 100644 --- a/src/components/DesignForm/formControlPropertiNew.vue +++ b/src/components/DesignForm/formControlPropertiNew.vue @@ -2941,16 +2941,35 @@ const currentComponentOptions = computed(() => { return controlData.value.options }) -// 获取当前选择的索引列节点(用于获取label) -const currentIndexColumnNode = computed(() => { - if (!controlData.value?.control?.zdtcsz?.tby) return null - return zdtcszTree.value.find(item => item.id == controlData.value.control.zdtcsz.tby) -}) +// 递归查找树节点 +const findTreeNode = (tree, id) => { + if (!tree || !Array.isArray(tree)) return null + + for (let node of tree) { + if (node.id === id) { + return node + } + + // 如果有子节点,递归查找 + if (node.children && node.children.length > 0) { + const found = findTreeNode(node.children, id) + if (found) return found + } + } + + return null +} // 获取当前选择的标题行节点(用于获取label) const currentTitleColumnNode = computed(() => { if (!controlData.value?.control?.zdtcsz?.tbx) return null - return zdtcszTree.value.find(item => item.id == controlData.value.control.zdtcsz.tbx) + return findTreeNode(zdtcszTree.value, controlData.value.control.zdtcsz.tbx) +}) + +// 获取当前选择的索引列节点(用于获取label) +const currentIndexColumnNode = computed(() => { + if (!controlData.value?.control?.zdtcsz?.tby) return null + return findTreeNode(zdtcszTree.value, controlData.value.control.zdtcsz.tby) }) // 索引列的标签 @@ -2989,8 +3008,10 @@ const zdtcszTableColumns = computed(() => { // 监听标题行和索引列的变化,重新生成表格数据 watch([titleOptions, indexOptions], ([newTitleOptions, newIndexOptions]) => { + // 如果都没有选择,清空表格数据 if (!newTitleOptions.length && !newIndexOptions.length) { + console.log("如果都没有选择,清空表格数据") zdtcszTableData.value = [] return }