adminlog.js 2.7 KB

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