<!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="keyword" placeholder="请输入优惠券码/使用企业/消费产品/创建人"/>
                            </li>
                            <li>
                                <label>状态：</label>
                                <select name="couponStatus" th:with="type=${@dict.getType('couponStatus')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>创建时间： </label>
                                <input type="text" class="time-input" id="startDate" placeholder="开始时间" name="startDate"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endDate" placeholder="结束时间" name="endDate"/>
                            </li>

                            <li class="select-time">
                                <label>使用时间： </label>
                                <input type="text" class="time-input" id="startDate1" placeholder="开始时间" name="startDate1"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endDate1" placeholder="结束时间" name="endDate1"/>
                            </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="coupon:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="coupon: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('coupon:edit')}]];
        var removeFlag = [[${@permission.hasPermi('coupon:remove')}]];
        var couponStatusDatas = [[${@dict.getType('couponStatus')}]];
        var discountWayDatas = [[${@dict.getType('discountWay')}]];
        var prefix = ctx + "manage/coupon";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "产品优惠券",
                columns: [
                {
                    field: 'name',
                    title: '优惠券名称'
                },
                {
                    field: 'productCouponId',
                    title: '优惠券码'
                },
                {
                    field: 'discountWay',
                    title: '优惠方式'
                },
                {
                    field: 'discountValue',
                    title: '优惠值'
                },
                {
                    field: 'couponStatus',
                    title: '状态'
                },
                {
                    field: 'comName',
                    title: '使用企业'
                },
                {
                    field: 'createName',
                    title: '创建人'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'useTime',
                    title: '使用时间'
                },
                {
                    field: 'expireTime',
                    title: '过期时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.comOrderId == null || row.comOrderId == undefined) {
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.productCouponId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>