菜单&数据权限新增(展开/折叠 全选/全不选 父子联动)

pull/212/head
RuoYi 2020-09-16 11:47:22 +08:00
parent b7e20b48cb
commit acfb6a56bb
7 changed files with 113 additions and 18 deletions

View File

@ -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;

View File

@ -1261,6 +1261,7 @@ var table = {
check: {
enable: false, // 置 zTree 的节点上是否显示 checkbox / radio
nocheckInherit: true, // 设置子节点是否自动继承
chkboxType: { "Y": "ps", "N": "ps" } // 父子节点的关联关系
},
data: {
key: {

View File

@ -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();

View File

@ -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()) {

View File

@ -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();

View File

@ -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() {

View File

@ -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() {