topicdongtai.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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: 'topicdongtai/index' + location.search,
  8. add_url: 'topicdongtai/add',
  9. edit_url: 'topicdongtai/edit',
  10. del_url: 'topicdongtai/del',
  11. multi_url: 'topicdongtai/multi',
  12. import_url: 'topicdongtai/import',
  13. table: 'topic_dongtai',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. // {field: 'user_id', title: __('User_id')},
  27. {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
  28. {field: 'content', title: __('Content'), operate: 'LIKE',
  29. cellStyle: {css: {
  30. "white-space": "break-spaces",
  31. "max-width": "200px",
  32. "min-width": "200px",
  33. "word-break": "break-all",
  34. "text-overflow": "inherit",
  35. "overflow": "visible",
  36. }
  37. }
  38. },
  39. {field: 'images', title: __('Images'), operate: false,
  40. cellStyle: {css: {
  41. "white-space": "break-spaces",
  42. "max-width": "150px",
  43. "min-width": "150px",
  44. "word-break": "break-all",
  45. "text-overflow": "inherit",
  46. "overflow": "visible",
  47. }
  48. },
  49. events: Table.api.events.image, formatter: Table.api.formatter.images},
  50. // {field: 'audio_file', title: __('Audio_file'), operate: false},
  51. // {field: 'audio_second', title: __('Audio_second')},
  52. // {field: 'video_file', title: __('Video_file'), operate: false},
  53. {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
  54. {field: 'goodnum', title: __('Goodnum')},
  55. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  56. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  57. {field: 'auditstatus', title: __('Auditstatus'), searchList: {"0":__('Auditstatus 0'),"1":__('Auditstatus 1'),"2":__('Auditstatus 2')}, formatter: Table.api.formatter.status},
  58. {field: 'audittime', title: __('Audittime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  59. {field: 'auditremark', title: __('Auditremark'), operate: 'LIKE'},
  60. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  61. ]
  62. ]
  63. });
  64. // 为表格绑定事件
  65. Table.api.bindevent(table);
  66. },
  67. add: function () {
  68. Controller.api.bindevent();
  69. },
  70. edit: function () {
  71. Controller.api.bindevent();
  72. },
  73. api: {
  74. bindevent: function () {
  75. Form.api.bindevent($("form[role=form]"));
  76. }
  77. }
  78. };
  79. return Controller;
  80. });