video.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. layui.use([ 'laypage', 'layer', 'table', 'element','form','upload'], function(){
  2. var laypage = layui.laypage //分页
  3. ,$ = layui.jquery
  4. ,layer = layui.layer //弹层
  5. ,table = layui.table //表格
  6. ,element = layui.element //元素操作
  7. ,form = layui.form
  8. ,upload = layui.upload;
  9. var tableIds = 'videolist'; //表格ID
  10. //第一个实例
  11. var indexTtable=table.render({
  12. elem: '#'+tableIds
  13. ,url: '/dictionaryb/videohomeform' //数据接口
  14. ,where:{token:csrfToken}
  15. ,method:'post'
  16. ,page: true //开启分页
  17. ,text:'数据加载中'
  18. ,id:'tablerReload'
  19. ,cols: [[ //表头
  20. // {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left',align:'center'},
  21. {type:'numbers'},
  22. {field: 'type_name', title: '分类名称', align:'center'},
  23. {field: 'is_recommend', title: '是否推荐',width:150, align:'center'}
  24. ,{field: 'create_at', title: '添加时间',width:200, align:'center'}
  25. ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#operate'}
  26. ]]
  27. });
  28. indexTtable.reload('tablerReload'); //重新加载
  29. //列表操作
  30. table.on('tool('+tableIds+')', function(obj){
  31. var layEvent = obj.event,
  32. data = obj.data;
  33. if(layEvent === 'edit'){
  34. layer.open({
  35. type: 2,
  36. title: '修改视频分类',
  37. area: ['600px','550px'],
  38. anim: 2,
  39. content: '/dictionaryb/videoedit?id='+data.id //iframe的url,no代表不显示滚动条
  40. });
  41. } else if(layEvent === 'del') {
  42. layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
  43. $.post('/dictionaryb/videodel',{'id':data.id},function (data) {
  44. if(data.code == 200)
  45. {
  46. layer.msg(data.msg);
  47. table.reload('tablerReload');
  48. } else if(data.code == 300 ) {
  49. layer.msg(data.msg);
  50. }
  51. })
  52. })
  53. }
  54. });
  55. var $ = layui.$, active = {
  56. addData: function(){ //获取选中数据
  57. layer.open({
  58. type: 2,
  59. title: '添加视频类目',
  60. shade: [0],
  61. area: ['600px','550px'],
  62. content: '/dictionaryb/videoadd' //iframe的url,no代表不显示滚动条
  63. });
  64. }
  65. };
  66. $('.demoTable .layui-btn').on('click', function(){
  67. var type = $(this).data('type');
  68. active[type] ? active[type].call(this) : '';
  69. });
  70. //修改
  71. form.on('submit(save_video_type_name)', function(data){
  72. $.post('/dictionaryb/videoeditform',{'data':data.field},function (data) {
  73. if(data.code == 200)
  74. {
  75. layer.msg(data.msg);
  76. parent.layui.table.reload('tablerReload');
  77. } else if(data.code == 300 ) {
  78. layer.msg(data.msg);
  79. layer.msg(ReturnInfo(data.data),{icon:5});
  80. }
  81. })
  82. return false;
  83. });
  84. //添加
  85. form.on('submit(add_video_type_name)', function(data){
  86. $.post('/dictionaryb/videoaddform',{'data':data.field},function (data) {
  87. if(data.code == 200)
  88. {
  89. layer.msg(data.msg);
  90. parent.layui.table.reload('tablerReload');
  91. } else if(data.code == 300 ) {
  92. layer.msg(data.msg);
  93. layer.msg(ReturnInfo(data.data),{icon:5});
  94. }
  95. })
  96. return false;
  97. });
  98. });