<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('代金券流水')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-water">
        <!-- 隐藏字段，用于传递代金券ID -->
        <input name="voucherId" th:value="${voucherId}" type="hidden">

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "voucher/member";
    var voucherTypeDatas = /*[[${@dict.getType('voucher_type')}]]*/ [];
    $(function() {
        var options = {
            url: prefix + "/list",
            modalName: "代金券流水",
            queryParam: function() {
                return {
                    voucherId: $("input[name='voucherId']").val()
                };
            },
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'username',
                    title: '用户名称'
                },
                {
                    field: 'voucherName',
                    title: '代金券名称'
                },
                {
                    field: 'voucherPrice',
                    title: '代金券金额'
                },
                {
                    field: 'instantDiscount',
                    title: '满多少金额立减'
                },
                {
                    field: 'validityTime',
                    title: '有效期',
                    formatter: function(value, row, index) {
                        // 使用 ry-ui.js 中的 dateFormat 方法替代 $.common.formatDate
                        return $.common.dateFormat(value);
                    }
                },
                {
                    field: 'voucherType',
                    title: '代金券类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(voucherTypeDatas, value);
                    }
                },
                {
                    field: 'isValidity',
                    title: '是否过期',
                    formatter: function(value, row, index) {
                        if (value == '1') {
                            return '未使用';
                        } else if (value == '2') {
                            return '已使用';
                        } else if (value == '3') {
                            return '已过期';
                        } else {
                            return value;
                        }
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>