video.js 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'video/video/index'+location.search,
  8. add_url: 'video/video/add'+location.search,
  9. edit_url: 'video/video/edit'+location.search,
  10. del_url: 'video/video/del',
  11. multi_url: 'video/video/multi',
  12. table: 'video',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'weigh',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id'),align: 'left', sortable: true},
  25. {field: 'img', title: __('图片'),align: 'left', events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
  26. {field: 'videolist.name', title: __('name'),align: 'left', operate: '='},
  27. {field: 'name', title: __('章节'), align: 'left',operate: 'LIKE'},
  28. {field: 'weigh', title: __('排序'), align: 'left',operate: 'LIKE'},
  29. {field: 'price', title: __('普价格'),align: 'left', operate: 'LIKE'},
  30. {field: 'vipprice', title: __('VIP价格'),align: 'left', operate: 'LIKE'},
  31. {field: 'createtime', title: __('添加时间'),align: 'left', visible: false,formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  32. {field: 'lx', title: __('类型'),align: 'left', formatter: Controller.api.formatter.lx, searchList: {1: __('视频'), 2:__('音频'), 3:__('文章')}},
  33. {field: 'status', title: __('Status'),align: 'left', formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
  34. {field: 'operate', title: __('Operate'),align: 'left', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  35. ]
  36. ]
  37. });
  38. // 为表格绑定事件
  39. Table.api.bindevent(table);
  40. },
  41. add: function () {
  42. Controller.api.bindevent();
  43. },
  44. edit: function () {
  45. Controller.api.bindevent();
  46. },
  47. api: {
  48. bindevent: function () {
  49. Form.api.bindevent($("form[role=form]"));
  50. },
  51. formatter: {
  52. paytype: function (value) {
  53. return value==2 ? '<span class="label label-danger">' + __("已支付") + '</span>': '<span class="label label-default">'+ __('未支付')+ '</span>';
  54. },
  55. ishot: function (value) {
  56. return value==2 ? '<span class="label label-danger">' + __("已推荐") + '</span>': '<span class="label label-default">'+ __('未推荐')+ '</span>';
  57. },
  58. lx: function (value) {
  59. if(value==1){
  60. return '<span class="label label-info">'+ __('视频')+ '</span>';
  61. }else if(value==2){
  62. return '<span class="label label-warning">' + __("音频") + '</span>';
  63. }else if(value==3){
  64. return '<span class="label label-success">' + __("文章") + '</span>';
  65. }
  66. }
  67. }
  68. }
  69. };
  70. return Controller;
  71. });