layui.use([ 'laypage', 'layer', 'table', 'element','form','upload'], function(){ var laypage = layui.laypage //分页 ,$ = layui.jquery ,layer = layui.layer //弹层 ,table = layui.table //表格 ,element = layui.element //元素操作 ,form = layui.form ,upload = layui.upload; var tableIds = 'videolist'; //表格ID //第一个实例 var indexTtable=table.render({ elem: '#'+tableIds ,url: '/dictionaryb/videohomeform' //数据接口 ,where:{token:csrfToken} ,method:'post' ,page: true //开启分页 ,text:'数据加载中' ,id:'tablerReload' ,cols: [[ //表头 // {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left',align:'center'}, {type:'numbers'}, {field: 'type_name', title: '分类名称', align:'center'}, {field: 'is_recommend', title: '是否推荐',width:150, align:'center'} ,{field: 'create_at', title: '添加时间',width:200, align:'center'} ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#operate'} ]] }); indexTtable.reload('tablerReload'); //重新加载 //列表操作 table.on('tool('+tableIds+')', function(obj){ var layEvent = obj.event, data = obj.data; if(layEvent === 'edit'){ layer.open({ type: 2, title: '修改视频分类', area: ['600px','550px'], anim: 2, content: '/dictionaryb/videoedit?id='+data.id //iframe的url,no代表不显示滚动条 }); } else if(layEvent === 'del') { layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () { $.post('/dictionaryb/videodel',{'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); } }) }) } }); var $ = layui.$, active = { addData: function(){ //获取选中数据 layer.open({ type: 2, title: '添加视频类目', shade: [0], area: ['600px','550px'], content: '/dictionaryb/videoadd' //iframe的url,no代表不显示滚动条 }); } }; $('.demoTable .layui-btn').on('click', function(){ var type = $(this).data('type'); active[type] ? active[type].call(this) : ''; }); //修改 form.on('submit(save_video_type_name)', function(data){ $.post('/dictionaryb/videoeditform',{'data':data.field},function (data) { if(data.code == 200) { layer.msg(data.msg); parent.layui.table.reload('tablerReload'); } else if(data.code == 300 ) { layer.msg(data.msg); layer.msg(ReturnInfo(data.data),{icon:5}); } }) return false; }); //添加 form.on('submit(add_video_type_name)', function(data){ $.post('/dictionaryb/videoaddform',{'data':data.field},function (data) { if(data.code == 200) { layer.msg(data.msg); parent.layui.table.reload('tablerReload'); } else if(data.code == 300 ) { layer.msg(data.msg); layer.msg(ReturnInfo(data.data),{icon:5}); } }) return false; }); });