数据结构
data: [
{
label: '广东',
id:12,
children: [{
label: '广州',
id:121,
children: [
{label: '天河',id:1213},
{label: '越秀',id:1215},
{label: '南山',id:1216},
{label: '番禺',id:1217},
]
},
{
label: '佛山',
id:122,
children: [
{label: '南海',id:1223},
{label: '禅城',id:1225},
{label: '顺德',id:1226},
{label: '狮山',id:1227},
]
},
{
label: '深圳',
id:123,
children: [
{label: '南山',id:1233},
{label: '布吉',id:1235},
{label: '罗湖',id:1236},
{label: '坪山',
id:1237,
children: [
{label: '南山',id:12331},
{label: '布吉',id:12352},
{label: '罗湖',id:12363},
{label: '坪山',id:12374}]
},
]
},
]
},
{
label: '福建',
id:22,
children: [{
label: '福州',
id:221,
children: [
{label: '天河',id:2213},
{label: '越秀',id:2215},
{label: '南山',id:2216},
{label: '番禺',id:2217},
]
},
{
label: '厦门',
id:122,
children: [
{label: '南海',id:2223},
{label: '禅城',id:2225},
{label: '顺德',id:2226},
{label: '狮山',id:2227},
]
},
{
label: '泉州',
id:123,
children: [
{label: '南山',id:2233},
{label: '布吉',id:2235},
{label: '罗湖',id:2236},
{label: '坪山',id:2237},
]
},
]
},
方法
init(list){
list.forEach(item =>{
item.show = false
this.arr.push(item.id)
if (item.children) {
this.init(item.children)
}
})
console.log(new Set(this.arr))
},
diguiclick(){
this.init(this.data)
},
// 递归获取树节点id数组
inits(list){
this.selectArr = []
this.selectArr.push(list.id)
if (list.children) {
this.inits(list.children[0])
}
// })
console.log(new Set(this.selectArr))
},
// 获取搜索条件
init(){
this.inits(this.currentNode)
getAdvancedSearchCondition(this.selectArr).then(res =>{
console.log(res)
this.datas = res
})
},