topicdongtai.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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: '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'), operate: 'LIKE'},
  30. // {field: 'content', title: __('Content'), operate: 'LIKE'},
  31. {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  32. // {field: 'audio_file', title: __('Audio_file'), operate: false},
  33. // {field: 'audio_second', title: __('Audio_second')},
  34. {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  35. // {field: 'goodnum', title: __('Goodnum')},
  36. // {field: 'answernum', title: __('Answernum')},
  37. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. {field: 'cityname', title: __('Cityname'), operate: 'LIKE'},
  40. // {field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
  41. // {field: 'latitude', title: __('Latitude'), operate: 'LIKE'},
  42. // {field: 'aite', title: __('Aite'), operate: 'LIKE'},
  43. {field: 'is_public', title: __('Is_public'), searchList: {"1":__('Is_public 1'),"2":__('Is_public 2')}, formatter: Table.api.formatter.normal},
  44. {field: 'toptime', title: __('toptime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  45. {field: 'operate', title: __('Operate'), table: table,
  46. buttons:[
  47. {
  48. name:'toptime',
  49. text:'置顶',
  50. title:'置顶',
  51. icon:'fa fa-exclamation-circle',
  52. classname:'btn btn-xs btn-info btn-ajax',
  53. url:'topicdongtai/toptime/id/{ids}?dialog=1',
  54. target:'_self',
  55. refresh:true,
  56. },
  57. {
  58. name:'untoptime',
  59. text:'取消置顶',
  60. title:'取消置顶',
  61. icon:'fa fa-exclamation-circle',
  62. classname:'btn btn-xs btn-info btn-ajax',
  63. url:'topicdongtai/untoptime/id/{ids}?dialog=1',
  64. target:'_self',
  65. hidden:function(row){
  66. if(row.toptime > 0){
  67. return false;
  68. }
  69. return true;
  70. },
  71. refresh:true,
  72. }
  73. ],
  74. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  75. ]
  76. ]
  77. });
  78. // 为表格绑定事件
  79. Table.api.bindevent(table);
  80. },
  81. toptime: function () {
  82. Controller.api.bindevent();
  83. },
  84. untoptime: function () {
  85. Controller.api.bindevent();
  86. },
  87. add: function () {
  88. Controller.api.bindevent();
  89. },
  90. edit: function () {
  91. Controller.api.bindevent();
  92. },
  93. api: {
  94. bindevent: function () {
  95. Form.api.bindevent($("form[role=form]"));
  96. }
  97. }
  98. };
  99. return Controller;
  100. });