@{ Layout = "~/Views/Shared/_Layout.cshtml"; }

<section class="content-header"></section>

<section class="content">
    <div class="container-fluid">
        <!-- SELECT2 EXAMPLE -->
        <div class="card card-default">
            <div class="card-header">
                <h3 class="card-title">已有插件</h3>

                <div class="card-tools">
                    <button type="button" class="btn btn-tool" data-card-widget="collapse">
                        <i class="fas fa-minus"></i>
                    </button>
                    <button type="button" class="btn btn-tool" data-card-widget="remove">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
            </div>
            <!-- /.card-header -->
            <div class="card-body">

                <div class="row">
                    <div class="form-group row col-12 col-md-3 col-xl-3">
                        <button type="button" class="btn btn-primary " onclick="getV7List()">更新列表</button>
                    </div>

                </div>
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>key</th>
                            <th>名称</th>
                            <th>说明</th>
                        </tr>
                    </thead>
                    <tbody id="tbody">
                    </tbody>
                </table>


            </div>
            <!-- /.card-body -->
            <div class="card-footer" id="pager">

            </div>
        </div>
        <!-- /.card -->



    </div>
    <!-- /.container-fluid -->
</section>


<script>
    $(function () {
        getList();
    })
    function getList() {
        $('#pager').sjAjaxPager({
            url: "/DataList/getJsonDataV7List",
            pageSize: 10,
            searchParam: {
                action: "getJsonDataList"
            },
            success: function (data) {
                if (data.ErrorCode == 1) {
                    var sHtml = '';
                    for (var i = 0; i < data.Data.length; i++) {
                        sHtml += "<tr>";
                        sHtml += "<td>" + data.Data[i]['name'] + "</td>";
                        sHtml += "<td>" + data.Data[i]['title'] + "</td>";
                        sHtml += "<td title=\"" + data.Data[i]['ps']+ "\">" + getText(data.Data[i]['ps'],20) + "</td>";
                        sHtml += "</tr>";
                    }
                    $('#tbody').html(sHtml)
                }
            },
            complete: function () {
            }
        });
    }
    var isOk = true;
    function getV7List() {

        if (isOk) {
            isOk = false;
            $.ajax({
                url: "/DataList/getV7List",
                type: 'post',
                dataType: "json",
                success: function (msg) {
                    alert(msg.Msg)
                    if (msg.Code == 1) {
                        getList();
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {

                },
                complete: function () {
                    isOk = true;
                }
            });
        }
    }
    function getText(str, len) {
        if (str.length > len) {
            return str.substring(0, len);
        }
        return str;
    }

    //时间  格式化
    function dateFtt(fmt, date) { //author: meizz
        date = new Date(date);
        var o = {
            "M+": date.getMonth() + 1,                 //月份
            "d+": date.getDate(),                    //日
            "h+": date.getHours(),                   //小时
            "m+": date.getMinutes(),                 //分
            "s+": date.getSeconds(),                 //秒
            "q+": Math.floor((date.getMonth() + 3) / 3), //季度
            "S": date.getMilliseconds()             //毫秒
        };
        if (/(y+)/.test(fmt))
            fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt))
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }
</script>

