<!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="role-form">
                <div class="select-list">
                    <ul>
                        <li>
                            审核状态：<select name="status" th:with="type=${@dict.getType('zhengzai_store_status')}">
                            <option value="">全部</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </li>
                        <li>
                            店铺名称：<input type="text" name="roleName"/>
                        </li>
                        <li>
                            认证类型：<select name="status" th:with="type=${@dict.getType('zhengzai_store_cert_type')}">
                            <option value="">全部</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                        </select>
                        </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="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 acceptFlg = [[${@permission.hasPermi('goblin:store:audit:reject')}]];
    var rejectFlg = [[${@permission.hasPermi('goblin:store:audit:reject')}]];
    var infoFlg = [[${@permission.hasPermi('goblin:store:info')}]];
    var prefix = ctx + "goblin/store";

    var dicStoreCertType = [[${@dict.getType('zhengzai_store_cert_type')}]];
    var dicStoreStatus = [[${@dict.getType('zhengzai_store_status')}]];

    $(function() {
        var options = {
            url: prefix + "/list",
            detailUrl: prefix + "/info/{id}",
            sortName: "createdAt",
            modalName: "店铺",
            columns: [{
                checkbox: true
            },
                {
                    field: 'storeName',
                    title: '店铺名称'
                },
                {
                    field: 'certType',
                    title: '店铺类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(dicStoreCertType, value);
                    }
                },
                {
                    field: 'status',
                    title: '店铺状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(dicStoreStatus, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.status == 1) {
                            actions.push('<a class="btn btn-primary btn-xs ' + acceptFlg + '" href="javascript:void(0)" onclick="auditAccept(\'' + row.storeId + '\')"><i class="fa fa-check"></i>通过</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + rejectFlg + '" href="javascript:void(0)" onclick="auditReject(\'' + row.storeId + '\')"><i class="fa fa-close"></i>驳回</a> ');
                        }
                        actions.push('<a class="btn btn-warning btn-xs ' + infoFlg + '" href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.storeId + '\')"><i class="fa fa-info-circle"></i>查看</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    /* 店铺审核:通过 */
    function auditAccept(storeId) {
        if (!acceptFlg) {
            $.modal.confirm("确认要通过该店铺申请吗？", function() {
                $.operate.post(prefix + "/audit/accept", { "storeId": storeId });
            });
        }
    }

    /* 店铺审核:驳回 */
    function auditReject(storeId) {
        if (!rejectFlg) {
            var reasonVal = "TODO:弹窗输入拒绝原因";
            alert(reasonVal);

            // $.operate.post(prefix + "/audit/reject", { "storeId": storeId, "reason": reasonVal });
        }
    }
</script>
</body>
</html>