{{include "com/inc.html"}}
<!-- Main Header -->
{{include "com/header.html"}}
<!-- Left side column. 权限菜单 -->
{{include "com/menu.html"}}
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            <small></small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="/front/user/check/list?"><i class="fa fa-dashboard"></i> 质检任务列表</a></li>
            <li><a href="#"><i class="fa fa-dashboard"></i> 质检列表</a></li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-body">
                        <div class="box-body">
                            <h4><i class="glyphicon glyphicon-exclamation-sign" style="margin-right: 6px"></i>数据情况</h4>
                            <div class="form-group" style="margin-left: 10px;margin-top: 10px">
                                <div class="col-xs-5" style="width: auto">
                                    <label class="form-inline">已标数据/数据总量：
                                        <input type="text" class="form-control" style="width: 120px;padding: 5px" readonly value="{{.T.taskTagNum}} / {{ .T.taskNum }}"></label>
                                    <label class="form-inline">已检数据/已标总量：
                                        <input type="text" class="form-control" style="width: 120px;padding: 5px" readonly value="{{.T.taskCheckNum}} / {{ .T.taskTagNum }}"></label>
                                </div>
                                <input type="button" class="btn btn-primary" onclick="checkResult()" value="质检结果">
                            </div>
                        </div>

                        <div id="status-div" class="col-xs-1" style="width: auto;float:right;">
                            <label for="statusSelect">状态：
                                <select class="form-control selectpicker" id="statusSelect">
                                    <option value=-1>全部</option>
                                    <option value=0>未标注</option>
                                    <option value=1>已标注</option>
                                </select></label>
                        </div>
                        <table id="dataTable" class="table table-bordered table-hover">
                            <thead>
                            <tr>
                                <th></th>
                                <th>标题</th>
                                <th>用户</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>

{{include "com/footer.html"}}
<script>

    let tid = {{ .T.tid }}
    let pid = {{ .T.pid }}
    let sourceinfo = {{ .T.sourceinfo }}
    let stype = {{ .T.stype }}
    let datatype = {{ .T.datatype }}

    $(function () {
        ttable = $('#dataTable').dataTable({
            "paging": true,
            "lengthChange": false,
            "searching": true,
            "processing": true,
            "pageLength": 20,
            "ordering": false,
            "info": true,
            "autoWidth": false,
            "serverSide": true,
            "ajax": {
                "url": "/front/user/check/data",
                "type": "post",
                "data": {"tid": tid, "s_sourceinfo": sourceinfo, "stype": stype, "datatype": datatype}
            },
            "language": {
                "url": "/dist/js/dataTables.chinese.lang"
            },
            "fnDrawCallback": function () {
                $("ul.pagination").prepend("&nbsp;&nbsp;&nbsp;转到第 <input type='text' id='changePage'   style='width:20px;'> 页    <a type='text' href='javascript:void(0);' id='dataTable-btn' style='text-align:center'>GO</a>");
                $('#dataTable-btn').click(function (e) {
                    var redirectpage = 0
                    if ($("#changePage").val() && $("#changePage").val() > 0) {
                        var redirectpage = $("#changePage").val() - 1;
                    }
                    ttable.api().page(redirectpage).draw(false);
                });
                this.api().column(0).nodes().each(function (cell, i) {
                    cell.innerHTML = i + 1;
                });
            },
            "columns": [
                {"data": null, width: "2%"},
                {"data": "v_baseinfo.title", render: function (val, index, row) {
                        let tmp
                        if (row["b_check"]) {
                            tmp = '<a style="display: inline-block;cursor:pointer;font-size:16px;color: green" target="_blank" href="/front/user/check/detail/?pid='+pid+'&did='+row._id+'&tid='+tid+'&s_sourceinfo='+sourceinfo+'">'+val+'</a>'
                        } else {
                            tmp = '<a style="display: inline-block;cursor:pointer;font-size:16px;color: #428bca" target="_blank" href="/front/user/check/detail/?pid='+pid+'&did='+row._id+'&tid='+tid+'&s_sourceinfo='+sourceinfo+'">'+val+'</a>'
                        }
                        return tmp
                    }},
                {"data": "s_login", "defaultContent": ""},
            ],
            "initComplete": function () {
                $("#dataTable_filter").append($('#status-div'))
            },
            "fnServerParams": function (e) {
                e.i_ckdata = $("#statusSelect option:selected").val()
            }
        });
        $('#statusSelect').on('changed.bs.select', function () {
            ttable.api().ajax.reload();
        })
    });

    function checkResult() {
        let num = {{ .T.taskCheckNum }}
        if (num > 0) {
            window.location.href = "/front/user/check/result?pid={{.T.pid}}&tid={{.T.tid}}&s_sourceinfo={{.T.sourceinfo}}&stype={{.T.stype}}&datatype={{.T.datatype}}"
        }else {
            showTip("没有审核数据")
        }
    }
</script>
