Commit 3755597c760fc5f2896d02d5be871587abca547a
1 parent
71c31dfd
添加一个默认空属性,用来判断节点显示
Showing
3 changed files
with
11 additions
and
7 deletions
ruoyi-ui/src/views/system/dept/index.vue
ruoyi-ui/src/views/system/user/index.vue
| ... | ... | @@ -135,9 +135,9 @@ |
| 135 | 135 | <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange"> |
| 136 | 136 | <el-table-column type="selection" width="40" align="center" /> |
| 137 | 137 | <el-table-column label="用户编号" align="center" prop="userId" /> |
| 138 | - <el-table-column label="用户名称" align="center" prop="userName" /> | |
| 139 | - <el-table-column label="用户昵称" align="center" prop="nickName" /> | |
| 140 | - <el-table-column label="部门" align="center" prop="dept.deptName" /> | |
| 138 | + <el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" /> | |
| 139 | + <el-table-column label="用户昵称" align="center" prop="nickName" :show-overflow-tooltip="true" /> | |
| 140 | + <el-table-column label="部门" align="center" prop="dept.deptName" :show-overflow-tooltip="true" /> | |
| 141 | 141 | <el-table-column label="手机号码" align="center" prop="phonenumber" width="120" /> |
| 142 | 142 | <el-table-column label="状态" align="center"> |
| 143 | 143 | <template slot-scope="scope"> |
| ... | ... | @@ -502,7 +502,7 @@ export default { |
| 502 | 502 | reset() { |
| 503 | 503 | this.form = { |
| 504 | 504 | userId: undefined, |
| 505 | - deptId: 100, | |
| 505 | + deptId: undefined, | |
| 506 | 506 | userName: undefined, |
| 507 | 507 | nickName: undefined, |
| 508 | 508 | password: undefined, | ... | ... |
ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java
| ... | ... | @@ -49,11 +49,15 @@ public class SysDeptServiceImpl implements ISysDeptService |
| 49 | 49 | public List<SysDept> buildDeptTree(List<SysDept> depts) |
| 50 | 50 | { |
| 51 | 51 | List<SysDept> returnList = new ArrayList<SysDept>(); |
| 52 | + if (StringUtils.isNotEmpty(depts) && StringUtils.isNotNull(depts.stream().findFirst())) | |
| 53 | + { | |
| 54 | + depts.stream().findFirst().get().setParentId(null); | |
| 55 | + } | |
| 52 | 56 | for (Iterator<SysDept> iterator = depts.iterator(); iterator.hasNext();) |
| 53 | 57 | { |
| 54 | 58 | SysDept t = (SysDept) iterator.next(); |
| 55 | 59 | // 根据传入的某个父节点ID,遍历该父节点的所有子节点 |
| 56 | - if (t.getParentId() == 0) | |
| 60 | + if (StringUtils.isNull(t.getParentId()) || t.getParentId() == 0) | |
| 57 | 61 | { |
| 58 | 62 | recursionFn(depts, t); |
| 59 | 63 | returnList.add(t); |
| ... | ... | @@ -271,7 +275,7 @@ public class SysDeptServiceImpl implements ISysDeptService |
| 271 | 275 | while (it.hasNext()) |
| 272 | 276 | { |
| 273 | 277 | SysDept n = (SysDept) it.next(); |
| 274 | - if (n.getParentId().longValue() == t.getDeptId().longValue()) | |
| 278 | + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) | |
| 275 | 279 | { |
| 276 | 280 | tlist.add(n); |
| 277 | 281 | } | ... | ... |