<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="登陆日志列表" libs=["table"]/>
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
		<@f.form id="logininfor-form">
		<div class="select-list">
			<ul>
				<li>
					<label>登录地址：</label><input type="text" class="form-control" name="ipaddr"/>
				</li>
				<#--用户是否是最大管理员-->
				<#if permission.isRole("ADMIN")>
					<li>
						<label>登录名称：</label><input type="text" class="form-control" name="username"/>
					</li>
				</#if>
				<li>
					<label><@ctx.i18n text = "机构查询"/></label>：
					<div class="control-div width-150">
						<@f.treeselect name="deptId" boxTitle="请选择归属机构" url="sys/comp/treeData"
						expandLevel=true
						placeholder="请选择上级机构"/>
					</div>
				</li>
				<li>
					<label>登录状态：</label>
					<select name="status" class="form-control">
						<option value="">所有</option>
						<#list dict.getType('sys_login_status')>
							<#items as d>
								<#if d.status =='0' >
									<option value="${d.dictValue}" text="${d.dictLabel}">${d.dictLabel}</option>
								</#if>
							</#items>
						</#list>
					</select>
				</li>
				<li class="select-time">
					<label>登录时间： </label>
					<@f.input id="startTime" name="beginTime"/>
					<span>-</span>
					<@f.input id="endTime" name="endTime"/>
				</li>
				<li>
					<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;<@ctx.i18n text = "查询"/></a>
					<a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i>&nbsp;<@ctx.i18n text = "重置"/></a>
				</li>
			</ul>
		</div>
		</@f.form>
		</div>
		<@table id="bootstrap-table">
			<@shiro.hasPermission name="sys:logininfo:del">
				<a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()">
					<i class="fa fa-remove"></i> 删除
				</a>
			</@shiro.hasPermission>
			<@shiro.hasPermission name="sys:logininfo:clean">
				<a class="btn btn-danger" onclick="opt.operate.clean()">
					<i class="fa fa-trash"></i> 清空
				</a>
			</@shiro.hasPermission>
		</@table>
	</div>
</div>
<@footer>
<script>
	<#--var datas = ${dict.getDictListJson('sys_common_status')};-->
	var prefix = baseURL + "sys/logininfo";
	$(function() {
		var options = {
			url: prefix + "/list",
			cleanUrl: prefix + "/clean",
			delUrl: prefix + "/del",
			sortName: "loginTime",
			uniqueId: "id", /* 唯一ID */
			sortOrder: "desc",
			modalName: "登录日志",
			escape: true,
			columns: [
				{
                    title: "<@ctx.i18n text = "序号"/>", width: 10, formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
				{field: 'username', title: '登录名称', sortable: true},
				{field: 'ipaddr', title: '登录地址'},
				{field: 'loginLocation', title: '登录地点',formatter: function (value, row, index) {
						return $.table.tooltip(value,10);}},
				{field: 'compName', title: "<@ctx.i18n text = "归属公司"/>",formatter: function (value, row, index) {
						return $.table.tooltip(value,5);}
				},
				{field: 'browser', title: '浏览器'},
				{field: 'os', title: '操作系统'},
				{field: 'status', title: '登录状态', align: 'center', formatter: function(value, row, index) {
						if(value == '00000'){
							return '<span class="label label-primary">成功</span>';
						}else{
							return '<span class="label label-danger">'+value+'</span>';
						}
					}
				},
				{field: 'msg', title: '操作信息', formatter: function (value, row, index) {
						return $.i18n.prop(value);
					}
				},
				{field: 'loginTime', title: '登录时间', sortable: true}
			]
		};
		$.table.init(options);
	});

	function treeCallback(id, event, index, layero, nodes) {
		if(id == "deptId"){
			if(event == "ok"){
				/* 点击确认按钮直接刷新表格*/
				$.table.search();
			}
		}
	}
	function unlock() {
		opt.operate.post(prefix + "/unlock?loginName=" + $.table.selectColumns("loginName"));
	}
</script>
</@footer>
</@pageTheme>

