<el-tree
ref="tree"
hghlight-currenti
node-key="ID"
lazy
:load="loadNode"
:data="treeData"
:props="defaultProps"
/>
data() {
return {
treeData: [{ ID: 1, CODE: 'AAA', children: [] }, { ID: 2, CODE: 'BBB', children: [] }],
// leftTreeDevices: [],
telChildren: [{ ID: 1020200001, CODE: 'aa', SPEC_ID: '1020200001', isTag: true },
{ ID: 1020200002, CODE: 'bb', SPEC_ID: '1020200002', isTag: true },
{ ID: 1020200003, CODE: 'cc', SPEC_ID: '1020200003', isTag: true },
{ ID: 1020200004, CODE: 'dd', SPEC_ID: '1020200004', isTag: true }
],
defaultProps: {
children: 'children',
label: 'CODE'
},
}
}
methods{
loadNode(node, resolve) {
if (node.level === 0) {
return resolve(this.treeData)
}
if (node.level === 1) {
if (node.data.ID === 1) {
return resolve(this.telChildren)
}
// else if (node.data.ID === 2) {
// return resolve(this.wlwChildren)
// }
else {
resolve(null)
}
}
if (node.level > 1) {
setTimeout(() => {
const conditionList = {
counted: true,
entityspecId: node.data.SPEC_ID,
paginationMapParameter: {
order: [{ attribute: 'CODE', type: 'ASC', nullsFirst: 'true' }],
query: [],
specItem: this.specItem
},
reduced: false,
regionCode: ''
}
entity.queryWithoutPagination(conditionList).then(data => {
const dataInfo = []
if (data.count) {
data.items.forEach(item => {
item.entityInfo.isLeaf = true
dataInfo.push(item.entityInfo)
})
resolve(dataInfo)
} else {
resolve(null)
}
}).catch(item => { resolve(null) })
}, 1000)
}
},
//查询数据的接口
query2() {
const relations = {
// 机房规格ID
aSpecId: 1010000000,
zSpecId: '',
// 关系规格ID
relationSpecId: 1010210210000,
specItem: [{ attribute: 'CODE' }],
aCondition: [],
zCondition: [],
order: [{ attribute: 'CODE', type: 'ASC', nullsFirst: 'true' }],
pagination: { index: this.pageNumber2, size: this.pageSize2 }
}
relations.aCondition.push({ attribute: 'ID', criteriaType: '21', value: this.deviceFacilityId })
this.leftTreeOcableSegs = []
relation.queryA(relations).then((rows) => {
if (rows) {
const dataInfo = []
rows.items.forEach(item => { dataInfo.push(item.entityInfo) })
// leftTreeOcableSegs得到的是数据库中返回的数据,
//要把这个数据方法二级标题dd中显示,要怎么写
this.leftTreeOcableSegs[0].children = dataInfo
console.log(dataInfo)
this.total2 = rows.count
this.loading2 = false
}
}).catch(item => { this.loading2 = false })
},
}