<!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>关联消费者id：</label>
                            <input type="text" name="customerId"/>
                        </li>
                        <li>
                            <label>注册手机号：</label>
                            <input type="text" name="phone"/>
                        </li>
                        <li>
                            <label>城市id：</label>
                            <input type="text" name="city"/>
                        </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(2)" shiro:hasPermission="customer:place:add">
                <i class="fa fa-edit"></i> 通过
            </a>
            <a class="btn btn-danger multiple disabled" onclick="auditStatus(1)" shiro:hasPermission="customer:place:remove">
                <i class="fa fa-remove"></i> 拒绝
            </a>
<!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="customer:place:edit">-->
<!--                <i class="fa fa-edit"></i> 修改-->
<!--            </a>-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="customer:place: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('customer:place:edit')}]];
    var removeFlag = [[${@permission.hasPermi('customer:place:remove')}]];
    var prefix = ctx + "customer/place";
    var customerPlaceStatus = [[${@dict.getType('customer_place_status')}]];

    $(function() {
        var options = {
            url: prefix + "/list",
            updateUrl: prefix + "/edit/{id}",
            exportUrl: prefix + "/export",
            modalName: "分销申请",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'name',
                    title: '名字'
                },
                // {
                //     field: 'customerId',
                //     title: '关联消费者id'
                // },
                {
                    field: 'phone',
                    title: '注册手机号'
                },
                {
                    field: 'customerPlaceName',
                    title: '上级分销'
                },
                {
                    field: 'customerPlacePhone',
                    title: '上级手机号'
                },
                {
                    field: 'parentCustomerPlaceName',
                    title: '最上级分销'
                },
                {
                    field: 'parentCustomerPlacePhone',
                    title: '最上级手机号'
                },
                {
                    field: 'cityName',
                    title: '城市名'
                },
                {
                    field: 'status',
                    title: '审核状态',
                    formatter: function(value) {
                        return $.table.selectDictLabel(customerPlaceStatus, 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.id + '\')"><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.id + '\')"><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>