login_log.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * 日志管理初始化
  3. */
  4. var LoginLog = {
  5. id: "LoginLogTable", //表格id
  6. seItem: null, //选中的条目
  7. table: null,
  8. layerIndex: -1
  9. };
  10. /**
  11. * 初始化表格的列
  12. */
  13. LoginLog.initColumn = function () {
  14. return [
  15. {field: 'selectItem', radio: true},
  16. {title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
  17. {title: '日志名称', field: 'logname', align: 'center', valign: 'middle', sortable: true},
  18. {title: '用户名称', field: 'userName', align: 'center', valign: 'middle'},
  19. {title: '时间', field: 'createtime', align: 'center', valign: 'middle', sortable: true},
  20. {title: '具体消息', field: 'message', align: 'center', valign: 'middle', sortable: true},
  21. {title: 'ip', field: 'ip', align: 'center', valign: 'middle', sortable: true}];
  22. };
  23. /**
  24. * 检查是否选中
  25. */
  26. LoginLog.check = function () {
  27. var selected = $('#' + this.id).bootstrapTable('getSelections');
  28. if (selected.length == 0) {
  29. Feng.info("请先选中表格中的某一记录!");
  30. return false;
  31. } else {
  32. LoginLog.seItem = selected[0];
  33. return true;
  34. }
  35. };
  36. /**
  37. * 清空日志
  38. */
  39. LoginLog.delLog = function () {
  40. Feng.confirm("是否清空所有日志?", function () {
  41. var ajax = Feng.baseAjax("/loginLog/delLoginLog", "清空日志");
  42. ajax.start();
  43. LoginLog.table.refresh();
  44. });
  45. }
  46. /**
  47. * 查询日志列表
  48. */
  49. LoginLog.search = function () {
  50. var queryData = {};
  51. queryData['logName'] = $("#logName").val();
  52. queryData['beginTime'] = $("#beginTime").val();
  53. queryData['endTime'] = $("#endTime").val();
  54. LoginLog.table.refresh({query: queryData});
  55. };
  56. $(function () {
  57. init();
  58. var defaultColunms = LoginLog.initColumn();
  59. var table = new BSTable(LoginLog.id, "/loginLog/list", defaultColunms);
  60. table.setPaginationType("server");
  61. LoginLog.table = table.init();
  62. });
  63. function init() {
  64. var BootstrapTable = $.fn.bootstrapTable.Constructor;
  65. BootstrapTable.prototype.onSort = function (event) {
  66. var $this = event.type === "keypress" ? $(event.currentTarget) : $(event.currentTarget).parent(),
  67. $this_ = this.$header.find('th').eq($this.index()),
  68. sortName = this.header.sortNames[$this.index()];
  69. this.$header.add(this.$header_).find('span.order').remove();
  70. if (this.options.sortName === $this.data('field')) {
  71. this.options.sortOrder = this.options.sortOrder === 'asc' ? 'desc' : 'asc';
  72. } else {
  73. this.options.sortName = sortName || $this.data('field');
  74. this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc';
  75. }
  76. this.trigger('sort', this.options.sortName, this.options.sortOrder);
  77. $this.add($this_).data('order', this.options.sortOrder);
  78. // Assign the correct sortable arrow
  79. this.getCaret();
  80. if (this.options.sidePagination === 'server') {
  81. this.initServer(this.options.silentSort);
  82. return;
  83. }
  84. this.initSort();
  85. this.initBody();
  86. };
  87. BootstrapTable.prototype.getCaret = function () {
  88. var that = this;
  89. $.each(this.$header.find('th'), function (i, th) {
  90. var sortName = that.header.sortNames[i];
  91. $(th).find('.sortable').removeClass('desc asc').addClass((sortName || $(th).data('field')) === that.options.sortName ? that.options.sortOrder : 'both');
  92. });
  93. };
  94. }