topicdongtai.js 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
  29. {field: 'content', title: __('Content'), operate: 'LIKE',
  30. cellStyle: {css: {
  31. "white-space": "break-spaces",
  32. "max-width": "200px",
  33. "min-width": "200px",
  34. "word-break": "break-all",
  35. "text-overflow": "inherit",
  36. "overflow": "visible",
  37. }
  38. }
  39. },
  40. {field: 'images', title: __('Images'), operate: false,
  41. cellStyle: {css: {
  42. "white-space": "break-spaces",
  43. "max-width": "150px",
  44. "min-width": "150px",
  45. "word-break": "break-all",
  46. "text-overflow": "inherit",
  47. "overflow": "visible",
  48. }
  49. },
  50. events: Table.api.events.image, formatter: Table.api.formatter.images},
  51. // {field: 'audio_file', title: __('Audio_file'), operate: false},
  52. // {field: 'audio_second', title: __('Audio_second')},
  53. // {field: 'video_file', title: __('Video_file'), operate: false},
  54. {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
  55. {field: 'goodnum', title: __('Goodnum')},
  56. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  57. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  58. {field: 'auditstatus', title: __('Auditstatus'), searchList: {"0":__('Auditstatus 0'),"1":__('Auditstatus 1'),"2":__('Auditstatus 2')}, formatter: Table.api.formatter.status},
  59. {field: 'audittime', title: __('Audittime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  60. {field: 'auditremark', title: __('Auditremark'), operate: 'LIKE'},
  61. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  62. ]
  63. ]
  64. });
  65. // 为表格绑定事件
  66. Table.api.bindevent(table);
  67. },
  68. add: function () {
  69. Controller.api.bindevent();
  70. },
  71. edit: function () {
  72. Controller.api.bindevent();
  73. },
  74. api: {
  75. bindevent: function () {
  76. Form.api.bindevent($("form[role=form]"));
  77. }
  78. }
  79. };
  80. return Controller;
  81. });