<!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="orderId"/>
                        </li>
                        <li>
                            <label>用户姓名：</label>
                            <input type="text" name="realName"/>
                        </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-warning" onclick="$.table.exportExcel()">
                <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 + "order";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "订单",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '订单ID',
                    visible: false
                },
                {
                    field: 'orderId',
                    title: '订单号'
                },
                {
                    field: 'realName',
                    title: '用户姓名'
                },
                {
                    field: 'userPhone',
                    title: '用户电话'
                },
                {
                    field: 'userAddress',
                    title: '详细地址'
                },
                {
                    field: 'totalNum',
                    title: '订单商品总数'
                },
                {
                    field: 'totalPrice',
                    title: '订单总价'
                },
                {
                    field: 'payPrice',
                    title: '实际支付金额'
                },
                {
                    field: 'paid',
                    title: '支付状态',
                    formatter: function (value, row, index) {
                        var statusMap = {
                            0:'待支付',1:'已支付',2:'退款',3:'取消'
                        };
                        return statusMap[value] || '未知';
                    }
                },
                {
                    field: 'payTime',
                    title: '支付时间'
                },
                {
                    field: 'payType',
                    title: '支付方式',
                    formatter: function (value, row, index) {
                        var payTypeMap = {
                            1: '微信支付',
                            2: '余额支付'
                        };
                        return payTypeMap[value] || '未知';
                    }
                },
                {
                    field: 'status',
                    title: '订单状态',
                    formatter: function (value, row, index) {
                        var statusMap = {
                            '-1': '取消',
                            '0': '未支付',
                            '1': '待发货',
                            '2': '待收货',
                            '3': '待评价',
                            '4': '已完成',
                            '5': '待成团'
                    };
                        return statusMap[value] || '未知';
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>