<!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>
                        <input hidden type="text" name="integralActivityId" th:value="${integralActivityId}">
                        <!--<li>
                            <label>活动名称：</label>
                            <input type="text" name="activityTitle"/>
                        </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-bordered">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var receivingStatusFlag = [[${@permission.hasPermi('sweet:IntegralActivityDraw:receivingStatus')}]];

    var prefix = ctx + "sweet/IntegralActivityDraw";
    $(function () {
        var options = {
            url: prefix + "/list",
            modalName: "积分活动中奖记录",
            columns: [{
                checkbox: true
            },
                {
                    field: 'prizeId',
                    title: 'prize_id'
                },
                {
                    field: 'userId',
                    title: 'user_id'
                },
                {
                    field: 'receivingAddressesId',
                    title: 'receiving_addresses_id'
                },
                {
                    field: 'receivingName',
                    title: 'receiving_name'
                },
                {
                    field: 'receivingPhone',
                    title: 'receiving_phone'
                },
                {
                    field: 'receivingAddress',
                    title: 'receiving_address'
                },
                {
                    field: 'receivingStatus',
                    title: 'receiving_status'
                },
                {
                    field: 'createdAt',
                    title: '创建时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + receivingStatusFlag + '" href="javascript:void(0)" onclick="openModal(\'' + row.drawId + '\')"></i>发货</a> ');
                        return actions.join('');
                    }
                }]
        };

        $.table.init(options);

    });
    function openModal(id) {
        $.modal.confirm(`确定要发货吗？`, function() {
            $.ajax({
                type: 'put',
                url: '/sweet/IntegralActivityDraw/receivingStatus',
                data: {drawId: id},
                success:function(e) {
                    console.log(e)
                    if (e.code == 0) {
                        layer.msg('发货成功！')
                        $("button[name=refresh]").click();
                    }
                }
            })
        });
    }
</script>
</body>
</html>