[update] 企标左侧树新增完左侧树展开
This commit is contained in:
@@ -338,7 +338,18 @@ export default {
|
||||
this.filters.nodeCode = null
|
||||
if (res.success) {
|
||||
this.treeData = res.result || []
|
||||
this.expandedKeys = [this.treeData[0].key]
|
||||
// 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.treeData = []
|
||||
}
|
||||
@@ -349,6 +360,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
|
||||
},
|
||||
// 左侧树搜索
|
||||
handleTreeSearch () {
|
||||
this.treeData = []
|
||||
|
||||
Reference in New Issue
Block a user