comment.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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: 'blog/comment/index',
  8. add_url: 'blog/comment/add',
  9. edit_url: 'blog/comment/edit',
  10. del_url: 'blog/comment/del',
  11. multi_url: 'blog/comment/multi',
  12. table: 'blog_comment',
  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: 'post.title', title: __('Post'), formatter: Table.api.formatter.search},
  26. {field: 'username', title: __('Username'), formatter: Table.api.formatter.search},
  27. {field: 'email', title: __('Email'), formatter: Table.api.formatter.search},
  28. {field: 'website', title: __('Website'), formatter: Table.api.formatter.url},
  29. {field: 'comments', title: __('Comments')},
  30. {field: 'ip', title: __('Ip'), formatter: Table.api.formatter.search},
  31. {field: 'subscribe', title: __('Subscribe')},
  32. {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
  33. {field: 'updatetime', title: __('Updatetime'), visible: false, formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
  34. {field: 'status', title: __('Status'), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
  35. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  36. ]
  37. ]
  38. });
  39. // 为表格绑定事件
  40. Table.api.bindevent(table);
  41. },
  42. add: function () {
  43. Controller.api.bindevent();
  44. },
  45. edit: function () {
  46. Controller.api.bindevent();
  47. },
  48. api: {
  49. bindevent: function () {
  50. Form.api.bindevent($("form[role=form]"));
  51. }
  52. }
  53. };
  54. return Controller;
  55. });