forked from kidgrow-microservices-platform

zhaoxiaohao
2020-04-10 cba67280f021ea732581829c472a703a1e303824
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<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="sysLog-search-key">
                <option value="_all">全文搜索</option>
                <option value="message">日志信息</option>
                <option value="logLevel">日志级别</option>
                <option value="appName">应用名</option>
                <option value="classname">类名</option>
                <option value="traceId">链路追踪id</option>
            </select>&emsp;
            <input id="sysLog-search-value" class="layui-input search-input" style="width: 300px" type="text" placeholder="输入关键字"/>&emsp;
            <button id="sysLog-btn-search" class="layui-btn icon-btn"><i class="layui-icon">&#xe615;</i>搜索</button>
        </div>
 
        <table class="layui-table" id="sysLog-table" lay-filter="sysLog-table"></table>
    </div>
</div>
 
<script>
    layui.use(['form', 'table', 'util', 'config', 'admin', 'upload'], function () {
        let table = layui.table;
        let config = layui.config;
        let util = layui.util;
 
        // 渲染表格
        table.render({
            elem: '#sysLog-table',
            url: config.base_server + 'api-log/sysLog',
            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: 'message', sort: true, title: '日志信息', width: 350},
                {field: 'logLevel', sort: true, title: '日志级别', width: 100},
                {field: 'appName', sort: true, title: '应用名', width: 120},
                {field: 'serverIp', sort: true, title: '服务ip', width: 130},
                {field: 'serverPort', sort: true, title: '服务端口', width: 100},
                {field: 'threadName', sort: true, title: '线程名', width: 150},
                {field: 'classname', sort: true, title: '类名', width: 250},
                {field: 'traceId', sort: true, title: '链路追踪id', width: 200}
            ]]
        });
 
        // 搜索按钮点击事件
        $('#sysLog-btn-search').click(function () {
            let key = $('#sysLog-search-key').val();
            let value = $('#sysLog-search-value').val();
            if (key != '_all' && value) {
                value = key + ':' + value;
            }
            table.reload('sysLog-table', {where: {queryStr: value}});
        });
    });
</script>