adminlog.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: 'auth/adminlog/index',
  8. add_url: '',
  9. edit_url: '',
  10. del_url: 'auth/adminlog/del',
  11. multi_url: 'auth/adminlog/multi',
  12. }
  13. });
  14. var table = $("#table");
  15. // 初始化表格
  16. table.bootstrapTable({
  17. url: $.fn.bootstrapTable.defaults.extend.index_url,
  18. fixedColumns: true,
  19. fixedRightNumber: 1,
  20. columns: [
  21. [
  22. {field: 'state', checkbox: true,},
  23. {field: 'id', title: 'ID', operate: false},
  24. {field: 'username', title: __('Username'), formatter: Table.api.formatter.search},
  25. {field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '模糊搜索'},
  26. {field: 'url', title: __('Url'), formatter: Table.api.formatter.url},
  27. {field: 'ip', title: __('IP'), events: Table.api.events.ip, formatter: Table.api.formatter.search},
  28. {field: 'browser', title: __('Browser'), operate: false, formatter: Controller.api.formatter.browser},
  29. {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  30. {
  31. field: 'operate', title: __('Operate'), table: table,
  32. events: Table.api.events.operate,
  33. buttons: [{
  34. name: 'detail',
  35. text: __('Detail'),
  36. icon: 'fa fa-list',
  37. classname: 'btn btn-info btn-xs btn-detail btn-dialog',
  38. url: 'auth/adminlog/detail'
  39. }],
  40. formatter: Table.api.formatter.operate
  41. }
  42. ]
  43. ]
  44. });
  45. // 为表格绑定事件
  46. Table.api.bindevent(table);
  47. },
  48. api: {
  49. bindevent: function () {
  50. Form.api.bindevent($("form[role=form]"));
  51. },
  52. formatter: {
  53. browser: function (value, row, index) {
  54. return '<a class="btn btn-xs btn-browser">' + row.useragent.split(" ")[0] + '</a>';
  55. },
  56. },
  57. }
  58. };
  59. return Controller;
  60. });