<!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="orderCode"/>
                            </li>
                            <li>
                                <label>演出名称：</label>
                                <input type="text" name="performanceTitle"/>
                            </li>
                            <li>
                                <label>电话：</label>
                                <input type="text" name="userMobile"/>
                            </li>
                            <li class="select-time">
                                <label>支付时间： </label>
                                <input type="text" class="time-input" id="timePayStart" placeholder="开始日期" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="timePayEnd" placeholder="结束日期" name="params[endTime]"/>
                            </li>
                            <li>
                                <label>第三方：</label>
                                <div class="col-lg-3">
                                    <div class="input-group">
                                        <input type="text" class="form-control" id="sponsorSelectDiv" name="sponsor">
                                        <div class="input-group-btn">
                                            <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
                                                <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <label>支付方式：</label>
                                <select name="payType" th:with="type=${@dict.getType('zhengzai_pay_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>订单状态：</label>
                                <select name="orderStatus" th:with="type=${@dict.getType('zhengzai_order_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>客户端：</label>
                                <select name="orderType" th:with="type=${@dict.getType('zhengzai_order_source')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>取票方式：</label>
                                <select name="getTicketType" th:with="type=${@dict.getType('zhengzai_get_ticket_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>快递状态：</label>
                                <select name="expressStatus" th:with="type=${@dict.getType('zhengzai_express_status')}">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
<!--                            <li>-->
<!--                                <label>搭售商品：</label>-->
<!--                                <select name="tiedType" th:with="type=${@dict.getType('zhengzai_tied_type')}">-->
<!--                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!--                                </select>-->
<!--                            </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="kylin:tickets:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="kylin:tickets:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="kylin:tickets:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="kylin:tickets:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
<!--            </div>-->

            <div class="col-sm-12 search-collapse">
                <form id="formId2">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>短订单号：</label>
                                <input type="text" name="findCode"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="findCode()"><i
                                        class="fa fa-search"></i>&nbsp;查询</a>
                            </li>
                            <li>
                                <label>长订单号：</label>
                                <input type="text" name="allCode" readonly/>
                            </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" />
     <th:block th:include="include :: bootstrap-suggest-js" />
     <th:block th:include="include :: bootstrap-typeahead-js" />
    <script th:inline="javascript">
        var detailFlag = [[${@permission.hasPermi('kylin:order:orderlist:detail')}]];
        var transferFlag = [[${@permission.hasPermi('kylin:order:orderlist:transferInit')}]];
        var prefix = ctx + "kylin/order/orderList";
        var orderStatusDic = [[${@dict.getType('zhengzai_order_status')}]];
        var getTicketTypeDic = [[${@dict.getType('zhengzai_get_ticket_type')}]];
        var payTypeDic = [[${@dict.getType('zhengzai_pay_type')}]];

        var prefix2 = ctx + "kylin/refund";

        function findCode() {
            var shortCode = document.getElementsByName("findCode")[0].value;
            var allCode = document.getElementsByName("allCode")[0];
            $.operate.get(prefix2 + "/search/code?code=" + shortCode + "&type=2", function (res) {
                allCode.value = res.msg;
            });
        }

        $(function() {
            var options = {
                url: prefix + "/list",
                detailUrl: prefix + "/detail/{id}",
                exportUrl: prefix + "/export",
                modalName: "订单",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'sponsor',
                    title: '第三方'
                },
                {
                    field: 'orderCode',
                    title: '订单号'
                },
                {
                    field: 'title',
                    title: '演出名称'
                },
                {
                    field: 'status',
                    title: '订单状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(orderStatusDic, value);
                    }
                },
                {
                    field: 'getTicketType',
                    title: '取票方式',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(getTicketTypeDic, value);
                    }
                },
                {
                    field: 'payType',
                    title: '支付方式',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(payTypeDic, value);
                    }
                },
                {
                    field: 'tied',
                    title: '搭售'
                },
                {
                    field: 'priceActual',
                    title: '总价格'
                },
                {
                    field: 'number',
                    title: '购票量'
                },
                {
                    field: 'userId',
                    title: '用户ID'
                },
                {
                    field: 'userMobile',
                    title: '账户名'
                },
                {
                    field: 'userMobile',
                    title: '手机号'
                },
                {
                    field: 'orderType',
                    title: '客户端'
                },
                {
                    field: 'createdAt',
                    title: '创建时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.orderTicketsId + '\')"><i class="fa fa-search"></i>详细</a>');
                        actions.push('<a class="btn btn-warning btn-xs ' + transferFlag + '" href="javascript:void(0)" onclick="f(\'' + row.orderTicketsId + '\')"><i class="fa fa-search"></i>初始化</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        var sponsorSelectDiv = $("#sponsorSelectDiv").bsSuggest({
            url: prefix + "/getSponsorList",
            idField: "sponsorId",
            keyField: "sponsorName"
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword) {
            console.log('onSetSelectValue: ', keyword);
        }).on('onUnsetSelectValue', function (e) {
            console.log("onUnsetSelectValue");
        });

        function f(id) {
            $.post(prefix + "/initTransfer",{orderId:id},function (res) {
                alert(res.msg)
            });
        }
    </script>
</body>
</html>