topicdongtai.js 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_id', title: __('Topic_id')},
  27. {field: 'topichub.name', title: __('Topichub.name'), operate: 'LIKE'},
  28. {field: 'user_id', title: __('User_id')},
  29. {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
  30. {field: 'content', title: __('Content'), operate: 'LIKE'},
  31. {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  32. {field: 'goodnum', title: __('Goodnum')},
  33. {field: 'answernum', title: __('Answernum')},
  34. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  35. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
  37. buttons:[
  38. {
  39. name:'comment_list',
  40. text:'评论列表',
  41. title:'评论列表',
  42. icon:'fa fa-exclamation-circle',
  43. classname:'btn btn-xs btn-info btn-dialog',
  44. url:'topicdongtaianswer/index/dt_id/{ids}?dialog=1',
  45. target:'_self',
  46. extend: 'data-area=["90%","90%"]',
  47. hidden:function($row){
  48. if($row['answernum'] == 0){
  49. return true;
  50. }
  51. return false;
  52. }
  53. },
  54. {
  55. name:'good_list',
  56. text:'点赞列表',
  57. title:'点赞列表',
  58. icon:'fa fa-exclamation-circle',
  59. classname:'btn btn-xs btn-info btn-dialog',
  60. url:'topicdongtaigood/index/dt_id/{ids}?dialog=1',
  61. target:'_self',
  62. extend: 'data-area=["90%","90%"]',
  63. hidden:function($row){
  64. if($row['goodnum'] == 0){
  65. return true;
  66. }
  67. return false;
  68. }
  69. },
  70. ],}
  71. ]
  72. ]
  73. });
  74. // 为表格绑定事件
  75. Table.api.bindevent(table);
  76. },
  77. add: function () {
  78. Controller.api.bindevent();
  79. },
  80. edit: function () {
  81. Controller.api.bindevent();
  82. },
  83. api: {
  84. bindevent: function () {
  85. Form.api.bindevent($("form[role=form]"));
  86. }
  87. }
  88. };
  89. return Controller;
  90. });