<!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="name"/>
                            </li>
                            <li>
                                <label>公司名称：</label>
                                <input type="text" name="companyName"/>
                            </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 class="btn btn-primary multiple disabled" onclick="auditStatus(1)" shiro:hasPermission="worker:certification:add">
                    <i class="fa fa-edit"></i> 通过
                </a>
                <a class="btn btn-danger multiple disabled" onclick="auditStatus(2)" shiro:hasPermission="worker:certification:add">
                    <i class="fa fa-remove"></i> 拒绝
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="worker:certification:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="worker:certification:export">
                    <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 editFlag = [[${@permission.hasPermi('worker:certification:edit')}]];
        var removeFlag = [[${@permission.hasPermi('worker:certification:remove')}]];

        var workerStatus = [[${@dict.getType('worker_certification_status')}]];
        var companySize = [[${@dict.getType('worker_company_size')}]];

        var prefix = ctx + "worker/certification";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "师傅实名审核",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'workerCertificationId',
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'workerId',
                    title: '师傅者id',
                    visible: false
                },
                {
                    field: 'workerPhone',
                    title: '手机号'
                },
                {
                    field: 'name',
                    title: '真实姓名'
                },
                {
                    field: 'idCardNum',
                    title: '身份证号'
                },
                {
                    field: 'idCardUrl1',
                    title: '身份证正面照片',
                    formatter: function(value) {
                        if (value != null && value !== ''){return '<a target="_blank" href="' + value+ '" >查看图片<a/>';}
                        else {return '<a>无<a/>'}
                    }
                },
                {
                    field: 'idCardUrl2',
                    title: '身份证反面照片',
                    formatter: function(value) {
                        if (value != null && value !== ''){return '<a target="_blank" href="' + value+ '" >查看图片<a/>';}
                        else {return '<a>无<a/>'}
                    }
                },
                {
                    field: 'brandName',
                    title: '品牌名称'
                },
                {
                    field: 'companySize',
                    title: '公司规模',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(companySize, value);
                    }
                },
                {
                    field: 'companyName',
                    title: '公司名称'
                },
                {
                    field: 'businessLicenseNum',
                    title: '执照号码'
                },
                {
                    field: 'businessLicenseUrl',
                    title: '营业执照',
                    formatter: function(value) {
                        if (value != null && value !== ''){return '<a target="_blank" href="' + value+ '" >查看图片<a/>';}
                        else {return '<a>无<a/>'}
                    }
                },
                {
                    field: 'companyProvinceName',
                    title: '省份'
                },
                {
                    field: 'companyCityName',
                    title: '城市'
                },
                {
                    field: 'companyCountryName',
                    title: '区域'
                },
                {
                    field: 'companyAddress',
                    title: '公司详细地址'
                },
                {
                    field: 'legalPersionName',
                    title: '法人名称'
                },
                {
                    field: 'legalPersionPhoneNum',
                    title: '法人联系电话'
                },
                {
                    field: 'otherServ',
                    title: '其他服务',
                    visible: false
                },
                {
                    field: 'status',
                    title: '状态',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(workerStatus, value);
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.workerCertificationId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.workerCertificationId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function auditStatus(status){
            table.set();
            var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
            if (rows.length == 0) {
                $.modal.alertWarning("请至少选择一条记录");
                return;
            }
            $.modal.confirm("确认审核吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "ids": rows.join(), "status": status });
            })
        }
    </script>
</body>
</html>