<!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>
        body .layui-layer-btn {
                display: none !important;
            }
    </style>
</head>

<body class="gray-bg">
    <div class="container-div">
        <div class="row">

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="exportSelected()">
                    <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 prefix = ctx + "stone/logs";
        var prefix2 = ctx + "local";
        var couType = [[${couType}]];
        let id = ''
        $(function () {
            var options = {
                url: '/kylin-acitve/pageActiveTicket',
                pagination: true,
                modalName: "积分",
                queryParams: queryParams,
                columns: [
                    {
                        field: 'code',
                        title: '券码'
                    },
                    {
                        field: 'state',
                        title: '券状态',
                        formatter: function (value, row) {
                            if (value == 1) {
                                return '未兑换'
                            } else if (value == 2) {
                                return '已兑换'
                            } else {
                                return '已失效'
                            }
                        }
                    },
                    {
                        field: 'redeemUid',
                        title: '使用者ID'
                    },
                    {
                        field: 'redeemAt',
                        title: '使用时间'
                    }]
            };
            $.table.init(options);
        });
        function queryParams(params) {
            let name = 'id';
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            id = unescape(r[2]);
            var search = $.table.queryParams(params);
            search.activeId = id;
            return search;
        }
        function opendTicketList (id) {
            var url = prefix2+'activityTicketList?id=' + id;
            $.modal.openTab("活动券列表", url);
        }
        // 导出数据
        function exportSelected() {
            $.ajax({
                type: 'post',
                url: '/kylin-acitve/exportTicket',
                data: {activeId: id, activeName: 'dasdas'},
                success: function (res) {
                    console.log(res, '????')
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(res.msg) + "&delete=" + true;
                }
            })
        }
    </script>
</body>
</html>