var layout=[
{
title:'脚本对象名称',
treeNodes:true,
headerClass:'value_col',
colClass:'value_col',
style:'width:60%'
},
{
title:'操作',
headerClass:'value_col',
colClass:'value_col',
style:'width:9%',
render:function(row){
var str='';
if(row.parentId!=null&&row.children.length<=0){//有父元素没有子元素;
str = '<a class="layui-btn layui-btn-danger layui-btn-xs" onclick=del("' + row.id + '","' + row.parentId + '","' + row.children.length + '")><i class="layui-icon"></i></a>'
}else{
''
}
return '<a class="layui-btn layui-btn-normal layui-btn-xs" onclick=add("'+row.id+'","'+row.level+'")><i class="layui-icon"></i></a>'+
'<a class="layui-btn layui-btn-warm layui-btn-xs" onclick=change("' + row.id + '","' + row.title + '")><i class="layui-icon"></i></a>'+ //列渲染
str;
}
}
];
var groupList;
layui.use(['tree', 'layer','form','table'], function() {
var $ = layui.$,
layer = layui.layer,
form = layui.form,
table = layui.table;
$.ajax({
type: "post",
url: "/cd/tool/scene/tree.afca",
dataType:'json',
success:function(data){
if(data.code==='0'){
var message=data.msg;
groupList=data.data;
layui.treeGird({
elem:'#demo',
spreadable:true,
nodes:groupList,
layout:layout
})
}
},
error:function(){ }
}) });