<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="操作日志" libs=["table","bootstrapSelect"]/>
<div class="container-div">
	<div class="row">
	<div class="col-sm-12 search-collapse">
	<@f.form id="operlog-form">
	<div class="select-list">
		<ul>
			<li>
				<label>系统模块： </label><input type="text" class="form-control" name="title"/>
			</li>
			<li>
				<label>操作人员： </label><input type="text" class="form-control" name="operName"/>
			</li>
			<li class="select-selectpicker">
				<label>操作类型： </label>
				<@f.select name="businessTypes" multiple = true class="selectpicker" dictType="sys_oper_type" required=true/>
			</li>
			<li>
				<label>操作状态：</label>
				<@f.select name="status" blankValue="" blankLabel="所有" dictType="sys_common_status" />
			</li>
			<li class="select-time">
				<label>操作时间： </label>
				<@f.input id="startTime" name="beginTime"/>
				<span>-</span>
				<@f.input 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:log: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:log: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 detailFlag = "${permission.hasPermi('sys:log:detail')}";
	var datas = ${dict.getDictListJson('sys_oper_type')};
	var prefix = baseURL + "sys/operlog";

	$(function() {
		var options = {
			url: prefix + "/list",
			cleanUrl: prefix + "/clean",
			detailUrl: prefix + "/detail/{id}",
			delUrl: prefix + "/del",
			sortName: "operTime",
			sortOrder: "desc",
			uniqueId: "id", /* 唯一ID */
			modalName: "操作日志",
			escape: true,
			showPageGo: true,
			columns: [
			{
				title: "<@ctx.i18n text = "序号"/>", width: 10, formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
			},
			{
				field: 'title',
				title: '系统模块'
			},
			{
				field: 'businessType',
				title: '操作类型',
				align: 'center',
				formatter: function(value, row, index) {
					return $.table.selectDictLabel(datas, value);
				}
			},
			{
				field: 'operName',
				title: '操作人员',
				sortable: true
			},
			{
				field: 'compName',
				title: '公司名称'
			},
			{
				field: 'operIp',
				title: '主机'
			},
			{
				field: 'operLocation',
				title: '操作地点',
				formatter: function (value, row, index) {
					return $.table.tooltip(value,10);
				}
			},
			{
				field: 'status',
				title: '操作状态',
				align: 'center',
				formatter: function(value, row, index) {
					if (value == 0) {
						return '<span class="badge badge-primary">成功</span>';
					} else if (value == 1) {
						return '<span class="badge badge-danger">失败</span>';
					}
				}
			},
			{
				field: 'operTime',
				title: '操作时间',
				sortable: true
			},
			{
				field: 'time',
				title: '响应时间',
				formatter: function(value, row, index) {
						return value+'毫秒';
				}
			},
			{
				title:"<@ctx.i18n text = "操作"/>",
				align: 'center',
				formatter: function(value, row, index) {
					var actions = [];
					actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="opt.operate.detail(\'' + row.id + '\')"><i class="fa fa-search"></i>详细</a>');
					return actions.join('');
				}
			}]
		};
		$.table.init(options);
	});

	function searchPre() {
		var data = {};
		data.businessTypes = opt.common.join($('#businessTypes').selectpicker('val'));
		$.table.search('bootstrap-table','operlog-form', data);
	}

	function resetPre() {
		$("#businessTypes").selectpicker('refresh');
		$.table.search('bootstrap-table','operlog-form', {});
	}
</script>
</@footer>
</@pageTheme>