eyemargin.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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: 'applys/eyemargin/index' + location.search,
  8. edit_url: 'applys/eyemargin/edit',
  9. del_url: 'applys/eyemargin/del',
  10. multi_url: 'applys/eyemargin/multi',
  11. table: 'eyemargin',
  12. }
  13. });
  14. var table = $("#table");
  15. // 初始化表格
  16. table.bootstrapTable({
  17. url: $.fn.bootstrapTable.defaults.extend.index_url,
  18. pk: 'id',
  19. sortName: 'id',
  20. columns: [
  21. [
  22. {checkbox: true},
  23. {field: 'id', title: __('Id')},
  24. {field: 'user_id', title: __('User_id')},
  25. {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
  26. {field: 'eye_type', title: __('Eye_type'), searchList: {"1":__('Eye_type 1'),"2":__('Eye_type 2')}, formatter: Table.api.formatter.normal},
  27. {field: 'content', title: __('Content'), operate: 'LIKE'},
  28. {field: 'video', title: __('Video'), operate: 'LIKE',formatter: function(val, row) {
  29. if(val) {
  30. return '<video width="120" height="90" preload="none" controls>'+
  31. '<source src="'+val+'" type="video/ogg">'+
  32. '</video>';
  33. } else {
  34. return '暂无';
  35. }
  36. }},
  37. {field: 'cover', title: __('Cover'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
  38. {field: 'city', title: __('城市'), operate: 'LIKE'},
  39. {field: 'is_main', title: __('Is_main'), searchList: {"1":__('Is_main 1'),"0":__('Is_main 0')}, formatter: Table.api.formatter.normal},
  40. {field: 'encode_status', title: __('转码状态'), searchList: {"0":__('待处理'),"1":__('成功'),"2":__('失败')}, formatter: Table.api.formatter.status},
  41. {field: 'status', title: __('Status'), searchList: {"-1":__('Status -1'),"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
  42. {field: 'weight', title: __('Weight')},
  43. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  44. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  45. ]
  46. ]
  47. });
  48. // 为表格绑定事件
  49. Table.api.bindevent(table);
  50. },
  51. add: function () {
  52. Controller.api.bindevent();
  53. },
  54. edit: function () {
  55. Controller.api.bindevent();
  56. },
  57. api: {
  58. bindevent: function () {
  59. Form.api.bindevent($("form[role=form]"));
  60. }
  61. }
  62. };
  63. return Controller;
  64. });