<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="${pageContext.request.contextPath}/static/layui/css/layui.css" rel="stylesheet">
<script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<script src="${pageContext.request.contextPath}/static/js/jquery.min.js"></script>
</head>
<body>
	<br>
	<form class="layui-form" action="">
		<div class="layui-inline">
			<label class="layui-form-label">说明</label>
			<div class="layui-input-inline">
				<input type="text" id="remark" name="remark" placeholder="请输入要查询信息"
					autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">登录状态</label>
			<div class="layui-input-inline edge">
				<select name="status" id="status">
					<option value=""></option>
					<option value="正常">正常</option>
					<option value="警告">警告</option>
					<option value="异常">异常</option>
				</select>
			</div>
		</div>
		<div class="layui-inline">
			<div class="layui-input-inline">
				<button class="layui-btn" id="searchBtn" lay-submit
					lay-filter="formDemo" data-type="reload" style="margin-left: 15px">
					<i class="layui-icon layui-icon-search"></i> 查询
				</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
	<br>
	<table class="layui-hide" id="loginLogTable"></table>
	<script>
	layui.use([ 'table', 'form','util','laydate'], function() {
		var $ = layui.jquery,
		table = layui.table,
		form = layui.form,
		util = layui.util,
		laydate = layui.laydate;
		
		//生成表格
		table.render({
			elem : '#loginLogTable',
			url : '${pageContext.request.contextPath}/getLoginLogList',
			//开启分页
			page : {
				layout:['count','prev','page','next', 'skip','limit']
			},
			limits	: [10,30,50,80,100,999],
			id : 'loginLogAll',
			where : {
				remark : '',
				status : ''
			},
			/* request : {
				'limitName' : 'pageSize' //分页每页条数默认字段改为pageSize
			}, */
			cellMinWidth : 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
			cols : [ [ {
				type : 'numbers',
				width : 50,
				title : '序号',
				fixed : "left"
			},{
				field : 'remark',
				width :  650,
				title : '登录详情'
			},{
				field : 'status',
				width :  150,
				algin : 'center',
				title : '登录状态',
				templet : function(d) {
					if(d.status == "异常"){
						return '<a class=""style="color:#ed2a4a">'+d.status+'</a>';
					}else if(d.status == "警告"){
						return '<a class=""style="color:green">'+d.status+'</a>';
					}else{
						return d.status;
					}
				} 
			}] ],
			parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
				return {
					"code" 	: 0, //解析接口状态
					"msg" 	: "", //解析提示文本
					"count"	: res.total,//解析数据长度
					"data" 	: res.list//解析数据列表
				};
			}
		});
		
		//点击查询按钮，重载表格
		$('#searchBtn').on('click', function() {
			table.reload('loginLogAll', {
				method : 'post',
				where : {
					remark : $("#remark").val(),
					status : $("#status").val()
				},
				page : {
					curr : 1
				}
			});
			return false;
		});
	})
	</script>
</body>
</html>