<!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">
                <input hidden type="text" name="performancesId" th:value="${id}">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>订单号：</label>
                            <input type="text" name="orderCode"/>
                        </li>
                        <li>
                            <label>订单号ID：</label>
                            <input type="text" name="orderTicketsId"/>
                        </li>
                        <li>
                            <label>购买人电话：</label>
                            <input type="text" name="userMobile"/>
                        </li>
                        <li>
                            <label>购买人姓名：</label>
                            <input type="text" name="userName"/>
                        </li>
                        <li>
                            <label>收货人电话：</label>
                            <input type="text" name="expressContacts"/>
                        </li>
                        <li>
                            <label>收货人姓名：</label>
                            <input type="text" name="expressPhone"/>
                        </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="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>
                            <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 placeOrderFlag = [[${@permission.hasPermi('kylin:performancesExpress:placeOrder')}]];
    var cancelOrderFlag = [[${@permission.hasPermi('kylin:performancesExpress:cancelOrder')}]];
    var getResultFlag = [[${@permission.hasPermi('kylin:performancesExpress:getResult')}]];
    var getFreightFlag = [[${@permission.hasPermi('kylin:performancesExpress:getFreight')}]];
    var getListFreightFlag = [[${@permission.hasPermi('kylin:performancesExpress:getListFreight')}]];
    var listOrderRouteFlag = [[${@permission.hasPermi('kylin:performancesExpress:listOrderRoute')}]];

    var prefix = ctx + "kylin/performancesExpress";

    var orderStatusDic = [[${@dict.getType('zhengzai_order_status')}]];

    $(function () {
        var options = {
            url: prefix + "/performanceOrderList",
            modalName: "演出订单",
            placeOrderUrl: prefix + "/placeOrder",
            cancelOrderUrl: prefix + "/cancelOrder",
            getFreightUrl: prefix + "/getFreight",
            getListFreightUrl: prefix + "/getListFreight",
            getResultUrl: prefix + "/getResult",
            listOrderRouteUrl: prefix + "/listOrderRoute",
            columns: [{
                checkbox: true
            },
                {
                    field: 'orderTicketsId',
                    title: '订单ID'
                },
                {
                    field: 'orderCode',
                    title: '订单号'
                },
                {
                    field: 'status',
                    title: '订单状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(orderStatusDic, value);
                    }
                },
                {
                    field: '',
                    title: '快递',
                    formatter: function (value, row, index) {
                        var expressType = '';
                        if (row.expressType == 1) {
                            expressType = "寄付";
                        } else {
                            expressType = "到付";
                        }
                        return '快递方式：'+expressType+'<br>'+'快递费：'+row.priceExpress;
                    }
                },
                {
                    field: '',
                    title: '购买用户',
                    formatter: function(value, row, index) {
                        var userId = row.userId;
                        var userMobile = row.userMobile;
                        var userName = row.userName;
                        return 'ID：'+userId+'<br>'+'姓名：'+userName+'<br>'+'手机号：'+userMobile;
                    }
                },
                {
                    field: '',
                    title: '收货用户',
                    formatter: function(value, row, index) {
                        var expressContacts = row.expressContacts;
                        var expressAddress = row.expressAddress;
                        var expressPhone = row.expressPhone;
                        return '姓名：'+expressContacts+'<br>'+'地址：'+expressAddress+'<br>'+'手机号：'+expressPhone;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + placeOrderFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.orderTicketsId + '\', \'确定下单吗？\', table.options.placeOrderUrl)"></i>下单</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + cancelOrderFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.orderTicketsId + '\', \'确定取消快递单吗？\', table.options.cancelOrderUrl)"></i>取消</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + getResultFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.orderTicketsId + '\', \'确定获取快递信息吗？\', table.options.getResultUrl)"></i>主动获取下单信息</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + getFreightFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.orderTicketsId + '\', \'确定获取估算运费吗？\', table.options.getFreightUrl)"></i>运费估算</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + getListFreightFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.orderTicketsId + '\', \'确定获取运费信息吗？\', table.options.getListFreightUrl)"></i>主动获取运费</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + listOrderRouteFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.orderTicketsId + '\', \'确定获取路由信息吗？\', table.options.listOrderRouteUrl)"></i>路由主动查询</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

</script>
</body>
</html>