report.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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: 'ask/report/index',
  8. add_url: 'ask/report/add',
  9. edit_url: 'ask/report/edit',
  10. del_url: 'ask/report/del',
  11. multi_url: 'ask/report/multi',
  12. table: 'ask_report',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id')},
  25. {field: 'user_id', title: __('User_id'), formatter: Table.api.formatter.search},
  26. {field: 'user.nickname', title: __('nickname'), operate: false},
  27. {field: 'type', title: __('Type'), searchList: {"question": __('Question'), "article": __('Article'), "answer": __('Answer'), "tag": __('Tag'), "comment": __('Comment')}, formatter: Table.api.formatter.normal},
  28. {field: 'source_id', title: __('Source_id'), formatter: Table.api.formatter.search},
  29. {field: 'reason', title: __('Reason'), formatter: Table.api.formatter.search},
  30. {field: 'reason_text', title: __('Reason'), operate: false},
  31. {field: 'content', title: __('Content')},
  32. {field: 'ip', title: __('Ip')},
  33. {field: 'useragent', title: __('Useragent'), visible: false},
  34. {
  35. field: 'view', title: __('View'), formatter: function (value, row, index) {
  36. return '<a href="ask/' + row['type'] + '/edit/ids/' + row['source_id'] + '" class="btn btn-xs btn-info btn-dialog" title="查看">查看</a>'
  37. }, operate: false
  38. },
  39. {field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
  40. {field: 'status', title: __('Status'), searchList: {"normal": __('Normal'), "hidden": __('Hidden')}, formatter: Table.api.formatter.status},
  41. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  42. ]
  43. ]
  44. });
  45. // 为表格绑定事件
  46. Table.api.bindevent(table);
  47. },
  48. add: function () {
  49. Controller.api.bindevent();
  50. },
  51. edit: function () {
  52. Controller.api.bindevent();
  53. },
  54. api: {
  55. bindevent: function () {
  56. Form.api.bindevent($("form[role=form]"));
  57. }
  58. }
  59. };
  60. return Controller;
  61. });