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 + }, /** * 树节点查询 */