<div class="layui-card">
|
<div class="layui-card-header">
|
<h2 class="header-title">慢查询日志</h2>
|
<span class="layui-breadcrumb pull-right">
|
<a href="#!console">首页</a>
|
<a><cite>慢查询日志</cite></a>
|
</span>
|
</div>
|
<div class="layui-card-body">
|
<div class="layui-form toolbar">
|
搜索:
|
<select id="slowQueryLog-search-key">
|
<option value="_all">全文搜索</option>
|
<option value="query_str">查询语句</option>
|
</select> 
|
<input id="slowQueryLog-search-value" class="layui-input search-input" style="width: 300px" type="text" placeholder="输入关键字"/> 
|
<button id="slowQueryLog-btn-search" class="layui-btn icon-btn"><i class="layui-icon"></i>搜索</button>
|
</div>
|
|
<table class="layui-table" id="slowQueryLog-table" lay-filter="slowQueryLog-table"></table>
|
</div>
|
</div>
|
<script>
|
layui.use(['form', 'table', 'util', 'config', 'admin'], function () {
|
let table = layui.table;
|
let config = layui.config;
|
let util = layui.util;
|
|
// 渲染表格
|
table.render({
|
elem: '#slowQueryLog-table',
|
url: config.base_server + 'api-log/slowQueryLog',
|
method: 'GET',
|
headers:{'Authorization': 'Bearer ' + config.getToken().access_token},
|
page: true,
|
cols: [[
|
{type: 'numbers'},
|
{
|
field: 'timestamp', width: 200, sort: true, templet: function (d) {
|
return util.toDateString(d.timestamp, 'yyyy-MM-dd HH:mm:ss');
|
}, title: '日志时间'
|
},
|
{field: 'query_str', sort: true, title: '查询语句', width: 410},
|
{field: 'query_time', sort: true, title: '查询时间(ms)', width: 120},
|
{field: 'lock_time', sort: true, title: '锁等待时间(ms)', width: 140},
|
{field: 'rows_sent', sort: true, title: '返回行数', width: 110},
|
{field: 'rows_examined', sort: true, title: '优化器扫描行数', width: 140}
|
]]
|
});
|
|
// 搜索按钮点击事件
|
$('#slowQueryLog-btn-search').click(function () {
|
let key = $('#slowQueryLog-search-key').val();
|
let value = $('#slowQueryLog-search-value').val();
|
if (key != '_all' && value) {
|
value = key + ':' + value;
|
}
|
table.reload('slowQueryLog-table', {where: {queryStr: value}});
|
});
|
});
|
</script>
|