<el-tree ref="tree" :data="companyList" :props="defaultProps" node-key="key" :highlight-current="true"
accordion :current-node-key="currentNode" @node-click="getrigDetail">
<div class="custom-tree-node" slot-scope="{ node, data }">
<el-row>
<el-col :span="12" class="name">{{ node.label }}</el-col>
<el-col :span="12" class="col_r"><span class="c_red">{{ data.alarmNum }}</span> / <span
class="c_green">{{ data.runNum }}</span> / <span class="c_blue">{{ data.holdNum
}}</span> / <span class="c_black">{{ data.offlineNum }}</span></el-col>
</el-row>
<el-row>
<el-col :span="24" class="col_r">告警数 / 运行数 / 待机数 / 离线数</el-col>
</el-row>
</div>
</el-tree>
getrigDetail(data, node) {
if (this.paramsId.companyId !== data.companyId) {
const parentEle = document.getElementById('is-current')
if (parentEle) {
parentEle.setAttribute('id', '')
}
}
this.paramsId.companyId = data.companyId
this.paramsId.projectId = data.projectId
this.$nextTick(() => {
if (node && node.level === 2) {
let parentEle = document.getElementsByClassName('is-current')[0]
if (parentEle) {
parentEle.parentNode.previousSibling.setAttribute('id', 'is-current')
}
}
})
}
getrigDetail(data, node) {
this.paramsId.companyId = data.companyId
this.paramsId.projectId = data.projectId
this.$nextTick(() => {
if (node && node.level === 1) {
if (Array.isArray(node.parent.childNodes) && node.parent.childNodes.length) {
node.parent.childNodes.forEach(item => {
item.isCurrent = false
})
}
node.isCurrent = true
} else if (node && node.level === 2) {
if (Array.isArray(node.parent.parent.childNodes) && node.parent.parent.childNodes.length) {
node.parent.parent.childNodes.forEach(item => {
item.isCurrent = false
})
}
node.parent.isCurrent = true
}
})
}