//只展示父级组织结构的权限
form.on('select(role_select)', function(data){
$.post("/admin/system/role/permission", {id: data.value}, function (result) {
var html = '';
html += '<label for="" class="layui-form-label">权限</label><div class="layui-input-block"><input type="checkbox" lay-filter="allIn" name="" lay-skin="primary" title="全选" value=""></div>';
$.each(result.data,function(n,m){
if (m.pid == 0){
html += '<div class="layui-input-block"><input type="checkbox" lay-filter="sonIn" class="permission" name="permissions[]" lay-skin="primary" title="'+m.describe+'" value="'+m.id+'"><div class="layui-input-block">';
$.each(result.data,function(i,j){
if (j.pid == m.id){
html += '<input id="'+ j.pid +'" type="checkbox" class="permission" name="permissions[]" lay-skin="primary" title="'+j.describe+'" value="'+j.id+'">';
}
});
html += '</div></div>';
}
});
$('#permission').html(html);
form.render();
});
});
遇到问题:最后需添加form.render() 来渲染数据。