From be51b4bf2561586589e153c3d48d0bf2acb1dcd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?= <15040126243@163.com> Date: Tue, 13 Sep 2022 14:06:53 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=20=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=9D=83=E9=99=90=E7=9A=84=E7=94=A8=E6=88=B7=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E9=83=A8=E9=97=A8=E7=BC=BA=E5=B0=91=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/system/service/impl/SysDeptServiceImpl.java | 6 +++++- ruoyi-ui/src/views/system/dept/index.vue | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index b3093863..00b40246 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -108,7 +108,11 @@ public class SysDeptServiceImpl implements ISysDeptService { */ @Override public SysDept selectDeptById(Long deptId) { - return baseMapper.selectById(deptId); + SysDept dept = baseMapper.selectById(deptId); + SysDept parentDept = baseMapper.selectOne(new LambdaQueryWrapper() + .select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId())); + dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null); + return dept; } /** diff --git a/ruoyi-ui/src/views/system/dept/index.vue b/ruoyi-ui/src/views/system/dept/index.vue index 5b898a2e..e502b4ea 100644 --- a/ruoyi-ui/src/views/system/dept/index.vue +++ b/ruoyi-ui/src/views/system/dept/index.vue @@ -297,9 +297,13 @@ export default { this.form = response.data; this.open = true; this.title = "修改部门"; - }); - listDeptExcludeChild(row.deptId).then(response => { - this.deptOptions = this.handleTree(response.data, "deptId"); + listDeptExcludeChild(row.deptId).then(response => { + this.deptOptions = this.handleTree(response.data, "deptId"); + if (this.deptOptions.length == 0) { + const noResultsOptions = { deptId: this.form.parentId, deptName: this.form.parentName, children: [] }; + this.deptOptions.push(noResultsOptions); + } + }); }); }, /** 提交按钮 */