topicdongtai.js 7.1 KB

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