From 3755597c760fc5f2896d02d5be871587abca547a Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期四, 26 十二月 2019 15:59:03 +0800
Subject: [PATCH] 添加一个默认空属性,用来判断节点显示
---
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java | 8 ++++++--
ruoyi-ui/src/views/system/user/index.vue | 8 ++++----
ruoyi-ui/src/views/system/dept/index.vue | 2 +-
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/ruoyi-ui/src/views/system/dept/index.vue b/ruoyi-ui/src/views/system/dept/index.vue
index bcefdb8..3029913 100644
--- a/ruoyi-ui/src/views/system/dept/index.vue
+++ b/ruoyi-ui/src/views/system/dept/index.vue
@@ -228,7 +228,7 @@
reset() {
this.form = {
deptId: undefined,
- parentId: 100,
+ parentId: undefined,
deptName: undefined,
orderNum: undefined,
leader: undefined,
diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue
index aae3e82..d2cdb84 100644
--- a/ruoyi-ui/src/views/system/user/index.vue
+++ b/ruoyi-ui/src/views/system/user/index.vue
@@ -135,9 +135,9 @@
<el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="40" align="center" />
<el-table-column label="鐢ㄦ埛缂栧彿" align="center" prop="userId" />
- <el-table-column label="鐢ㄦ埛鍚嶇О" align="center" prop="userName" />
- <el-table-column label="鐢ㄦ埛鏄电О" align="center" prop="nickName" />
- <el-table-column label="閮ㄩ棬" align="center" prop="dept.deptName" />
+ <el-table-column label="鐢ㄦ埛鍚嶇О" align="center" prop="userName" :show-overflow-tooltip="true" />
+ <el-table-column label="鐢ㄦ埛鏄电О" align="center" prop="nickName" :show-overflow-tooltip="true" />
+ <el-table-column label="閮ㄩ棬" align="center" prop="dept.deptName" :show-overflow-tooltip="true" />
<el-table-column label="鎵嬫満鍙风爜" align="center" prop="phonenumber" width="120" />
<el-table-column label="鐘舵��" align="center">
<template slot-scope="scope">
@@ -502,7 +502,7 @@
reset() {
this.form = {
userId: undefined,
- deptId: 100,
+ deptId: undefined,
userName: undefined,
nickName: undefined,
password: undefined,
diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java
index f4e4dec..cc51d49 100644
--- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java
+++ b/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java
@@ -49,11 +49,15 @@
public List<SysDept> buildDeptTree(List<SysDept> depts)
{
List<SysDept> returnList = new ArrayList<SysDept>();
+ if (StringUtils.isNotEmpty(depts) && StringUtils.isNotNull(depts.stream().findFirst()))
+ {
+ depts.stream().findFirst().get().setParentId(null);
+ }
for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();)
{
SysDept t = (SysDept) iterator.next();
// 鏍规嵁浼犲叆鐨勬煇涓埗鑺傜偣ID,閬嶅巻璇ョ埗鑺傜偣鐨勬墍鏈夊瓙鑺傜偣
- if (t.getParentId() == 0)
+ if (StringUtils.isNull(t.getParentId()) || t.getParentId() == 0)
{
recursionFn(depts, t);
returnList.add(t);
@@ -271,7 +275,7 @@
while (it.hasNext())
{
SysDept n = (SysDept) it.next();
- if (n.getParentId().longValue() == t.getDeptId().longValue())
+ if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue())
{
tlist.add(n);
}
--
Gitblit v1.9.3