From acfb6a56bbf3296f87790aab7eb249dadee01650 Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: Wed, 16 Sep 2020 11:47:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95&=E6=95=B0=E6=8D=AE=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=96=B0=E5=A2=9E=EF=BC=88=E5=B1=95=E5=BC=80/?= =?UTF-8?q?=E6=8A=98=E5=8F=A0=20=E5=85=A8=E9=80=89/=E5=85=A8=E4=B8=8D?= =?UTF-8?q?=E9=80=89=20=E7=88=B6=E5=AD=90=E8=81=94=E5=8A=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/static/ruoyi/css/ry-ui.css | 8 +++++ .../main/resources/static/ruoyi/js/ry-ui.js | 1 + .../resources/templates/system/role/add.html | 34 +++++++++++++++++-- .../templates/system/role/dataScope.html | 34 +++++++++++++++++-- .../resources/templates/system/role/edit.html | 34 +++++++++++++++++-- .../resources/templates/system/user/add.html | 10 +++--- .../resources/templates/system/user/edit.html | 10 +++--- 7 files changed, 113 insertions(+), 18 deletions(-) diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css b/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css index 25f0d9ad..98765f7d 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css +++ b/ruoyi-admin/src/main/resources/static/ruoyi/css/ry-ui.css @@ -443,6 +443,14 @@ label.error { background-position: -180px 0 } +/* ztree */ +div.ztree-border { + margin-top: 10px; + border: 1px solid #e5e6e7; + background: #FFFFFF none; + border-radius:4px; +} + /* 切换开关 */ .toggle-switch { display: -webkit-inline-box; 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 f858ab4a..8450dc9d 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 @@ -1261,6 +1261,7 @@ var table = { check: { enable: false, // 置 zTree 的节点上是否显示 checkbox / radio nocheckInherit: true, // 设置子节点是否自动继承 + chkboxType: { "Y": "ps", "N": "ps" } // 父子节点的关联关系 }, data: { key: { diff --git a/ruoyi-admin/src/main/resources/templates/system/role/add.html b/ruoyi-admin/src/main/resources/templates/system/role/add.html index 2675d093..82d3f439 100644 --- a/ruoyi-admin/src/main/resources/templates/system/role/add.html +++ b/ruoyi-admin/src/main/resources/templates/system/role/add.html @@ -42,9 +42,15 @@ </div> </div> <div class="form-group"> - <label class="col-sm-3 control-label">菜单权限</label> + <label class="col-sm-3 control-label">菜单权限:</label> <div class="col-sm-8"> - <div id="menuTrees" class="ztree"></div> + <label class="check-box"> + <input type="checkbox" value="1">展开/折叠</label> + <label class="check-box"> + <input type="checkbox" value="2">全选/全不选</label> + <label class="check-box"> + <input type="checkbox" value="3" checked>父子联动</label> + <div id="menuTrees" class="ztree ztree-border"></div> </div> </div> </form> @@ -111,6 +117,30 @@ focusCleanup: true }); + $('input').on('ifChanged', function(obj){ + var type = $(this).val(); + var checked = obj.currentTarget.checked; + if (type == 1) { + if (checked) { + $._tree.expandAll(true); + } else { + $._tree.expandAll(false); + } + } else if (type == "2") { + if (checked) { + $._tree.checkAllNodes(true); + } else { + $._tree.checkAllNodes(false); + } + } else if (type == "3") { + if (checked) { + $._tree.setting.check.chkboxType = { "Y": "ps", "N": "ps" }; + } else { + $._tree.setting.check.chkboxType = { "Y": "", "N": "" }; + } + } + }) + function submitHandler() { if ($.validate.form()) { add(); diff --git a/ruoyi-admin/src/main/resources/templates/system/role/dataScope.html b/ruoyi-admin/src/main/resources/templates/system/role/dataScope.html index d23fe588..d3b5513a 100644 --- a/ruoyi-admin/src/main/resources/templates/system/role/dataScope.html +++ b/ruoyi-admin/src/main/resources/templates/system/role/dataScope.html @@ -34,9 +34,15 @@ </div> </div> <div class="form-group" id="authDataScope" th:style="'display:' + @{(*{dataScope=='2'} ? 'block' : 'none')} + ''"> - <label class="col-sm-3 control-label">数据权限</label> + <label class="col-sm-3 control-label">数据权限:</label> <div class="col-sm-8"> - <div id="deptTrees" class="ztree"></div> + <label class="check-box"> + <input type="checkbox" value="1" checked>展开/折叠</label> + <label class="check-box"> + <input type="checkbox" value="2">全选/全不选</label> + <label class="check-box"> + <input type="checkbox" value="3" checked>父子联动</label> + <div id="deptTrees" class="ztree ztree-border"></div> </div> </div> </form> @@ -55,6 +61,30 @@ }; $.tree.init(options); }); + + $('input').on('ifChanged', function(obj){ + var type = $(this).val(); + var checked = obj.currentTarget.checked; + if (type == 1) { + if (checked) { + $._tree.expandAll(true); + } else { + $._tree.expandAll(false); + } + } else if (type == "2") { + if (checked) { + $._tree.checkAllNodes(true); + } else { + $._tree.checkAllNodes(false); + } + } else if (type == "3") { + if (checked) { + $._tree.setting.check.chkboxType = { "Y": "ps", "N": "ps" }; + } else { + $._tree.setting.check.chkboxType = { "Y": "", "N": "" }; + } + } + }) function submitHandler() { if ($.validate.form()) { diff --git a/ruoyi-admin/src/main/resources/templates/system/role/edit.html b/ruoyi-admin/src/main/resources/templates/system/role/edit.html index 8d510da8..354380d1 100644 --- a/ruoyi-admin/src/main/resources/templates/system/role/edit.html +++ b/ruoyi-admin/src/main/resources/templates/system/role/edit.html @@ -43,9 +43,15 @@ </div> </div> <div class="form-group"> - <label class="col-sm-3 control-label">菜单权限</label> + <label class="col-sm-3 control-label">菜单权限:</label> <div class="col-sm-8"> - <div id="menuTrees" class="ztree"></div> + <label class="check-box"> + <input type="checkbox" value="1">展开/折叠</label> + <label class="check-box"> + <input type="checkbox" value="2">全选/全不选</label> + <label class="check-box"> + <input type="checkbox" value="3" checked>父子联动</label> + <div id="menuTrees" class="ztree ztree-border"></div> </div> </div> </form> @@ -117,6 +123,30 @@ }, focusCleanup: true }); + + $('input').on('ifChanged', function(obj){ + var type = $(this).val(); + var checked = obj.currentTarget.checked; + if (type == 1) { + if (checked) { + $._tree.expandAll(true); + } else { + $._tree.expandAll(false); + } + } else if (type == "2") { + if (checked) { + $._tree.checkAllNodes(true); + } else { + $._tree.checkAllNodes(false); + } + } else if (type == "3") { + if (checked) { + $._tree.setting.check.chkboxType = { "Y": "ps", "N": "ps" }; + } else { + $._tree.setting.check.chkboxType = { "Y": "", "N": "" }; + } + } + }) function edit() { var roleId = $("input[name='roleId']").val(); diff --git a/ruoyi-admin/src/main/resources/templates/system/user/add.html b/ruoyi-admin/src/main/resources/templates/system/user/add.html index 6e3ac0c4..1d6c93a3 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/add.html +++ b/ruoyi-admin/src/main/resources/templates/system/user/add.html @@ -251,12 +251,10 @@ function doSubmit(index, layero){ var tree = layero.find("iframe")[0].contentWindow.$._tree; - if ($.tree.notAllowParents(tree)) { - var body = layer.getChildFrame('body', index); - $("#treeId").val(body.find('#treeId').val()); - $("#treeName").val(body.find('#treeName').val()); - layer.close(index); - } + var body = layer.getChildFrame('body', index); + $("#treeId").val(body.find('#treeId').val()); + $("#treeName").val(body.find('#treeName').val()); + layer.close(index); } $(function() { diff --git a/ruoyi-admin/src/main/resources/templates/system/user/edit.html b/ruoyi-admin/src/main/resources/templates/system/user/edit.html index d01144db..8e2464e4 100644 --- a/ruoyi-admin/src/main/resources/templates/system/user/edit.html +++ b/ruoyi-admin/src/main/resources/templates/system/user/edit.html @@ -215,12 +215,10 @@ function doSubmit(index, layero){ var tree = layero.find("iframe")[0].contentWindow.$._tree; - if ($.tree.notAllowParents(tree)) { - var body = layer.getChildFrame('body', index); - $("#treeId").val(body.find('#treeId').val()); - $("#treeName").val(body.find('#treeName').val()); - layer.close(index); - } + var body = layer.getChildFrame('body', index); + $("#treeId").val(body.find('#treeId').val()); + $("#treeName").val(body.find('#treeName').val()); + layer.close(index); } $(function() {