<title>日志列表</title>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>采集管理</cite></a>
        <a><cite>采集日志</cite></a>
        <a><cite>日志列表</cite></a>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-card">
        <div id="layui-search" class="layui-form layui-form layui-card-header layuiadmin-card-header-auto"
             style="display: none">
            <div class="layui-form-item">
                <div id="layui-search-fields" class="layui-search-fields" style="display: inline-block">
                </div>
                <div id="layui-search-button" class="layui-inline">
                    <button class="layui-btn layuiadmin-btn" lay-submit lay-filter="LAY-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <div style="padding-bottom: 10px;" id="layui-top-button">
            </div>
            <table id="LAY-curd-table" lay-filter="LAY-curd-table"></table>
            <script type="text/html" id="table-curd-list">
            </script>
        </div>
    </div>
</div>
<script>
    var config = {
            api: {
                batch: '/manage/collect/logcron/batch.json',
                list: '/manage/collect/logcron/list.json',
                del: '/manage/collect/logcron/del.json',
                clear: '/manage/collect/logcron/clear.json',
            },
            topButton: {
                del: {},
                clear: {
                    text: '清除日志',
                    action: function () {
                        layui.layer.confirm('确定清除日志吗？', function (index) {
                            layui.admin.req({
                                url: config.api.clear,
                                method: 'POST',
                                success: function (res) {
                                    layui.layer.msg('清除成功');
                                    layui.table.reload('LAY-curd-table');
                                }
                            })
                        });
                    }
                },
            },
            actionButton: {
                cron: {
                    text: '查看',
                    icon: 'layui-icon layui-icon-engine',
                    action: function (obj) {
                        var i = layui.layer.open({
                            type: 2,
                            title: '查看日志',
                            shadeClose: false,
                            shade: false,
                            maxmin: true,
                            area: ['893px', '600px'],
                            content: '/manage/collect/log/detail.html?id=' + obj.data.id + '&access_token=' + encodeURIComponent(layui.data('layuiAdmin').access_token),
                            btn: ['关闭', '刷新'],
                            btn2: function (index, layno) {
                                layer.iframeSrc(index, 'javascript:location.reload();scroll(0,9999999);');
                                return false;
                            }
                        });
                        console.log(i);
                    }
                },
                del: {},
            },
            table: {
                cols: [[
                    {type: 'checkbox', fixed: 'left'},
                    {field: 'datetime', title: '创建时间', width: 165},
                    {field: 'type', title: '任务类型', width: 100, align: 'center'},
                    {field: 'name', title: '任务名称'},
                    {field: 'param', title: '执行参数'},
                    {field: 'status', title: '状态', width: 100, align: 'center'},
                    {title: '操作', width: 160, align: 'center', fixed: 'right', toolbar: '#table-curd-list'}
                ]]
            }
        }
    ;
    layui.use('curd/list', layui.factory('curd/list'));
</script>