<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <base th:href="${#request.getContextPath() + '/'} ">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
    <link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;">
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="test-table-reload-btn" style="margin-bottom: 10px;">
                        <div class="layui-inline">
                            <input type="text" id="keywords" class="layui-input search-item" placeholder="输入名称">
                        </div>
                        <div class="layui-btn-group">
                            <button type="button" id="search" class="layui-btn layui-btn-sm">
                                <i class="fa fa-lg fa-search"></i> 搜索
                            </button>
                        </div>
                    </div>
                    <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
        base: 'assets/layuiadmin/'
    }).extend({
        index: 'lib/index'
    }).use(['index', 'table', 'laydate', 'ztree'], function() {
        var $ = layui.$;
        var $win = $(window);
        var table = layui.table;
        var admin = layui.admin;
        var laydate = layui.laydate;
        var parentId = top.restAjax.params(window.location.href).parentId;

        // 初始化表格
        function initTable() {
            table.render({
                elem: '#dataTable',
                id: 'dataTable',
                url: top.restAjax.path('api/mongo/data/listpage?parentId={parentId}', [parentId]),
                width: admin.screen() > 1 ? '100%' : '',
                height: $win.height() - 60,
                limit: 20,
                limits: [20, 40, 60, 80, 100, 200],
                toolbar: '#headerToolBar',
                request: {
                    pageName: 'page',
                    limitName: 'rows'
                },
                cols: [
                    [
                        {type:'checkbox', fixed: 'left'},
                        {field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
                        {field:'dataId', width:200, title: '字典ID', align:'center',},
                        {field:'dataName', width:160, title: '字典名称', align:'center',},
                        {field:'dataSummary', width:160, title: '字典说明', align:'center',},
                        {field:'dataCode', width:160, title: '字典编码', align:'center',},
                        {field:'dataSort', width:100, title: '字典排序', align:'center',},
                    ]
                ],
                page: true,
                parseData: function(data) {
                    return {
                        'code': 0,
                        'msg': '',
                        'count': data.total,
                        'data': data.rows
                    };
                }
            });
        }
        // 重载表格
        function reloadTable() {
            table.reload('dataTable', {
                where: {
                    keywords: $('#keywords').val(),
                },
                height: $win.height() - 60,
            });
        }
        // 初始化日期
        function initDate() {}
        initTable();
        initDate();

        // 事件 - 页面变化
        $win.on('resize', function() {
            reloadTable();
        });
        // 事件 - 搜索
        $(document).on('click', '#search', function() {
            reloadTable();
        });
    });
</script>
</body>
</html>