加入ztree demo
parent
45f7d0e4a2
commit
a0c6c187c5
|
|
@ -0,0 +1,85 @@
|
|||
[
|
||||
{
|
||||
"id": "1",
|
||||
"name": "根目录",
|
||||
"isParent": true
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"name": "会员管理",
|
||||
"isParent": true,
|
||||
"parentId": "1"
|
||||
},
|
||||
{
|
||||
"id": "3",
|
||||
"name": "用户管理",
|
||||
"isParent": true,
|
||||
"parentId": "2"
|
||||
},
|
||||
{
|
||||
"id": "4",
|
||||
"name": "增加",
|
||||
"isParent": false,
|
||||
"parentId": "3"
|
||||
},
|
||||
{
|
||||
"id": "5",
|
||||
"name": "修改",
|
||||
"isParent": false,
|
||||
"parentId": "3"
|
||||
},
|
||||
{
|
||||
"id": "6",
|
||||
"name": "删除",
|
||||
"isParent": false,
|
||||
"parentId": "3"
|
||||
},
|
||||
{
|
||||
"id": "7",
|
||||
"name": "角色管理",
|
||||
"isParent": true,
|
||||
"parentId": "2"
|
||||
},
|
||||
{
|
||||
"id": "8",
|
||||
"name": "增加",
|
||||
"isParent": false,
|
||||
"parentId": "7"
|
||||
},
|
||||
{
|
||||
"id": "9",
|
||||
"name": "修改",
|
||||
"isParent": false,
|
||||
"parentId": "7"
|
||||
},
|
||||
{
|
||||
"id": "10",
|
||||
"name": "删除",
|
||||
"isParent": false,
|
||||
"parentId": "7"
|
||||
},
|
||||
{
|
||||
"id": "11",
|
||||
"name": "权限管理",
|
||||
"isParent": true,
|
||||
"parentId": "2"
|
||||
},
|
||||
{
|
||||
"id": "12",
|
||||
"name": "增加",
|
||||
"isParent": false,
|
||||
"parentId": "11"
|
||||
},
|
||||
{
|
||||
"id": "13",
|
||||
"name": "修改",
|
||||
"isParent": false,
|
||||
"parentId": "11"
|
||||
},
|
||||
{
|
||||
"id": "14",
|
||||
"name": "删除",
|
||||
"isParent": false,
|
||||
"parentId": "11"
|
||||
}
|
||||
]
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
{
|
||||
"code": 0,
|
||||
"msg": "获取成功",
|
||||
"data": {
|
||||
"trees": [
|
||||
{
|
||||
"name": "用户管理",
|
||||
"value": "xsgl",
|
||||
"checked": true
|
||||
},
|
||||
{
|
||||
"name": "用户组管理",
|
||||
"value": "sbgl",
|
||||
"checked": true,
|
||||
"list": [
|
||||
{
|
||||
"name": "角色管理",
|
||||
"value": "sbgl-sbsjlb",
|
||||
"checked": true,
|
||||
"list": [
|
||||
{
|
||||
"name": "添加角色",
|
||||
"value": "sbgl-sbsjlb-dj",
|
||||
"checked": true
|
||||
},
|
||||
{
|
||||
"name": "角色列表",
|
||||
"value": "sbgl-sbsjlb-yl",
|
||||
"checked": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "管理员管理",
|
||||
"value": "sbgl-sbsjlb",
|
||||
"checked": true,
|
||||
"list": [
|
||||
{
|
||||
"name": "添加管理员",
|
||||
"value": "sbgl-sbsjlb-dj",
|
||||
"checked": true
|
||||
},
|
||||
{
|
||||
"name": "管理员列表",
|
||||
"value": "sbgl-sbsjlb-yl",
|
||||
"checked": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
<link rel="stylesheet" href="lib/layui/css/layui.css">
|
||||
<link rel="stylesheet" href="css/okadmin.css">
|
||||
<link rel="stylesheet" href="font/iconfont.css">
|
||||
<link rel="stylesheet" href="lib/zTree_v3/css/zTreeStyle/zTreeStyle.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="ok-body">
|
||||
|
|
@ -39,7 +40,7 @@
|
|||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">权限</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="authTree"></div>
|
||||
<ul class="ztree" id="permissionTree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
|
|
@ -52,17 +53,50 @@
|
|||
</div>
|
||||
<!--js逻辑-->
|
||||
<script src="lib/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: ''
|
||||
}).extend({
|
||||
|
||||
});
|
||||
|
||||
layui.use(['element', 'form', 'jquery'], function () {
|
||||
var element = layui.element;
|
||||
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="lib/zTree_v3/js/jquery.ztree.all.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['element', 'form'], function () {
|
||||
var form = layui.form;
|
||||
var $ = layui.jquery;
|
||||
|
||||
// zTree设置
|
||||
var setting = {
|
||||
data: {
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: "id",
|
||||
pIdKey: "parentId",
|
||||
rootPId: 0
|
||||
}
|
||||
},
|
||||
check: {
|
||||
enable: true,
|
||||
chkStyle: "checkbox",
|
||||
radioType: "all"
|
||||
}
|
||||
};
|
||||
|
||||
// zTree异步请求所有权限树节点
|
||||
var treeObj, loadIndex;
|
||||
$.ajax({
|
||||
url: 'data/permission-tree.json',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {roleId: 1},
|
||||
beforeSend: function () {
|
||||
loadIndex = layer.load(0, {shade: 0.1});
|
||||
},
|
||||
complete: function () {
|
||||
layer.close(loadIndex);
|
||||
},
|
||||
success: function (data) {
|
||||
treeObj = $.fn.zTree.init($("#permissionTree"), setting, data);
|
||||
treeObj.expandAll(true);
|
||||
},
|
||||
error: function () {
|
||||
layer.msg('服务器错误', {icon: 5, time: 1000});
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(add)', function (data) {
|
||||
console.log(data.field);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
<link rel="stylesheet" href="lib/layui/css/layui.css">
|
||||
<link rel="stylesheet" href="css/okadmin.css">
|
||||
<link rel="stylesheet" href="font/iconfont.css">
|
||||
<link rel="stylesheet" href="lib/zTree_v3/css/zTreeStyle/zTreeStyle.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="ok-body">
|
||||
|
|
@ -39,7 +40,7 @@
|
|||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">权限</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="authTree"></div>
|
||||
<ul class="ztree" id="permissionTree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
|
|
@ -52,17 +53,50 @@
|
|||
</div>
|
||||
<!--js逻辑-->
|
||||
<script src="lib/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: ''
|
||||
}).extend({
|
||||
|
||||
});
|
||||
|
||||
layui.use(['element', 'form', 'jquery'], function () {
|
||||
var element = layui.element;
|
||||
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="lib/zTree_v3/js/jquery.ztree.all.js"></script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['element', 'form'], function () {
|
||||
var form = layui.form;
|
||||
var $ = layui.jquery;
|
||||
|
||||
// zTree设置
|
||||
var setting = {
|
||||
data: {
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: "id",
|
||||
pIdKey: "parentId",
|
||||
rootPId: 0
|
||||
}
|
||||
},
|
||||
check: {
|
||||
enable: true,
|
||||
chkStyle: "checkbox",
|
||||
radioType: "all"
|
||||
}
|
||||
};
|
||||
|
||||
// zTree异步请求所有权限树节点
|
||||
var treeObj, loadIndex;
|
||||
$.ajax({
|
||||
url: 'data/permission-tree.json',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {roleId: 1},
|
||||
beforeSend: function () {
|
||||
loadIndex = layer.load(0, {shade: 0.1});
|
||||
},
|
||||
complete: function () {
|
||||
layer.close(loadIndex);
|
||||
},
|
||||
success: function (data) {
|
||||
treeObj = $.fn.zTree.init($("#permissionTree"), setting, data);
|
||||
treeObj.expandAll(true);
|
||||
},
|
||||
error: function () {
|
||||
layer.msg('服务器错误', {icon: 5, time: 1000});
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(edit)', function (data) {
|
||||
console.log(data.field);
|
||||
|
|
|
|||
15
role.html
15
role.html
|
|
@ -117,20 +117,6 @@
|
|||
layer.confirm("确定要删除吗?", {skin: 'layui-layer-lan', icon: 2, title: '提示', anim: 6}, function () {
|
||||
layer.msg("操作成功!", {icon: 1, time: 1000});
|
||||
});
|
||||
} else if (layEvent === 'auth') {
|
||||
layer.open({
|
||||
title: '角色授权',
|
||||
type: 2,
|
||||
shade: false,
|
||||
maxmin: true,
|
||||
shade: 0.5,
|
||||
area: ['90%', '90%'],
|
||||
content: 'role-auth.html',
|
||||
zIndex: layer.zIndex,
|
||||
end: function () {
|
||||
$(".layui-laypage-btn")[0].click();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -177,7 +163,6 @@
|
|||
</script>
|
||||
<!--模板-->
|
||||
<script type="text/html" id="operationTpl">
|
||||
<a href="javascript:;" title="授权" lay-event="auth"><i class="iconfont icon-jiaoseshouquan"></i></a>
|
||||
<a href="javascript:;" title="编辑" lay-event="edit"><i class="layui-icon"></i></a>
|
||||
<a href="javascript:;" title="删除" lay-event="del"><i class="layui-icon"></i></a>
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue