分别是一二三级,二三级名称不一样,使用props需要二三级名称一样,后台修改太大,只能前端将三级名称改为二级
selecCourse(e) {
console.log(e)
//获取列表
collegeTaskgetUserList({ courseId: e }).then(res => {
this.departmentList = res.data.deptParentVOList
console.log(this.departmentList)
//循环数组
this.departmentList.map(i => {
//在父数组中找到deptVOList二级数组,在二级数组中查找userVOList三级数组名字,改为deptVOList
JSON.parse(JSON.stringify(i.deptVOList).replace(/userVOList/g, 'deptVOList'))
//修改值为二级数组,将二级数组更新
i.deptVOList = JSON.parse(JSON.stringify(i.deptVOList).replace(/userVOList/g, 'deptVOList'))
})
console.log('dsfd ', this.departmentList)
})
},
//数组格式
//一级
"deptParentVOList": [
{
"type": 1,
"id": 1,
"name": "总经理室",
//二级
"deptVOList": [
{
"type": 2,
"id": 258,
"name": "文职部",
//三级
"userVOList": [
{
"type": 3,
"id": 44,
"name": "杨晓桐"
},
{
"type": 3,
"id": 236,
"name": "刘花"
},
]
}
]
}