From 6a6ce2db9ce48e93613367ba79d455a92b8b4290 Mon Sep 17 00:00:00 2001 From: lideqin <694785430@qq.com> Date: Thu, 20 Jun 2024 10:34:02 +0800 Subject: [PATCH] =?UTF-8?q?[update]=20=E5=A4=96=E6=9D=A5=E6=A0=87=E5=87=86?= =?UTF-8?q?=E6=B3=95=E8=A7=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../foreignStandard/ForeignStandardList.vue | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/views/standardRegulationLibrary/foreignStandard/ForeignStandardList.vue b/src/views/standardRegulationLibrary/foreignStandard/ForeignStandardList.vue index f1e0998..a2e4d3d 100644 --- a/src/views/standardRegulationLibrary/foreignStandard/ForeignStandardList.vue +++ b/src/views/standardRegulationLibrary/foreignStandard/ForeignStandardList.vue @@ -341,8 +341,17 @@ export default { this.filters.nodeCode = null if (res.success) { this.treeData = res.result || [] - // 根节点默认展开 - this.expandedKeys = [this.treeData[0].key] + if (this.expandedKeys.length <= 0) { + // 根节点默认展开 + this.expandedKeys = [this.treeData[0].key] + } else { + const treeDataList = this.getTreeDataList(this.treeData) + const treeDataListKeys = treeDataList.map(item => item.key) + // 不是叶子结点的结点 + const notLeafKeys = treeDataList.filter(item => !item.leaf).map(item => item.key) + // 还存在的树节点并且还有子节点的展开节点依然展开 + this.expandedKeys = this.expandedKeys.filter(item => treeDataListKeys.includes(item) && notLeafKeys.includes(item)) + } } else { this.$message.warn(res.message) } @@ -350,6 +359,17 @@ export default { this.treeLoading = false }) }, + getTreeDataList (treeData) { + let treeDataList = [] + for (const item of treeData) { + treeDataList.push(item) + if (item.children && item.children.length > 0) { + const list = this.getTreeDataList(item.children) + treeDataList = treeDataList.concat(list) + } + } + return treeDataList + }, /** * 树节点查询 */