extends /admin/include/layout.pug
block content
    .row: .col-lg-12
        h1.site-h1(style='background-color:#FFFFFF;')
            | 元数据列表 (#{metadataList.totalElements})
            span(style='float:right;')
                button.layui-btn.layui-btn-small.green(href='/admin/metadata/imptb.html', data-toggle='ajax', data-width='550', data-title='创建新字典项')
                    | 导入元数据
                a.layui-btn.layui-btn-small.layui-btn-danger#batdel(href='javascript:void(0)', data-toggle='tip', data-title='删除数据表项同时会删除数据表元数据下的所有内容，请确认是否继续操作”？', title='删除数据表')
                    | 批量删除
        .row(style='padding:5px;')
            .col-lg-12
                table.layui-table(lay-skin='line')
                    colgroup
                        col(width='1%')
                        col(width='25%')
                        col(width='15%')
                        col(width='10%')
                        col(width='24%')
                        col(width='15%')
                        col
                    thead
                        tr
                            th
                                input#all(type='checkbox', onclick='$(".ids").prop("checked" , $(this).prop("checked"));')
                            th 中文名
                            th 表名
                            th 类型
                            th ES数据
                            th 创建时间
                            th(style='white-space:nowrap;', nowrap) 操作
                    tbody
                        if size(metadataList.content) > 0
                            for table in metadataList.content
                                tr
                                    td(style="width:1%;"): input(type="checkbox", class="ids", name="ids", value=table.id)
                                    td: a(href="/admin/metadata/table.html?id=" + table.id)= table.name
                                    td= table.tablename
                                    td= (table.tabletype == "1") ? '数据表' : 'SQL'
                                    if table.fromdb == true
                                        td
                                            i.layui-icon(style="color:#19a55d;") &#xe618;
                                            span= uKeFuDic[table.listblocktemplet].name
                                            span= uKeFuDic[table.previewtemplet].name
                                    else
                                        td
                                    if table.createtime
                                        td= pugHelper.formatDate('yyyy-MM-dd HH:mm:ss', table.createtime)
                                    else
                                        td
                                    td(style="white-space:nowrap;width:1%;", nowrap="nowrap")
                                        a(href="/admin/metadata/edit.html?id=" + table.id + "&p=" + (metadataList.number + 1), data-width="550", data-height="320", data-toggle="ajax", title="编辑" + table.name)
                                            i.layui-icon &#xe642;
                                            span 编辑
                                        a(href="/admin/metadata/delete.html?id=" + table.id + "&p=" + (metadataList.number + 1), data-toggle="tip" data-title="删除数据表项同时会删除数据表元数据下的所有内容，请确认是否删除数据表“" + table.name + "”？" title="删除" + table.name)
                                            i.layui-icon(style="color:red;") &#x1006;
                                            span 删除
        .row(style='padding:5px;')
            .col-lg-12#page(style='text-align:center;')
    script.
        $(document).ready(function () {
            $('#batdel').click(function () {
                var ids = "";
                $('.ids').each(function () {
                    if ($(this).prop("checked")) {
                        if (ids != "") {
                            ids += "&";
                        }
                        ids += "ids=" + $(this).val();
                    }
                });
                $('#batdel').attr('href', '/admin/metadata/batdelete.html?' + ids);

            });

        });
        layui.use(['laypage', 'layer'], function () {
            var laypage = layui.laypage
                , layer = layui.layer;

            var msg = "#{msg}";
            if (msg) top.layer.msg(msg);

            laypage({
                cont: 'page'
                // ,pages: <#if metadataList??>${metadataList.totalPages}<#else>0</#if> //总页数
                // ,curr:<#if metadataList??>${metadataList.number+1}<#else>0</#if>
                , groups: 5 //连续显示分页数
                , jump: function (data, first) {
                    if (!first) {
                        location.href = "/admin/metadata/index.html?p=" + data.curr;
                    }
                }
            });
        });

