topicdongtai.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. table.on('post-body.bs.table', function (e, settings, json, xhr) {
  18. $(".btn-answer").data("area", ["80%", "80%"]);
  19. });
  20. // 初始化表格
  21. table.bootstrapTable({
  22. url: $.fn.bootstrapTable.defaults.extend.index_url,
  23. pk: 'id',
  24. sortName: 'id',
  25. sortOrder: 'desc',
  26. search: false,
  27. columns: [
  28. [
  29. {checkbox: true},
  30. {field: 'id', title: __('Id')},
  31. {field: 'user_id', title: __('User_id')},
  32. // {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
  33. {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
  34. {field: 'content', title: __('Content'), operate: 'LIKE',
  35. /*cellStyle: {css: {
  36. "white-space": "break-spaces",
  37. "max-width": "200px",
  38. "min-width": "200px",
  39. "word-break": "break-all",
  40. "text-overflow": "inherit",
  41. "overflow": "visible",
  42. }
  43. },*/
  44. table: table, class: 'autocontent', formatter: Table.api.formatter.content
  45. },
  46. {field: 'images', title: __('Images'), operate: false,
  47. cellStyle: {css: {
  48. "white-space": "break-spaces",
  49. "max-width": "150px",
  50. "min-width": "150px",
  51. "word-break": "break-all",
  52. "text-overflow": "inherit",
  53. "overflow": "visible",
  54. }
  55. },
  56. events: Table.api.events.image, formatter: Table.api.formatter.images},
  57. // {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  58. // {field: 'video_file', title: __('Video_file'), operate: false, formatter: Table.api.formatter.video},
  59. {field: 'goodnum', title: __('Goodnum')},
  60. // {field: 'answernum', title: __('Answernum')},
  61. {field: 'createtime', title: __('Createtime'),sortable:true, operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  62. // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  63. {field: 'auditstatus', title: __('Auditstatus'), searchList: {"0":__('Auditstatus 0'),"1":__('Auditstatus 1'),"2":__('Auditstatus 2')}, formatter: Table.api.formatter.status},
  64. {field: 'audittime', title: __('Audittime'),sortable:true, operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  65. {field: 'auditremark', title: __('Auditremark'), operate: 'LIKE',
  66. cellStyle: {css: {
  67. "white-space": "break-spaces",
  68. "max-width": "100px",
  69. "min-width": "100px",
  70. "word-break": "break-all",
  71. "text-overflow": "inherit",
  72. "overflow": "visible",
  73. }
  74. }
  75. },
  76. {field: 'operate', title: __('Operate'), table: table,
  77. buttons: [{
  78. name: 'answer',
  79. text: '查看评论',
  80. icon: 'fa fa-list',
  81. classname: 'btn btn-info btn-xs btn-answer btn-dialog',
  82. url: 'topicdongtaianswer/index/dt_id/{ids}?dialog=1',
  83. }],
  84. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  85. ]
  86. ]
  87. });
  88. // 为表格绑定事件
  89. Table.api.bindevent(table);
  90. },
  91. add: function () {
  92. Controller.api.bindevent();
  93. },
  94. edit: function () {
  95. Controller.api.bindevent();
  96. },
  97. answer: function () {
  98. Controller.api.bindevent();
  99. },
  100. api: {
  101. bindevent: function () {
  102. Form.api.bindevent($("form[role=form]"));
  103. }
  104. }
  105. };
  106. return Controller;
  107. });