adminlog.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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: 'admin_id', title: __('Admin_id'), formatter: Table.api.formatter.search, visible: false},
  25. {field: 'username', title: __('Username'), formatter: Table.api.formatter.search},
  26. {field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '模糊搜索'},
  27. {field: 'url', title: __('Url'), formatter: Table.api.formatter.url},
  28. {field: 'ip', title: __('IP'), events: Table.api.events.ip, formatter: Table.api.formatter.search},
  29. {field: 'browser', title: __('Browser'), operate: false, formatter: Controller.api.formatter.browser},
  30. {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  31. {
  32. field: 'operate', title: __('Operate'), table: table,
  33. events: Table.api.events.operate,
  34. buttons: [{
  35. name: 'detail',
  36. text: __('Detail'),
  37. icon: 'fa fa-list',
  38. classname: 'btn btn-info btn-xs btn-detail btn-dialog',
  39. url: 'auth/adminlog/detail'
  40. }],
  41. formatter: Table.api.formatter.operate
  42. }
  43. ]
  44. ]
  45. });
  46. // 为表格绑定事件
  47. Table.api.bindevent(table);
  48. },
  49. api: {
  50. bindevent: function () {
  51. Form.api.bindevent($("form[role=form]"));
  52. },
  53. formatter: {
  54. browser: function (value, row, index) {
  55. return '<a class="btn btn-xs btn-browser">' + row.useragent.split(" ")[0] + '</a>';
  56. },
  57. },
  58. }
  59. };
  60. return Controller;
  61. });