tablelink.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init();
  6. this.table.first();
  7. this.table.second();
  8. },
  9. table: {
  10. first: function () {
  11. // 表格1
  12. var table1 = $("#table1");
  13. table1.bootstrapTable({
  14. url: 'example/tablelink/table1',
  15. toolbar: '#toolbar1',
  16. sortName: 'id',
  17. search: false,
  18. columns: [
  19. [
  20. // {field: 'state', checkbox: true,},
  21. {field: 'id', title: 'ID'},
  22. {field: 'username', title: __('Nickname')},
  23. {
  24. field: 'operate', title: __('Operate'), table: table1, events: Table.api.events.operate, buttons: [
  25. {
  26. name: 'log',
  27. title: '日志列表',
  28. text: '日志列表',
  29. icon: 'fa fa-list',
  30. classname: 'btn btn-primary btn-xs btn-click',
  31. click: function (e, data) {
  32. $("#myTabContent2 .form-commonsearch input[name='username']").val(data.username);
  33. $("#myTabContent2 .btn-refresh").trigger("click");
  34. }
  35. }
  36. ], formatter: Table.api.formatter.operate
  37. }
  38. ]
  39. ]
  40. });
  41. // 为表格1绑定事件
  42. Table.api.bindevent(table1);
  43. },
  44. second: function () {
  45. // 表格2
  46. var table2 = $("#table2");
  47. table2.bootstrapTable({
  48. url: 'example/tablelink/table2',
  49. extend: {
  50. index_url: '',
  51. add_url: '',
  52. edit_url: '',
  53. del_url: '',
  54. multi_url: '',
  55. table: '',
  56. },
  57. toolbar: '#toolbar2',
  58. sortName: 'id',
  59. search: false,
  60. columns: [
  61. [
  62. {field: 'state', checkbox: true,},
  63. {field: 'id', title: 'ID'},
  64. {field: 'username', title: __('Nickname')},
  65. {field: 'title', title: __('Title')},
  66. {field: 'url', title: __('Url'), align: 'left', formatter: Table.api.formatter.url},
  67. {field: 'ip', title: __('ip')},
  68. {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  69. ]
  70. ]
  71. });
  72. // 为表格2绑定事件
  73. Table.api.bindevent(table2);
  74. }
  75. },
  76. };
  77. return Controller;
  78. });