Commit 5d482ae3 by Shelby

完成登录日志功能

parent f77d7f25
@layout("/common/_container.html"){ <script src="../../../../../../../../JavaProject/Guns-Train/guns-admin/src/main/webapp/static/modular/system/log/login_log.js"></script>@layout("/common/_container.html",{plugins:["table","layer","sweet-alert","laydate"],js:["/assets/modular/system/log/login_log.js"]}){
<div class="row"> <div class="row" id="loginLogPage">
<div class="col-sm-12"> <div class="col-lg-12">
<div class="ibox float-e-margins"> <div class="card card-outline-theme m-b-10">
<div class="ibox-title"> <div class="card-body">
<h5>登录日志</h5> <div class="form-horizontal">
</div> <div class="form-body">
<div class="ibox-content">
<div class="row row-lg">
<div class="col-sm-12">
<div class="row"> <div class="row">
<div class="col-sm-3"> <div class="col-md-3">
<#TimeCon id="beginTime" name="开始时间" isTime="false" pattern="YYYY-MM-DD" /> <div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">开始时间</div>
</div>
<input type="text" id="beginTime" class="form-control" placeholder="开始时间"
autocomplete="off">
</div>
</div> </div>
<div class="col-sm-3"> <div class="col-md-3">
<#TimeCon id="endTime" name="结束时间" isTime="false" pattern="YYYY-MM-DD" /> <div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">结束时间</div>
</div>
<input type="text" id="endTime" class="form-control" placeholder="结束时间"
autocomplete="off">
</div>
</div> </div>
<div class="col-sm-3"> <div class="col-md-3">
<#NameCon id="logName" name="日志名称" /> <div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">日志名称</div>
</div>
<input v-model="logName" type="text" class="form-control" placeholder="日志名称"
autocomplete="off">
</div>
</div> </div>
<div class="col-sm-3"> <div class="col-md-3">
<#button name="搜索" icon="fa-search" clickFun="LoginLog.search()"/> <div class="input-group condition-button">
<div class="input-group-btn condition-button">
<button type="button" id="check-minutes"
class="btn btn-info waves-effect waves-light condition-button-width"
onclick="LoginLog.search()">查询
</button>
</div>
</div>
</div> </div>
</div> </div>
<div class="hidden-xs" id="LoginLogTableToolbar" role="group"> </div>
<#button name="清空日志" icon="fa-plus" clickFun="LoginLog.delLog()"/> </div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="card card-outline-theme m-b-0">
<div class="card-body p-t-0 p-b-0">
<div class="form-horizontal">
<div class="form-actions">
<div class="row">
<div class="col-lg-12">
<div class="card m-b-0 p-b-0">
<div class="hidden-xs" id="loginLogTableToolbar" role="group">
<button type="button" class="btn btn-primary waves-effect" onclick="LoginLog.delLog()">
<i class="fa fa-plus"></i>&nbsp;清空日志
</button>
</div>
<#table id="loginLogTable"/>
</div>
</div>
</div> </div>
<#table id="LoginLogTable"/>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script src="${ctxPath}/static/modular/system/log/login_log.js"></script>
@} @}
/** /**
* 日志管理初始化 * 角色管理的单例
*/ */
var LoginLog = { var LoginLog = {
id: "LoginLogTable", //表格id id: "loginLogTable", //表格id
seItem: null, //选中的条目 seItem: null, //选中的条目
table: null, table: null,
layerIndex: -1 layerIndex: -1,
condition: {
logName: ""
}
}; };
/** /**
...@@ -16,27 +19,23 @@ LoginLog.initColumn = function () { ...@@ -16,27 +19,23 @@ LoginLog.initColumn = function () {
{field: 'selectItem', radio: true}, {field: 'selectItem', radio: true},
{title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'}, {title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
{title: '日志名称', field: 'logname', align: 'center', valign: 'middle', sortable: true}, {title: '日志名称', field: 'logname', align: 'center', valign: 'middle', sortable: true},
{title: '用户名称', field: 'userName', align: 'center', valign: 'middle'}, {title: '用户名称', field: 'userName', align: 'center', valign: 'middle', sortable: true},
{title: '时间', field: 'createtime', align: 'center', valign: 'middle', sortable: true}, {title: '时间', field: 'createtime', align: 'center', valign: 'middle', sortable: true},
{title: '具体消息', field: 'message', align: 'center', valign: 'middle', sortable: true}, {title: '具体消息', field: 'regularMessage', align: 'center', valign: 'middle', sortable: true},
{title: 'ip', field: 'ip', align: 'center', valign: 'middle', sortable: true}]; {title: 'ip', field: 'ip', align: 'center', valign: 'middle', sortable: true}];
}; };
/** /**
* 检查是否选中 * 日志搜索
*/ */
LoginLog.check = function () { LoginLog.search = function () {
var selected = $('#' + this.id).bootstrapTable('getSelections'); var queryData = {};
if (selected.length == 0) { queryData['beginTime'] = $("#beginTime").val();
Feng.info("请先选中表格中的某一记录!"); queryData['endTime'] = $("#endTime").val();
return false; queryData['logName'] = LoginLog.condition.logName;
} else { LoginLog.table.refresh({query: queryData});
LoginLog.seItem = selected[0];
return true;
}
}; };
/** /**
* 清空日志 * 清空日志
*/ */
...@@ -48,66 +47,28 @@ LoginLog.delLog = function () { ...@@ -48,66 +47,28 @@ LoginLog.delLog = function () {
}); });
} }
/**
* 查询日志列表
*/
LoginLog.search = function () {
var queryData = {};
queryData['logName'] = $("#logName").val();
queryData['beginTime'] = $("#beginTime").val();
queryData['endTime'] = $("#endTime").val();
LoginLog.table.refresh({query: queryData});
};
$(function () { $(function () {
init(); LoginLog.app = new Vue({
el: '#loginLogPage',
data: LoginLog.condition
});
var defaultColunms = LoginLog.initColumn(); var defaultColunms = LoginLog.initColumn();
var table = new BSTable(LoginLog.id, "/loginLog/list", defaultColunms); var table = new BSTable(LoginLog.id, "/loginLog/list", defaultColunms);
table.setPaginationType("server"); table.setPaginationType("server");
LoginLog.table = table.init(); table.init();
}); LoginLog.table = table;
function init() {
var BootstrapTable = $.fn.bootstrapTable.Constructor;
BootstrapTable.prototype.onSort = function (event) {
var $this = event.type === "keypress" ? $(event.currentTarget) : $(event.currentTarget).parent(),
$this_ = this.$header.find('th').eq($this.index()),
sortName = this.header.sortNames[$this.index()];
this.$header.add(this.$header_).find('span.order').remove();
if (this.options.sortName === $this.data('field')) { laydate.render({
this.options.sortOrder = this.options.sortOrder === 'asc' ? 'desc' : 'asc'; elem: '#beginTime',
} else { theme: '#009efb',
this.options.sortName = sortName || $this.data('field'); max: Feng.currentDate()
this.options.sortOrder = $this.data('order') === 'asc' ? 'desc' : 'asc'; });
}
this.trigger('sort', this.options.sortName, this.options.sortOrder);
$this.add($this_).data('order', this.options.sortOrder);
// Assign the correct sortable arrow
this.getCaret();
if (this.options.sidePagination === 'server') {
this.initServer(this.options.silentSort);
return;
}
this.initSort();
this.initBody();
};
BootstrapTable.prototype.getCaret = function () {
var that = this;
$.each(this.$header.find('th'), function (i, th) { laydate.render({
var sortName = that.header.sortNames[i]; elem: '#endTime',
$(th).find('.sortable').removeClass('desc asc').addClass((sortName || $(th).data('field')) === that.options.sortName ? that.options.sortOrder : 'both'); theme: '#009efb',
}); max: Feng.currentDate()
}; });
} });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment