+-

\#\#\# 相关代码
<el-table
ref="treetable"
:data="dataOrgizationData"
:expand-row-keys="defaultExpandKeys"
:load="loadChildrenMethod"
:tree-props="{children: 'children', hasChildren: 'hasChild'}"
row-key="deptId"
border
lazy
>
<el-table-column prop="deptName" width="170" label="机构名称" tree-node/>
<el-table-column prop="BianzhiTotal" label="总编制数"/>
<el-table-column prop="leaderBianzhiTotal" label="干部编制数"/>
<el-table-column prop="fireManBianzhiTotal" label="消防员编制数"/>
<el-table-column prop="subDeptTotal" label="总机构数"/>
</el-table>
methods: {
loadChildrenMethod(tree, treeNode, resolve) {
console.log('異步加載子节点')
// 异步加载子节点
getChildrenOrgizationInfo({ deptPid: tree.deptId }).then(res => {
if (res.code === 200) {
if (res.data.length > 0) {
this.$set(res.data, 'hasChild', true)
res.data.forEach(item => {
getSubordinate({ deptId: item.deptId}).then(Subres => {
const data = Subres.data
if (data.fireManBianzhiTotal == null) {
this.$set(item, 'fireManBianzhiTotal', 0)
} else {
this.$set(item, 'fireManBianzhiTotal', data.fireManBianzhiTotal)
}
if (data.leaderBianzhiTotal == null) {
this.$set(item, 'leaderBianzhiTotal', 0)
} else {
this.$set(item, 'leaderBianzhiTotal', data.leaderBianzhiTotal)
}
if (data.subDeptTotal == null) {
this.$set(item, 'subDeptTotal', 0)
} else {
this.$set(item, 'subDeptTotal', data.subDeptTotal)
}
this.$set(item, 'BianzhiTotal', data.fireManBianzhiTotal + data.leaderBianzhiTotal)
})
getChildrenOrgizationInfo({ deptPid: item.deptId }).then(res2 => {
if (res2.data.length > 0) {
this.$set(item, 'children', res2.data)
this.$set(item, 'hasChild', true)
} else {
this.$set(item, 'hasChild', false)
}
})
})
}
resolve(res.data)
}else {
this.$message.error(`${res.message}`)
}
})
}
`
watch: {
dialogVisible(val) {
if (val === true) {
this.handleGetOrgizationInfo()
}
},
deptId(val) {
if (val) {
let valtostring = val.toString()
this.defaultExpandKeys.push(valtostring)
}
}
},