<!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('店铺审核')" />
    <style>
        .layui-layer-btn0, .layui-layer-btn1 {
            font-size: 12px;
            font-weight: normal;
            margin: 0 3px;
            margin-right: 7px;
            margin-left: 7px;
            padding: 0 15px;
            color: #fff;
            border: 1px solid #0064b6;
            background: #0071ce;
            border-radius: 3px;
            display: inline-block;
            height: 30px;
            line-height: 30px;
            text-align: center;
            vertical-align: middle;
            background-repeat: no-repeat;
            text-decoration: none;
            outline: none;
            -moz-box-sizing: content-box;
            -webkit-box-sizing: content-box;
            box-sizing: content-box;
        }
        .layui-layer-btn1 {
            color: #404a58;
            border: 1px solid #c0c4cd;
            background: #fff;
            border-radius: 3px;
            margin-left: 0;
        }
        .layui-layer-btn0:hover {
            color: #fff;
        }
        #addClassify {
            padding: 0;
            display: none;
            width: 540px;
            padding-top: 20px;
        }
        #addClassify .selectClassify {
            display: flex;
            align-items: center;
            padding: 0 20px;
        }
        #addClassify .selectClassify label {
            display: flex;
            margin-right: 20px;
            align-items: center;
        }
        #addClassify .selectClassify label input {
            margin: 0;
            margin-right: 2px;
        }
        .shadeCss,.layui-layer-shade {
            background-color: rgb(0, 0, 0, 0.5) !important;
        }
        .select-list ul {
            display: flex;
            justify-content: space-between;
        }
        .selectClassifyOne {
            display: flex;
            align-items: center;
            margin: 12px 0;
            padding: 0 20px;
        }
        .selectClassifyOne span {
            width: 100px;
            text-align: right;
        }
        .tagStore .fixed-table-toolbar {
            display: flex;
        }
        .tagStore .fixed-table-toolbar .bs-bars {
            flex: 1;
        }
        .tagStore .fixed-table-toolbar .bs-bars .btn-group-sm {
            display: flex;
            justify-content: space-between;
        }
        .leftSearchBox {
            display: flex;
            align-items: center;
        }
        .leftSearchBox input, .leftSearchBox select {
            width: 200px;
            height: 34px;
            margin-right: 12px;
        }
        .ibox-content {
            border-style: none;
            padding: 0;
        }
        .kv-hidden {
            display: none !important;
        }
        .bottomBtn {
            text-align: right;
            padding: 10px 15px 12px;
            background: #f0f4f7;
            border-top: 1px #c7c7c7 solid;
        }
    </style>
</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="storeName"/>
                        </li>
                        <li>
                            认证类型：<select name="certType" 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 id="addClassify">
        <div class="selectClassifyOne">
            <span>驳回原因：</span>
            <input id="reason" class="form-control" type="text">
        </div>
        <div class="bottomBtn">
            <a href="javascript:;" class="layui-layer-btn0 paddings" onclick="yes()">确定</a>
            <a class="layui-layer-btn1 layui-layer-btn1" onclick="closeModal()">取消</a>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var acceptFlg = [[${@permission.hasPermi('goblin:store:audit:reject')}]];
    var dicStoreCertType = [[${@dict.getType('zhengzai_store_cert_type')}]];
    var dicStoreStatus = [[${@dict.getType('zhengzai_store_status')}]];
    var rejectFlg = [[${@permission.hasPermi('goblin:store:audit:reject')}]];
    var infoFlg = [[${@permission.hasPermi('goblin:store:info')}]];
    var prefix = ctx + "goblin/store";
    var storeIds = '';
    $(function() {
        var options = {
            url: prefix + "/list",
            detailUrl: prefix + "/info/{id}",
            sortName: "createdAt",
            sortOrder: "desc",
            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) {
        storeIds = storeId;
        if (!rejectFlg) {
            // var reasonVal = "TODO:弹窗输入拒绝原因";
            layer.open({
                type: 1,
                shade: true,
                title: '创建分类', //不显示标题
                content: $('#addClassify'), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
                cancel: function(res){
                    // layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', {time: 5000, icon:6});
                }
    		});
            
        }
    }
    function closeModal () {
        $(".layui-layer-close1").click();
    }
    function yes () {
        let value = $("#reason").val();
        if (!value) {
            return layer.msg('请填写原因！')
        }
        $.ajax({
            type: 'post',
            url: prefix + "/audit/reject",
            data: { "storeId": storeIds, "reason": value },
            success:function(res) {
                refreshItem()
            }
        })
    }
</script>
</body>
</html>