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