notification.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/notification/index',
  8. add_url: 'ask/notification/add',
  9. edit_url: 'ask/notification/edit',
  10. del_url: 'ask/notification/del',
  11. multi_url: 'ask/notification/multi',
  12. table: 'ask_notification',
  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. fixedColumns: true,
  22. fixedRightNumber: 1,
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'id', title: __('Id')},
  27. {field: 'from_user_id', title: __('From_user_id'), formatter: Table.api.formatter.search},
  28. {field: 'fromuser.nickname', title: __('发件人'), operate: false},
  29. {field: 'to_user_id', title: __('To_user_id'), formatter: Table.api.formatter.search},
  30. {field: 'touser.nickname', title: __('收件人'), operate: false},
  31. {field: 'action', title: __('Action'), formatter: Table.api.formatter.search},
  32. {field: 'type', title: __('Type')},
  33. {field: 'source_id', title: __('Source_id'), formatter: Table.api.formatter.search},
  34. {field: 'title', title: __('Title')},
  35. {field: 'isread', title: __('Isread'), formatter: Table.api.formatter.toggle, disable: true},
  36. {field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
  37. {field: 'updatetime', title: __('Updatetime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
  38. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  39. ]
  40. ]
  41. });
  42. // 为表格绑定事件
  43. Table.api.bindevent(table);
  44. },
  45. add: function () {
  46. Controller.api.bindevent();
  47. },
  48. edit: function () {
  49. Controller.api.bindevent();
  50. },
  51. api: {
  52. bindevent: function () {
  53. Form.api.bindevent($("form[role=form]"));
  54. }
  55. }
  56. };
  57. return Controller;
  58. });