layui.use(['form','layer','laydate','table','laytpl','layedit','upload'],function(){ var form = layui.form, // layer = parent.layer === undefined ? layui.layer : top.layer, layer = layui.layer, $ = layui.jquery, table = layui.table, layedit = layui.layedit //表格头部操作菜单 var $ = layui.$, active = { mobile: function(){ //获取选中数据 alert(0) }, pc:function () { alert(1) }, backend:function () { alert(2) } }; function cacheClear(type) { layer.confirm('确定要删除吗?',{btn: ['确定', '取消']},function () { $.post('/news/newsdel',{id:data.id},function (data) { if(data.code == 200) { layer.msg(data.msg); table.reload('tablerReload'); } else if(data.code == 300 ) { layer.msg(data.msg); } }) }) } //监听指定开关 form.on('switch(switchTest)', function(data){ layer.confirm('确定要修改此操作吗?',{btn: ['确定', '取消']},function () { $.post('/house/housesortedit',{id:data.value,examineid:1},function (data) { if(data.code == 200) { layer.msg(data.msg); table.reload('tablerReload'); } else if(data.code == 300 ) { layer.msg(data.msg); } }) },function (aa) { table.reload('tablerReload'); //重新加载 }) }); $('.demoTable .layui-btn').on('click', function(){ var type = $(this).data('type'); active[type] ? active[type].call(this) : ''; }); //表格右边操作栏目 table.on('tool('+tableIds+')', function(obj){ var data = obj.data; if(obj.event === 'del'){ //删除操作 layer.confirm('确定要删除吗?',{btn: ['确定', '取消']},function () { $.post('/news/newsdel',{id:data.id},function (data) { if(data.code == 200) { layer.msg(data.msg); table.reload('tablerReload'); } else if(data.code == 300 ) { layer.msg(data.msg); } }) }) } else if(obj.event === 'edit'){ //编辑操作 var index = layui.layer.open({ title : "编辑资讯", type : 2, area:['','100%'], maxmin: true, content : "/news/newsedit?id="+data.id }) layui.layer.full(index); //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作) $(window).on("resize",function(){ layui.layer.full(index); }) } }); });