<el-tree
:style="{ height: `${pageContentHeight + 53}px` }"
class="filter-tree"
node-key="parkDepId" //!!!!切换为自己的nodeid
:data="groupingList"
:props="defaultProps"//
:expand-on-click-node="false"
:highlight-current="true"
ref="tree"
@node-click="selectType"
:default-expanded-keys="expandDefaultData"// 默认展开
></el-tree>
defaultProps: {
label: 'depName',
children: 'children',
},
expandDefaultData: [], // 默认展开的节点
// 获取树列表
async getGroupingList() {
this.typeLoading = true
this.groupingList = []
const { success, obj, msg } = await memberManagementServe.dept(this.$route.query.enterpriseId)
if (success) {
if (obj) {
this.groupingList = obj
this.expandDefault()
}
} else {
this.$message.error(msg)
}
this.typeLoading = false
},
// 默认选择第一个树节点
expandDefault() {
this.expandDefaultData.push(this.groupingList[0].parkDepId)
this.$nextTick(() => {
this.$refs.tree.setCurrentKey(this.groupingList[0].parkDepId) // 默认选中节点第一个(高亮效果)
})
this.selectType(this.groupingList[0])
},
// 选择分类
selectType(data) {
this.currentData = data
this.fetchData()
},