customsearch.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. //
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'example/customsearch/index',
  9. add_url: 'example/customsearch/add',
  10. edit_url: '',
  11. del_url: 'example/customsearch/del',
  12. multi_url: 'example/customsearch/multi',
  13. table: '',
  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. searchFormVisible: true,
  23. searchFormTemplate: 'customformtpl',
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: 'ID', operate: false},
  28. {field: 'admin_id', title: __('Admin_id'), visible: false, operate: false},
  29. {field: 'username', title: __('Username'), formatter: Table.api.formatter.search},
  30. {field: 'title', title: __('Title')},
  31. {field: 'url', title: __('Url'), align: 'left'},
  32. {field: 'ip', title: __('IP')},
  33. {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  34. {
  35. field: 'operate',
  36. title: __('Operate'),
  37. table: table,
  38. events: Table.api.events.operate,
  39. formatter: Table.api.formatter.operate
  40. }
  41. ]
  42. ]
  43. });
  44. // 为表格绑定事件
  45. Table.api.bindevent(table);
  46. },
  47. add: function () {
  48. Controller.api.bindevent();
  49. },
  50. edit: function () {
  51. Controller.api.bindevent();
  52. },
  53. api: {
  54. bindevent: function () {
  55. Form.api.bindevent($("form[role=form]"));
  56. }
  57. }
  58. };
  59. return Controller;
  60. });