ok-admin/pages/system/system-log.html

154 lines
5.5 KiB
HTML
Raw Normal View History

2019-04-14 09:44:03 +00:00
<!DOCTYPE html>
2019-05-13 08:48:38 +00:00
<html>
2019-04-14 09:44:03 +00:00
<head>
<meta charset="UTF-8">
<title>系统日志</title>
2019-05-13 08:48:38 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../../css/okadmin.css">
2019-04-14 09:44:03 +00:00
</head>
<body>
2019-05-13 08:48:38 +00:00
<div class="ok-body">
<!--面包屑导航区域-->
<div class="ok-body-breadcrumb">
<span class="layui-breadcrumb">
<a><cite>首页</cite></a>
<a><cite>系统管理</cite></a>
<a><cite>系统日志</cite></a>
</span>
<a class="layui-btn layui-btn-sm" href="javascript:location.replace(location.href);" title="刷新">
<i class="layui-icon layui-icon-refresh"></i>
</a>
</div>
<!--模糊搜索区域-->
<div class="layui-row">
<form class="layui-form layui-col-md12 ok-search">
2019-05-15 15:37:51 +00:00
<input class="layui-input" placeholder="开始日期" autocomplete="off" id="startTime" name="startTime">
<input class="layui-input" placeholder="截止日期" autocomplete="off" id="endTime" name="endTime">
<input class="layui-input" placeholder="请输入地址" autocomplete="off" name="url">
2019-05-13 08:48:38 +00:00
<button class="layui-btn" lay-submit="" lay-filter="search">
<i class="layui-icon layui-icon-search"></i>
</button>
</form>
</div>
<!--数据表格-->
<table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
</div>
<!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script>
layui.config({
2019-05-17 07:42:31 +00:00
base: "../../lib/okplugins/"
2019-05-13 08:48:38 +00:00
}).extend({
2019-05-17 07:42:31 +00:00
okLayer: "okLayer",
okUtils: "okUtils"
2019-05-15 15:37:51 +00:00
}).use(["element", "table", "form", "laydate", "okLayer", "okUtils"], function () {
2019-05-13 08:48:38 +00:00
var table = layui.table;
var form = layui.form;
var laydate = layui.laydate;
var okLayer = layui.okLayer;
var okUtils = layui.okUtils;
laydate.render({elem: "#startTime", type: "datetime"});
laydate.render({elem: "#endTime", type: "datetime"});
2019-05-15 15:37:51 +00:00
var logTable = table.render({
2019-05-13 08:48:38 +00:00
elem: "#tableId",
url: "../../data/log.json",
limit: 10,
page: true,
toolbar: true,
2019-05-15 15:37:51 +00:00
toolbar: "#toolbarTpl",
2019-05-13 08:48:38 +00:00
cols: [[
{type: "checkbox"},
{field: "id", title: "ID", width: 80, sort: true},
{field: "url", title: "请求地址", width: 230},
{field: "method", title: "操作方式", width: 100},
{field: "ip", title: "操作IP", width: 100},
{field: "timeConsuming", title: "耗时", width: 100},
{field: "status", title: "状态", width: 100, templet: "#statusTpl"},
{field: "operator", title: "操作人", width: 200},
{field: "operatingTime", title: "操作时间", width: 200},
{title: "操作", width: 200, align: 'center', templet: "#operationTpl"}
]],
done: function (res, curr, count) {
2019-05-15 15:37:51 +00:00
console.log(res, curr, count);
2019-05-13 08:48:38 +00:00
}
});
form.on("submit(search)", function () {
2019-05-15 15:37:51 +00:00
logTable.reload({
where: data.field,
page: {curr: 1}
});
2019-05-13 08:48:38 +00:00
return false;
});
2019-05-15 15:37:51 +00:00
table.on("toolbar(tableFilter)", function (obj) {
switch (obj.event) {
case "batchDel":
batchDel();
break;
}
});
2019-05-13 08:48:38 +00:00
table.on("tool(tableFilter)", function (obj) {
var data = obj.data;
2019-05-15 15:37:51 +00:00
switch (obj.event) {
case "del":
del(data.id);
break;
2019-05-16 01:06:48 +00:00
case "detail":
detail(data.id);
break;
2019-05-13 08:48:38 +00:00
}
});
2019-05-15 15:37:51 +00:00
function batchDel () {
2019-05-13 08:48:38 +00:00
okLayer.confirm("确定要批量删除吗?", function (index) {
layer.close(index);
2019-05-15 15:37:51 +00:00
var idsStr = okUtils.table.batchCheck(table);
2019-05-13 08:48:38 +00:00
if (idsStr) {
2019-05-15 15:37:51 +00:00
okUtils.ajax("/log/batchDel", "post", {idsStr: idsStr}).done(function (response) {
2019-05-13 08:48:38 +00:00
console.log(response)
2019-05-15 15:37:51 +00:00
okUtils.table.successMsg("批量删除成功");
2019-05-13 08:48:38 +00:00
}).fail(function (error) {
console.log(error)
});
}
});
2019-05-15 15:37:51 +00:00
}
2019-05-16 01:06:48 +00:00
function detail (id) {
okLayer.open("日志详情", "system-log-detail.html?id=" + id, "90%", "90%")
}
2019-05-13 08:48:38 +00:00
2019-05-15 15:37:51 +00:00
function del (id) {
okLayer.confirm("确定要删除吗?", function () {
okUtils.ajax("/log/batchDel", "post", {idsStr: id}).done(function (response) {
console.log(response)
okUtils.table.successMsg("删除成功");
}).fail(function (error) {
console.log(error)
});
})
}
2019-05-13 08:48:38 +00:00
})
</script>
2019-05-15 15:37:51 +00:00
<!-- 头工具栏模板 -->
<script type="text/html" id="toolbarTpl">
<div class="layui-btn-container">
<div class="layui-inline" lay-event="batchDel"><i class="layui-icon layui-icon-delete"></i></div>
</div>
</script>
2019-05-13 08:48:38 +00:00
<!--模板-->
<script type="text/html" id="statusTpl">
{{ d.role == 0 ? '正常' : '异常'}}
</script>
2019-05-15 15:37:51 +00:00
<!-- 行工具栏模板 -->
2019-05-13 08:48:38 +00:00
<script type="text/html" id="operationTpl">
2019-05-16 01:06:48 +00:00
<a href="javascript:;" title="详情" lay-event="detail"><i class="layui-icon layui-icon-tips"></i></a>
<a href="javascript:;" title="删除" lay-event="del"><i class="layui-icon layui-icon-delete"></i></a>
2019-05-13 08:48:38 +00:00
</script>
2019-04-14 09:44:03 +00:00
</body>
</html>