<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登录日志</title>
</head>
<style type="text/css">
	.loginLogHeader {
		padding: 0px 20px;
	}
	.loginLogHeader {
		padding-bottom:0
	}
	.loginLogHeader [class^="col"] {
		padding-left:0;
		padding-right:0
	}
	.loginLogQuery {
		background-color:#3ebee6;
		color:white;
		border-color:#3ebee6;
		text-shadow:none;
	}
	.loginLogQuery:hover {
		background-color:#3ebee6;
		color:white;
		border-color:#3ebee6;
		text-shadow:none
	}
	.loginLogHeader .form-control {
		width:95%
	}
</style>
<body>
	<div class="base-extend">
		<ol class="breadcrumb">
		  	<li>系统管理</li>
		  	<li>登录日志</li>
		</ol>
		<div class="loginLogHeader" style="padding:0 !important;">
			<div class="listBackBox">
				<div style="padding: 0 0.2rem;min-width: 10.35rem;">
					<div class="row" style="padding-left:0.1rem;padding-right:0.1rem">
						<button id="refresh" class="btn btn-white btn-info" style="float:left">刷新</button>
						<div style="float:right">
							<div style="float:right">
								<button id="query" class="btn btn-white btn-info colorbtn loginLogQuery" style="width:100%">查询</button>
							</div>
							<div style="float:right">
								<input maxlength="30" class="form-control" id="userName" placeholder="请输入登录名或姓名" />
							</div>
							<div style="float:right;width:1.5rem;">
								<select class="form-control eventType">
									<option value="">请选择事件类型</option>
									<option th:each="dict,dictStat:${dictList}" th:value="${dict.id}" th:text="${dict.name}"></option>
								</select>
							</div>
							<div style="float:right">
								<input type="text" class="form-control form-date" id="loginTime" placeholder="请选择日期" readonly>
							</div>
						</div>
					</div>
				</div>
				<div class="weekmeeting-detail col-xs-12 businessTable" style="padding:0.05rem 0.2rem 0 0.2rem;float:none;">
					<table id="loginLogList" style="width: 100%;"></table>
					<div id="loginLogListPage"></div>
				</div>
			</div>
		</div>
	</div>
</body>
	<script type="text/javascript">
		//查看按钮
		function viewPaymentDetail(id){
			var localdata={};
			localdata.search=$("#userName").val();
			localdata.detailId=id;
			localStorage.setItem('localdata',JSON.stringify(localdata));
			mylistpage = $('#contractList').getGridParam('page');
			$(".yk_rightcontent").load('/operationLog/logPage?logInId='+id)
		}
		$(function(){
			$(".form-date").datetimepicker({
			    language:  "zh-CN",
			    weekStart: 1,
			    todayBtn:  0,
			    autoclose: 1,
			    todayHighlight: 0,
			    startView: 2,
			    minView: 2,
			    forceParse: 0,
			    format: "yyyy-mm-dd"
			});
			function loadData(){
				$('#loginLogList').setGridParam({
					mtype:'GET',
					url : '/loginLog/do_list',
					datatype : 'json',
					postData: {
						'userName':$('#userName').val(),
						'logTypeId':$('.eventType').val(),
						'loginTime':$('#loginTime').val()
						},
					page : 1
				});
				$('#loginLogList').trigger('reloadGrid');
			}

			function operateLoginLog(cellValue,options,rowObject){
				var btnstr = '';
				if(rowObject.logType.code == 'userLogin') {
					btnstr += '<p><span>查看</span><i class="operateIconfont operateIcon-chakan" onclick="viewPaymentDetail('+rowObject.id+')"></i></p>';
				}
				return '<div class="operateIcon noHover">'+btnstr+'</div>';
			};

			var localdata=jQuery.parseJSON(localStorage.getItem("localdata"));
			var fastSearch='';
			if( localdata ){
				fastSearch=localdata.search;
			}
			
			sxUtil.jqGrid('#loginLogList',{
				colNames:['日志id','序号','登录名','姓名','事件','操作'],
				colModel:[
					{name: 'id', label: '日志ID', hidedlg:true, hidden:true,sortable:false,title:false},
					{name: 'orderNumber', label: '序号', width:70,sortable:false,title:false},
					{name: 'loginName', label: '登录名',sortable:false,align:'center',title:false},
					{name: 'name', label: '姓名',sortable:false,align:'center',title:false},
					{name: 'remark', label: '事件',sortable:false,align:'left',width:350,title:false},
					{name: 'operate', label: '操作',sortable:false,align:'left',width:100,title:false,formatter:operateLoginLog}
				], 
				height:'auto',
				mtype:'GET',
				url : '/loginLog/do_list',
				pager : "#loginLogListPage",
				multiselect: false,
				rownumbers:false,
				postData : {
					'userName':$('#userName').val(),
					'logTypeId':$('#logTypeId').data('logTypeId'),
					'loginTime':$('#loginTime').val()
				},
				loadError:function(){
					new $.zui.Messager('列表加载失败', {
					    type: 'warning',
					    time:1500
					}).show();
				},
				onPaging:function(pgButton){
					console.log(pgButton)
				}
			},true);
			
			//刷新
			$('#refresh').click(function(){
				$("#userName").val('');
				$(".eventType").val('');
				$("#loginTime").val('');
				$('#loginLogList').jqGrid('setGridParam',{ 
		            mtype:'GET',
		            url : '/loginLog/do_list',
		            postData: {
						'userName':'',
						'logTypeId':'',
						'loginTime':$('#loginTime').val()
						},
		            page:1 
		        }).trigger('reloadGrid'); //重新载入
			});
			$(".loginLogQuery").click(function(){
				loadData();
			})
		})
	</script>
</html>