From d24481f9a53f7ce83087bbe630671c94f813e33b Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 1 Dec 2018 18:39:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E9=97=A8=E4=BF=AE=E6=94=B9=E4=B8=8D?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=9C=80=E5=90=8E=E5=B1=82=E7=BA=A7=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/system/SysDeptController.java | 2 +- .../src/main/resources/static/ruoyi/js/ry-ui.js | 11 +++++++++++ .../main/resources/templates/system/dept/edit.html | 11 +++++++---- .../com/ruoyi/system/service/ISysDeptService.java | 3 ++- .../ruoyi/system/service/impl/SysDeptServiceImpl.java | 7 +++++-- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java index 141a28ca4..2721dca56 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -149,7 +149,7 @@ public class SysDeptController extends BaseController @ResponseBody public List> treeData() { - List> tree = deptService.selectDeptTree(); + List> tree = deptService.selectDeptTree(new SysDept()); return tree; } diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index d49dddabc..6924adba1 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -744,6 +744,17 @@ } return true; }, + // 不允许最后层级节点选择 + notAllowLastLevel: function(_tree) { + var nodes = _tree.getSelectedNodes(); + for (var i = 0; i < nodes.length; i++) { + if (nodes[i].level == nodes.length + 1) { + $.modal.msgError("不能选择最后层级节点(" + nodes[i].name + ")"); + return false; + } + } + return true; + }, // 隐藏/显示搜索栏 toggleSearch: function() { $('#search').slideToggle(200); diff --git a/ruoyi-admin/src/main/resources/templates/system/dept/edit.html b/ruoyi-admin/src/main/resources/templates/system/dept/edit.html index 6dd926d4b..7bb5177e8 100644 --- a/ruoyi-admin/src/main/resources/templates/system/dept/edit.html +++ b/ruoyi-admin/src/main/resources/templates/system/dept/edit.html @@ -123,10 +123,13 @@ } function doSubmit(index, layero){ - var body = layer.getChildFrame('body', index); - $("#treeId").val(body.find('#treeId').val()); - $("#treeName").val(body.find('#treeName').val()); - layer.close(index); + var tree = layero.find("iframe")[0].contentWindow.$._tree; + if ($.tree.notAllowLastLevel(tree)) { + var body = layer.getChildFrame('body', index); + $("#treeId").val(body.find('#treeId').val()); + $("#treeName").val(body.find('#treeName').val()); + layer.close(index); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java index f8f3e3756..b379f7f3a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -23,9 +23,10 @@ public interface ISysDeptService /** * 查询部门管理树 * + * @param dept 部门信息 * @return 所有部门信息 */ - public List> selectDeptTree(); + public List> selectDeptTree(SysDept dept); /** * 根据角色ID查询菜单 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 a26d130ab..2cfdd30e1 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 @@ -28,6 +28,7 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 查询部门管理数据 * + * @param dept 部门信息 * @return 部门信息集合 */ @Override @@ -40,13 +41,15 @@ public class SysDeptServiceImpl implements ISysDeptService /** * 查询部门管理树 * + * @param dept 部门信息 * @return 所有部门信息 */ @Override - public List> selectDeptTree() + @DataScope(tableAlias = "d") + public List> selectDeptTree(SysDept dept) { List> trees = new ArrayList>(); - List deptList = selectDeptList(new SysDept()); + List deptList = deptMapper.selectDeptList(dept); trees = getTrees(deptList, false, null); return trees; }