<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <title>私塾家</title>
    <script th:include="sys/common/metaCSS" th:remove="tag"></script>
    <script th:include="sys/common/metaJS" th:remove="tag"></script>
</head>
<style>
    .tablelink {
        margin-right: 10px;
    }
    .layui-form-label, .layui-textarea, .layui-btn {
        font-size: large;
    }
    .layui-form-label, .layui-input-block {
        margin-left: 30px;
    }
    .layui-textarea {
        width: 435px;
        height: 200px;
        margin-top: 5px;
    }
    .layui-btn {
        margin-top: 20px;
        margin-left: 100px;
    }

    td div {
        word-break: break-all;
    }
</style>
<body>
<div class="place">
    <span>位置：</span>
    <ul class="placeul">
        <li><a href="#">馆长审核管理</a></li>
        <li><a href="#">审核</a></li>
    </ul>
</div>
<div class="rightinfo">
    <form id="seachform" th:action="@{/sys/curator/auditList}" method="post">
        <input id="url" name="url" type="hidden">
        <input id="leagueName" name="leagueName" type="hidden">
        <ul class="seachform">
            <li>
                <label>馆长名称</label>
                <input name="LIKE_curatorName" type="text" class="scinput" th:value="${search.get('LIKE_curatorName')}"/>
            </li>
            <li>
                <label></label>
                <input type="button" class="scbtn" value="查询"/>
            </li>
        </ul>
    </form>
    <table class="tablelist">
        <thead>
        <tr>
            <th style="width: 40px;">序号</th>
            <th>馆长姓名</th>
            <th>手机号</th>
            <th>场馆</th>
            <th>申请时间</th>
            <th style="text-align: center;">操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="item:${list}">
            <td th:text="${itemStat.count}"></td>
            <td th:title="${item.curatorName}" th:text="${item.curatorName}"></td>
            <td th:title="${item.telephone}" th:text="${item.telephone}"></td>
            <td th:title="${item.libName}" th:text="${item.libName}"></td>
            <td th:text="${#calendars.format(item.applyTime, 'yyyy-MM-dd HH:mm:ss')}" ></td>
            <td>
                <div>
                    <a th:onclick="'submitResult(\'' + ${item.id} + '\', 1)'" class="tablelink">通过</a>
                    <a th:onclick="'preAudit(\'' + ${item.id} + '\')'" class="tablelink">不通过</a>
<!--                    <button onclick="audit()">审核</button>-->
                </div>
            </td>
        </tr>
        </tbody>
    </table>
    <!-- 分页 -->
    <div class="pagin">
        <div class="message">共<i class="blue">[[${page.rowCnt}]]</i>条记录，当前显示第&nbsp;<i class="blue">[[${page.pageNo }]]&nbsp;</i>页
        </div>
        <div th:utext='${listNavigatHtml}' th:remove="tag"></div>
    </div>
</div>
</body>
<script>
    function preAudit(libManagerAuditId) {
        layer.open({
            area: ['500px', '400px'],
            type: 1,
            content:
                '<form id="auditForm" class="layui-form" onsubmit="return false">' +
                '<input type="text" name="libManagerAuditId" value="' + libManagerAuditId + '" hidden>' +
                '<input type="number" name="auditResultType" value="2" hidden>' +
                '<div class="layui-form-item">' +
                '<label class="layui-form-label">拒绝原因:</label>' +
                '<div class="layui-input-block">' +
                '<textarea id="reason" type="text" name="reason" required  lay-verify="required" placeholder="请输入拒绝原因" autocomplete="off" class="layui-textarea">' +
                '</textarea>' +
                '</div>' +
                '</div>' +
                '<div class="layui-form-item">' +
                '<div class="layui-input-block">' +
                '<button class="layui-btn" onclick="submitResult(\'' + libManagerAuditId + '\', 2)' + '">立即提交</button>' +
                '<button type="reset" class="layui-btn layui-btn-primary">重置</button>' +
                '</div>' +
                '</div>' +
                '</form>'
        });
    }

    function submitResult(libManagerAuditId, auditResultType) {
        var param = {
            'auditResultType': auditResultType,
            'libManagerAuditId': libManagerAuditId
        };

        if (2 === auditResultType) {
            param.reason = $('#reason')[0].value;
        }

        $.ajax({
            url: sysUrl + "/sys/curator/audit",
            type:'get',
            data: param,
            success:function(data){
                layer.open({
                    title: '操作结果',
                    content: data.msg,
                    end: function() {
                        if ('999' === data.code) {
                            $('#seachform').submit();
                        }
                    }
                });
            }
        });
    }
</script>
</html>