Commit 59e2d4a2 by RuoYi

修改上级部门(选择项排除本身和下级)

parent dc6fe4c9
......@@ -153,11 +153,16 @@ public class SysDeptController extends BaseController
/**
* 选择部门树
*
* @param deptId 部门ID
* @param excludeId 排除ID
*/
@GetMapping("/selectDeptTree/{deptId}")
public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap)
@GetMapping(value = { "/selectDeptTree/{deptId}", "/selectDeptTree/{deptId}/{excludeId}" })
public String selectDeptTree(@PathVariable("deptId") Long deptId,
@PathVariable(value = "excludeId", required = false) String excludeId, ModelMap mmap)
{
mmap.put("dept", deptService.selectDeptById(deptId));
mmap.put("excludeId", excludeId);
return prefix + "/tree";
}
......@@ -173,6 +178,19 @@ public class SysDeptController extends BaseController
}
/**
* 加载部门列表树(排除下级)
*/
@GetMapping("/treeData/{excludeId}")
@ResponseBody
public List<Ztree> treeDataExcludeChild(@PathVariable(value = "excludeId", required = false) Long excludeId)
{
SysDept dept = new SysDept();
dept.setDeptId(excludeId);
List<Ztree> ztrees = deptService.selectDeptTreeExcludeChild(dept);
return ztrees;
}
/**
* 加载角色部门(数据权限)列表树
*/
@GetMapping("/roleDeptTreeData")
......
......@@ -113,11 +113,12 @@
/*部门管理-修改-选择部门树*/
function selectDeptTree() {
var deptId = $("#treeId").val();
var excludeId = $("input[name='deptId']").val();
if(deptId > 0) {
var options = {
title: '部门选择',
width: "380",
url: prefix + "/selectDeptTree/" + $("#treeId").val(),
url: prefix + "/selectDeptTree/" + $("#treeId").val() + "/" + excludeId,
callBack: doSubmit
};
$.modal.openOptions(options);
......
......@@ -28,8 +28,11 @@
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script th:inline="javascript">
var prefix = ctx + "system/dept"
var deptId = [[${deptId}]];
var excludeId = [[${excludeId}]];
$(function() {
var url = ctx + "system/dept/treeData";
var url = $.common.isEmpty(excludeId) ? prefix + "/treeData": prefix + "/treeData/" + excludeId;
var options = {
url: url,
expandLevel: 2,
......
......@@ -29,6 +29,14 @@ public interface ISysDeptService
public List<Ztree> selectDeptTree(SysDept dept);
/**
* 查询部门管理树(排除下级)
*
* @param dept 部门信息
* @return 所有部门信息
*/
public List<Ztree> selectDeptTreeExcludeChild(SysDept dept);
/**
* 根据角色ID查询菜单
*
* @param role 角色对象
......
package com.ruoyi.system.service.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -55,6 +57,32 @@ public class SysDeptServiceImpl implements ISysDeptService
}
/**
* 查询部门管理树(排除下级)
*
* @param deptId 部门ID
* @return 所有部门信息
*/
@Override
@DataScope(deptAlias = "d")
public List<Ztree> selectDeptTreeExcludeChild(SysDept dept)
{
Long deptId = dept.getDeptId();
List<SysDept> deptList = deptMapper.selectDeptList(dept);
Iterator<SysDept> it = deptList.iterator();
while (it.hasNext())
{
SysDept d = (SysDept) it.next();
if (d.getDeptId().intValue() == deptId
|| ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""))
{
it.remove();
}
}
List<Ztree> ztrees = initZtree(deptList);
return ztrees;
}
/**
* 根据角色ID查询部门(数据权限)
*
* @param role 角色对象
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment