topicdongtai.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. sortOrder: 'desc',
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'id', title: __('Id')},
  27. // {field: 'topic_ids', title: __('Topic_ids'), operate: 'LIKE'},
  28. // {field: 'topichub.name', title: __('Topichub.name'), operate: 'LIKE'},
  29. {field: 'user_id', title: __('User_id')},
  30. {field: 'user.username', title: __('User.username'),sortable:true, operate: 'LIKE'},
  31. {field: 'content', title: __('Content'), operate: 'LIKE',
  32. cellStyle: {css: {
  33. "white-space": "break-spaces",
  34. "max-width": "200px",
  35. "min-width": "200px",
  36. "word-break": "break-all",
  37. "text-overflow": "inherit",
  38. "overflow": "visible",
  39. }
  40. }
  41. },
  42. {field: 'images', title: __('Images'), operate: false,
  43. cellStyle: {css: {
  44. "white-space": "break-spaces",
  45. "max-width": "150px",
  46. "min-width": "150px",
  47. "word-break": "break-all",
  48. "text-overflow": "inherit",
  49. "overflow": "visible",
  50. }
  51. },
  52. events: Table.api.events.image, formatter: Table.api.formatter.images},
  53. {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  54. {field: 'audio_file', title: __('Audio_file'), operate: false,events: Table.api.events.image, formatter: Table.api.formatter.audio},
  55. // {field: 'audio_second', title: __('Audio_second')},
  56. // {field: 'goodnum', title: __('Goodnum')},
  57. // {field: 'answernum', title: __('Answernum')},
  58. {field: 'createtime', title: __('Createtime'),sortable:true, operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  59. // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  60. // {field: 'cityname', title: __('Cityname'), operate: 'LIKE'},
  61. // {field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
  62. // {field: 'latitude', title: __('Latitude'), operate: 'LIKE'},
  63. // {field: 'aite', title: __('Aite'), operate: 'LIKE'},
  64. {field: 'is_public', title: __('Is_public'), searchList: {"1":__('Is_public 1'),"2":__('Is_public 2')}, formatter: Table.api.formatter.normal},
  65. {field: 'toptime', title: __('toptime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  66. {field: 'auditstatus', title: __('Auditstatus'), searchList: {"0":__('Auditstatus 0'),"1":__('Auditstatus 1'),"2":__('Auditstatus 2')}, formatter: Table.api.formatter.status},
  67. {field: 'audittime', title: __('Audittime'),sortable:true, operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  68. {field: 'auditremark', title: __('Auditremark'), operate: 'LIKE',
  69. cellStyle: {css: {
  70. "white-space": "break-spaces",
  71. "max-width": "100px",
  72. "min-width": "100px",
  73. "word-break": "break-all",
  74. "text-overflow": "inherit",
  75. "overflow": "visible",
  76. }
  77. }
  78. },
  79. {field: 'operate', title: __('Operate'), table: table,
  80. buttons:[
  81. {
  82. name:'toptime',
  83. text:'置顶',
  84. title:'置顶',
  85. icon:'fa fa-exclamation-circle',
  86. classname:'btn btn-xs btn-info btn-ajax',
  87. url:'topicdongtai/toptime/id/{ids}?dialog=1',
  88. target:'_self',
  89. refresh:true,
  90. },
  91. {
  92. name:'untoptime',
  93. text:'取消置顶',
  94. title:'取消置顶',
  95. icon:'fa fa-exclamation-circle',
  96. classname:'btn btn-xs btn-info btn-ajax',
  97. url:'topicdongtai/untoptime/id/{ids}?dialog=1',
  98. target:'_self',
  99. hidden:function(row){
  100. if(row.toptime > 0){
  101. return false;
  102. }
  103. return true;
  104. },
  105. refresh:true,
  106. }
  107. ],
  108. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  109. ]
  110. ]
  111. });
  112. // 为表格绑定事件
  113. Table.api.bindevent(table);
  114. },
  115. toptime: function () {
  116. Controller.api.bindevent();
  117. },
  118. untoptime: function () {
  119. Controller.api.bindevent();
  120. },
  121. add: function () {
  122. Controller.api.bindevent();
  123. },
  124. edit: function () {
  125. Controller.api.bindevent();
  126. },
  127. api: {
  128. bindevent: function () {
  129. Form.api.bindevent($("form[role=form]"));
  130. }
  131. }
  132. };
  133. return Controller;
  134. });