layui.use([ 'laypage', 'layer', 'table', 'element','form'], function(){ var laypage = layui.laypage //分页 ,layer = layui.layer //弹层 ,table = layui.table //表格 ,element = layui.element //元素操作 ,form = layui.form; var tableIds = 'newsCategoryList'; //第一个实例 table.render({ elem: '#'+tableIds ,url: '/usersignup/labelform' //数据接口 ,where:{token:csrfToken} ,method:'post' ,page: true //开启分页 ,height:600 ,text:'数据加载中' ,id:'tablereload' ,cols: [[ //表头 // {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left',align:'center'}, {field: 'name', title: '来源名称', align:'center'} ,{field: 'type', title: '来源设备', align:'center'} ,{field: 'source_id', title: '文档ID',align:'center'} ,{field: 'create_at', title: '添加时间', align:'center'} ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#operate'} ]] }); //列表操作 table.on('tool('+tableIds+')', 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: '/usersignup/labeledit?id='+data.id, //iframe的url,no代表不显示滚动条 end:function () { table.reload('tablereload'); } }); } else if(layEvent === 'del') { layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () { data.del = 2; $.post('/usersignup/labeleditform',{data:data},function (data) { layer.msg(data.msg); table.reload('tablereload'); }) }) } }); var $ = layui.$, active = { addData: function(){ //获取选中数据 layer.open({ type: 2, title: '添加资讯分类', closeBtn: 1, //不显示关闭按钮 shade: [0], area: ['600px', '500px'], anim: 2, content: '/usersignup/labeladd', //iframe的url,no代表不显示滚动条 end:function () { table.reload('tablereload'); } }); // var checkStatus = table.checkStatus('idTest') // ,data = checkStatus.data; // layer.alert(JSON.stringify(data)); }, reload:function () { var form = pfgs_serialize($('form')); var name = ''; var id = ''; if(form.input_house == 'name'){ name = form.input_house_text; } else if(form.input_house == 'id'){ id = form.input_house_text; } table.reload('tablereload',{ where:{ type:form.type, name:name, source_id:id }, page:{ curr:1 } }) } }; $('.demoTable .layui-btn').on('click', function(){ var type = $(this).data('type'); active[type] ? active[type].call(this) : ''; }); //修改 form.on('submit(editnews)', function(data){ layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); $.post('/usersignup/labeleditform',{'data':data.field,'token':csrfToken},function (data) { if(data.data != null){ layer.msg(ReturnInfo(data.data),{icon:5}); return ; } layer.msg(data.msg); TableClose(); }) return false; }); //添加 form.on('submit(addnews)', function(data){ layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); $.post('/usersignup/labeladdform',{'data':data.field,'token':csrfToken},function (data) { if(data.data != null){ layer.msg(ReturnInfo(data.data),{icon:5}); return ; } layer.msg(data.msg); TableClose(); }) return false; }); });