2021-11-15 23:51:08 +08:00
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
2021-11-29 16:04:07 +08:00
< div class = "body-table" style = "margin-bottom:0;" >
< div class = "layui-form-bar" >
2021-11-23 17:04:53 +08:00
< button class = "layui-btn layui-btn-normal layui-btn-sm add-menu" > + 添加节点< / button >
2021-11-15 23:51:08 +08:00
< / div >
2021-11-29 16:04:07 +08:00
< div >
2021-11-15 23:51:08 +08:00
< table class = "layui-hide" id = "treeTable" lay-filter = "treeTable" > < / table >
< / div >
< / div >
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
< script >
2021-11-23 17:04:53 +08:00
var ptable = null, treeGrid = null,rightpage=null, layer = null, tableId = "treeTable";
2021-11-15 23:51:08 +08:00
function init(layui) {
2021-11-23 17:04:53 +08:00
treeGrid = layui.treeGrid;
2021-11-23 18:04:44 +08:00
rightpage = layui.rightpage;
2021-11-15 23:51:08 +08:00
layer = layui.layer;
ptable = treeGrid.render({
id: tableId
, elem: '#' + tableId
, idField: 'id'
, url: "{:url('home/rule/index')}"
, cellMinWidth: 100
, treeId: 'id'//树形id字段名称
, treeUpId: 'pid'//树形父id字段名称
, treeShowName: 'title'//以树形式显示的字段
, cols: [[
2021-11-23 17:04:53 +08:00
{ field: 'id', width: 80, title: 'ID号', align: 'center'}
, { field: 'title', width: 240, title: '节点名称'}
, { field: 'pid', title: '父节点ID', width: 90, align: 'center' }
, { field: 'src', title: '节点规则'}
, { field: 'name', width: 150, title: '操作日志显示名称'}
, {width: 160, title: '操作', align: 'center'
2021-11-15 23:51:08 +08:00
, templet: function (d) {
2021-11-23 17:04:53 +08:00
var html = '< span class = "layui-btn-group" > < button class = "layui-btn layui-btn-normal layui-btn-xs" lay-event = "add" > 添加子节点< / button > < button class = "layui-btn layui-btn-xs" lay-event = "edit" > 编辑< / button > < button class = "layui-btn layui-btn-danger layui-btn-xs" lay-event = "del" > 删除< / button > ';
2021-11-15 23:51:08 +08:00
return html;
}
}
]]
, page: false
//,skin:'line'
});
2021-11-23 17:04:53 +08:00
//表头工具栏事件
2021-11-29 16:04:07 +08:00
$('.add-menu').on('click',function(){
2021-11-23 17:04:53 +08:00
rightpage.open("{:url('home/rule/add')}");
return;
2021-11-15 23:51:08 +08:00
});
2021-11-23 17:04:53 +08:00
//操作按钮
2021-11-15 23:51:08 +08:00
treeGrid.on('tool(' + tableId + ')', function (obj) {
2021-11-23 17:04:53 +08:00
if (obj.event === 'add') {
rightpage.open('/home/rule/add?pid='+obj.data.id);
return;
}
if (obj.event === 'edit') {
rightpage.open('/home/rule/add?id='+obj.data.id);
return;
}
2021-11-15 23:51:08 +08:00
if (obj.event === 'del') {
layer.confirm('确定要删除吗?', { icon: 3, title: '提示' }, function (index) {
$.ajax({
url: "{:url('home/rule/delete')}",
type: 'post',
data: { id: obj.data.id },
success: function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
})
layer.close(index);
});
}
});
}
< / script >
2021-11-23 17:04:53 +08:00
{include file="common/layui" base="base" extend="['treeGrid','rightpage']" callback="init" /}
2021-11-15 23:51:08 +08:00
{/block}
<!-- /脚本 -->