From e55bc6c75f0ec94bd37ae18412c080384f3b4238 Mon Sep 17 00:00:00 2001 From: ZhengJie <201507802@qq.com> Date: Mon, 22 Jun 2020 21:09:18 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=BC=BA=E9=99=B7=E4=BF=AE=E5=A4=8D](v2.5):?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86/?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E7=AE=A1=E7=90=86/=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=BC=B9=E7=AA=97=E4=B8=AD=E4=B8=89=E7=BA=A7?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E4=B8=8D=E6=98=BE=E7=A4=BA=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/dept/index.vue | 19 +++++++++++++------ src/views/system/role/index.vue | 19 +++++++++++++------ src/views/system/user/index.vue | 19 +++++++++++++------ 3 files changed, 39 insertions(+), 18 deletions(-) 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 + } }) }, // 获取弹窗内部门数据