layui.use([ 'laypage', 'layer', 'table', 'element','form'], function(){ var laypage = layui.laypage //分页 ,layer = layui.layer //弹层 ,table = layui.table //表格 ,element = layui.element //元素操作 ,form = layui.form; //第一个实例 table.render({ elem: '#nodelist' ,url: '/auth/nodelistfrom' //数据接口 ,where:{token:csrfToken} ,method:'post' // ,id:'id' ,page: true //开启分页 ,text:'数据加载中' ,height : 600 ,limit:20 ,cols: [[ //表头 // {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left',align:'center'}, {type:'numbers',title:'序号'} ,{field: 'controller', title: '控制器', align:'center'} ,{field: 'action', title: '方法',align:'center'} ,{field: 'describe', title: '描述', width:200,align:'center'} ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#operate'} ]] }); //列表操作 table.on('tool(nodelist)', function(obj){ var layEvent = obj.event, data = obj.data; if(layEvent === 'edit'){ layer.open({ type: 2, title: '编辑节点', closeBtn: 1, //不显示关闭按钮 shade: [0], area: ['600px', '500px'], anim: 2, content: ['/auth/editnode?id='+data.id, 'yes'], //iframe的url,no代表不显示滚动条 }); } else if(layEvent === 'del') { layer.confirm('确定要删除吗?',{btn: ['确定', '取消']},function () { $.post('/auth/delfrom',{'token':csrfToken,'id':data.id},function (data) { if(data.code == 200){ layer.msg(data.msg); table.reload('nodelist'); return ; } layer.msg(data.msg); }) }) } }); var $ = layui.$, active = { addData: function(){ //获取选中数据 layer.open({ type: 2, title: '添加菜单', closeBtn: 1, //不显示关闭按钮 shade: [0], area: ['600px', '500px'], anim: 2, content: ['/auth/addnode', 'no'], //iframe的url,no代表不显示滚动条 // end: function(){ //此处用于演示 // layer.open({ // type: 2, // title: '很多时候,我们想最大化看,比如像这个页面。', // shadeClose: true, // shade: false, // maxmin: true, //开启最大化最小化按钮 // area: ['893px', '600px'], // content: '//fly.layui.com/' // }); // } }); // var checkStatus = table.checkStatus('idTest') // ,data = checkStatus.data; // layer.alert(JSON.stringify(data)); }, addDataall:function () { $.post('/auth/allcontroller',function (data) { console.log(data); if(data.code == 200) { layer.msg(data.msg); parent.layui.table.reload('nodelist'); } else if(data.code == 300 ) { layer.msg(data.msg); } }) } }; $('.demoTable .layui-btn').on('click', function(){ var type = $(this).data('type'); active[type] ? active[type].call(this) : ''; }); //添加 form.on('submit(tijiao)', function(data){ $.post('/auth/addnodefrom',{'data':data.field},function (data) { console.log(data); if(data.code == 200) { layer.msg(data.msg); parent.layui.table.reload('nodelist'); } else if(data.code == 300 ) { layer.msg(data.msg); } }) return false; }); //修改 form.on('submit(editsubmit)', function(data){ $.post('/auth/editnodefrom',{'data':data.field},function (data) { if(data.code == 200) { layer.msg('修改成功'); parent.layui.table.reload('nodelist'); setTimeout(function () { var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); },1000) } else if(data.code == 300 ) { layer.msg(data.msg); } }) return false; }); //删除 });