<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('保安员实名认证列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>认证结果：</label>
                            <input type="text" name="authResult"/>
                        </li>
                        <li>
                            <label>姓名：</label>
                            <input type="text" name="securityName"/>
                        </li>
                        <li>
                            <label>身份证号：</label>
                            <input type="text" name="idNumber"/>
                        </li>
                        <li>
                            <label>认证状态：</label>
                            <select name="authStatus">
                                <option value="">所有</option>
                                <option value="认证中" th:style="${police} ? '':'display:none'">认证中</option>
                                <option value="认证" th:style="${police} ? '':'display:none'">已认证</option>
                                <option value="已认证" th:style="${police} ? '':'display:none'">认证通过</option>
                                <option value="认证失败" th:style="${police} ? '':'display:none'">认证不通过</option>
                                <option value="1" th:style="${police} ? 'display:none':''">认证中</option>
                                <option value="4" th:style="${police} ? 'display:none':''">已认证</option>
                                <option value="3" th:style="${police} ? 'display:none':''">认证通过</option>
                                <option value="2" th:style="${police} ? 'display:none':''">认证不通过</option>
                            </select>
                        </li>
                        <li class="select-time">
                            <label>认证时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a th:style="${intranet} ? '':'display:none'" class="btn btn-warning" onclick="dataSyncFile()">
                <i class="fa fa-download"></i> 生成同步文件
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "manage/auth";
    var v5url = [[${v5url}]];
    var intranet = [[${intranet}]];
    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/validateResult/{id}",
            exportUrl: prefix + "/export",
            modalName: "保安员实名认证",
            columns: [{
                checkbox: true
            },
                {
                    field: 'securityName',
                    title: '姓名'
                },
                {
                    field: 'idNumber',
                    title: '身份证号'
                },
                {
                    field: 'imgPath',
                    title: '认证图片',
                    formatter: function(value, row, index) {
                        var url = "";
                        try{
                            if(value){
                                if(value.indexOf("http")==0){
                                    url = value;
                                }else if(value.indexOf("[{")>=0){
                                    var dataObj=eval("("+value+")");
                                    url = v5url + dataObj[0].path;
                                }else{
                                    url = v5url + value;
                                }

                                if(url != ""){
                                    return $.table.imageView(url);
                                }
                            }
                        }catch (e) {

                        }

                        return value;

                    }
                },
                {
                    field: 'authStatus',
                    title: '认证状态'
                },{
                    field: 'authDate',
                    title: '认证时间'
                },
                {
                    field: 'authResult',
                    title: '认证结果'
                },
                {
                    title: '操作',
                    formatter: function(value, row, index) {
                        if (intranet) {
                            if("认证失败" !=row.authStatus && "已认证" !=row.authStatus){
                                var actions = [];
                                actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.idNumber + '\')">手动比对</a>');
                                return actions.join('');
                            }
                        }
                        return "";
                    }
                }]
        };
        $.table.init(options);
    });


    function dataSyncFile(){
        $.modal.open("生成同步文件", prefix + "/dataSync",450,500);
    }
</script>
</body>
</html>