{{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="#"><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 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="已标注">已标注</option>
                                    <option value="未标注">未标注</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>
    menuActive("/front/user/task/list");

    let tid = {{ .T.tid }}
    let pid = {{ .T.pid }}
    let sourceinfo = {{ .T.s_sourceinfo }}

    $(function () {
        ttable = $('#dataTable').dataTable({
            "paging": true,
            "lengthChange": false,
            "searching": true,
            "ordering": false,
            "info": true,
            "autoWidth": false,
            "serverSide": true,
            "ajax": {
                "url": "/front/user/remark/list",
                "type": "post",
                "data": {"tid": tid, "s_sourceinfo": sourceinfo}
            },
            "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.page(redirectpage).draw(false);
                });
                this.api().column(0).nodes().each(function (cell, i) {
                    cell.innerHTML = i + 1;
                });
            },
            "columns": [
                {"data": null, width: "2%"},
                {"data": "b_istag", width: "5%", render: function (val) {
                        let tmp;
                        if (val) {
                            tmp = '<span style="display: inline-block;font-size:14px;color: green">已标注</span>'
                        } else {
                            tmp = '<span style="display: inline-block;font-size:14px;color: #428bca">未标注</span>'
                        }
                        return tmp
                    }},
                {"data": "v_baseinfo.title", render: function (val, index, row) {
                        let tmp;
                        if (row["re_data"] === 1) {
                            tmp = '<a style="display: inline-block;cursor:pointer;font-size:16px;color: green" target="_blank" href="/front/user/remark/detail/?pid='+pid+'&did=' + row._id + '&s_sourceinfo='+sourceinfo+'">' + val + '</a>'
                        } else {
                            tmp = '<a style="display: inline-block;cursor:pointer;font-size:16px;color: #428bca" target="_blank" href="/front/user/remark/detail/?pid='+pid+'&tid=' + tid +'&did=' + row._id + '&s_sourceinfo='+sourceinfo+'">' + val + '</a>'
                        }
                        return tmp
                    }}
            ],
            "initComplete": function () {
                $("#dataTable_filter").append($('#status-div'))
            },
            "fnServerParams": function (e) {
                e.s_status = $("#statusSelect option:selected").val()
            }
        });
        $('#statusSelect').on('changed.bs.select', function () {
            ttable.api().ajax.reload();
        })
    });

</script>
