<!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('商户列表')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
</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="mercName"/>
                            </li>
                            <li>
                                <label>商户状态：</label>
                                <select name="mercStatus" class="form-control m-b" th:with="type=${@dict.getType('merc_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>商户类型：</label>
                                <select name="mercStatus" class="form-control m-b" th:with="type=${@dict.getType('merc_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>联系人：</label>
                                <input type="text" name="contact"/>
                            </li>
                            <li>
                                <label>联系信箱：</label>
                                <input type="text" name="mail"/>
                            </li>
                            <li>
                                <label>手机号：</label>
                                <input type="text" name="mobile"/>
                            </li>
                            <li>
                                <label>通信地址：</label>
                                <input type="text" name="address"/>
                            </li>
                            <li>
                                <label>个人名字：</label>
                                <input type="text" name="personName"/>
                            </li>
                            <li>
                                <label>身份证号：</label>
                                <input type="text" name="idNumber"/>
                            </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-success" onclick="$.operate.add()" shiro:hasPermission="master:merchant:add">
                    <i class="fa fa-plus"></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" />
    <th:block th:include="include :: select2-js" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('master:merchant:prod:edit')}]];
        var allocProdFlag = [[${@permission.hasPermi('master:merchant:prod:allocProd')}]];
        var setPayInfoFlag = [[${@permission.hasPermi('master:merchant:prod:setPayInfo')}]];
        var setInvFlag = [[${@permission.hasPermi('master:merchant:prod:setInv')}]];
        var removeFlag = [[${@permission.hasPermi('master:merchant:prod:remove')}]];
        var mercStatuses = [[${@dict.getType('merchant_status')}]];
        var mercTypes = [[${@dict.getType('merchant_type')}]];

        var prefix = ctx + "master/merchant";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "商户",
                columns: [
                {
                    field: 'mercId',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'mercName',
                    title: '商户名称'
                },
                {
                    field: 'mercStatus',
                    title: '商户状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(mercStatuses, value);
                    }
                },
                {
                    field: 'mercType',
                    title: '商户类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(mercTypes, value);
                    }
                },
                {
                    field: 'contact',
                    title: '联系人'
                },
                {
                    field: 'mail',
                    title: '联系信箱'
                },
                {
                    field: 'mobile',
                    title: '手机号'
                },
                {
                    field: 'address',
                    title: '通信地址'
                },
                {
                    field: 'personName',
                    title: '个人名字'
                },
                {
                    field: 'idNumber',
                    title: '身份证号'
                },
                {
                    field: 'companyName',
                    title: '公司名称'
                },
                {
                    field: 'companyCode',
                    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.mercId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-info btn-xs ' + setPayInfoFlag + '" href="javascript:void(0)" onclick="setPayInfo(\'' + row.mercId + '\')"><i class="fa fa-info"></i>支付信息设置</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + allocProdFlag + '" href="javascript:void(0)" onclick="allocProd(\'' + row.mercId + '\')"><i class="fa fa-product-hunt"></i>分配商品</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + setInvFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.mercId + '\')"><i class="fa fa-cubes"></i>商品库存设置</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.mercId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function setPayInfo(mercId) {
            $.modal.openTab("支付信息",ctx + "business/merchant/prod/wxpay/edit/" + mercId);
        }
        function allocProd(mercId) {
            $.modal.openTab("分配商品",ctx + "master/merchant/prod/view/" + mercId);
        }
    </script>
</body>
</html>