diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index 1c4f5d9..a401576 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -166,12 +166,19 @@ export default { }, getSupDepts(id) { crudDept.getDeptSuperior(id).then(res => { - this.depts = res.content.map(function(obj) { - if (obj.hasChildren && !obj.children) { - obj.children = null - } - return obj - }) + const date = res.content + this.buildDepts(date) + this.depts = date + }) + }, + buildDepts(depts) { + depts.forEach(data => { + if (data.children) { + this.buildDepts(data.children) + } + if (data.hasChildren && !data.children) { + data.children = null + } }) }, getDepts() { diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index ee1b1f4..de1f6b0 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -296,12 +296,19 @@ export default { ids.push(dept.id) }) getDeptSuperior(ids).then(res => { - this.depts = res.content.map(function(obj) { - if (obj.hasChildren && !obj.children) { - obj.children = null - } - return obj - }) + const date = res.content + this.buildDepts(date) + this.depts = date + }) + }, + buildDepts(depts) { + depts.forEach(data => { + if (data.children) { + this.buildDepts(data.children) + } + if (data.hasChildren && !data.children) { + data.children = null + } }) }, // 获取弹窗内部门数据 diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index 0872467..ad5f4ab 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -409,12 +409,19 @@ export default { }, getSupDepts(deptId) { getDeptSuperior(deptId).then(res => { - this.depts = res.content.map(function(obj) { - if (obj.hasChildren && !obj.children) { - obj.children = null - } - return obj - }) + const date = res.content + this.buildDepts(date) + this.depts = date + }) + }, + buildDepts(depts) { + depts.forEach(data => { + if (data.children) { + this.buildDepts(data.children) + } + if (data.hasChildren && !data.children) { + data.children = null + } }) }, // 获取弹窗内部门数据