@{ 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">404列表</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="form-group">
                 

                </div>
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>路径</th>
                            <th>状态</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/getDownloadFileList",
            pageSize: 10,
            searchParam: {
                action: "getDownloadFileList"
            },
            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]['Path'] + "</td>";
                        sHtml += "<td>" + data.Data[i]['Status'] + "</td>";
                        sHtml += "<td>" + dateFtt('yyyy-MM-dd hh:mm:ss', data.Data[i]['SysAddTime']) + "</td>";
                        if (data.Data[i]['Status'] == 0) {
                            sHtml += '<td><button type="button" class="btn btn-primary " onclick="updDownloadFile(' + data.Data[i]['Id'] + ')">已检查</button></td>';
                        } else {
                            sHtml += '<td></td>';
                        }

                        sHtml += "</tr>";
                    }
                    $('#tbody').html(sHtml)
                }
            },
            complete: function () {
            }
        });
    }
    var isOk = true;
    function updDownloadFile(id) {

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

                },
                complete: function () {
                    isOk = true;
                }
            });
        }
    }


    //时间  格式化
    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>

