<!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="productCategory"/>
                            </li>
                            <li>
                                <label>购方名称：</label>
                                <input type="text" name="comName"/>
                            </li>
                            <li>
                                <label>分配组织：</label>
                                <select name="assignedOrgId" th:with="type=${@com.getCom()}">
                                    <option value="">所有</option>
                                    <option th:each="com : ${type}" th:text="${com.comName}" th:value="${com.comId}"></option>
                                </select>
                            </li>
                            <li>
                                <label>订单状态：</label>
                                <select name="orderStatus" th:with="type=${@dict.getType('orderStatus')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>配置状态：</label>
                                <select name="orderDeployStatus" th:with="type=${@dict.getType('orderDeployStatus')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>采购状态：</label>
                                <select name="purchaseStatus" th:with="type=${@dict.getType('purchaseStatus')}">
                                    <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>
                                <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">
            </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 allocationFlag = [[${@permission.hasPermi('order:allocation')}]];
        var orderStatusDatas = [[${@dict.getType('orderStatus')}]];
        var orderDeployStatusDatas = [[${@dict.getType('orderDeployStatus')}]];
        var prefix = ctx + "manage/order";

        $(function() {
            var options = {
                url: prefix + "/get-order-list",
                columns: [
                {
                    field: 'comOrderId',
                    title: '订单编号'
                },
                {
                    field: 'comName',
                    title: '购方名称'
                },
                {
                    field: 'productCategory',
                    title: '产品名称'
                },
                {
                    field: 'orderDetailListStr',
                    title: '产品详情'
                },
                {
                    field: 'amount',
                    title: '总价（元）'
                },
                {
                    field: 'actualPayAmount',
                    title: '实付（元）'
                },
                {
                    field: 'createTime',
                    title: '支付时间'
                },
                {
                    field: 'orderStatus',
                    title: '订单状态'
                },
                {
                    field: 'orderDeployStatus',
                    title: '资源分配',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(orderDeployStatusDatas, value);
                    }
                },
                {
                    field: 'assignedOrgName',
                    title: '分配组织'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        var detailClick="comMeetingOrderInfo(" + index + ")";
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="' + detailClick + '"><i class="fa fa-edit"></i>详情</a> ');

                        if(row.orderDeployStatus != '1'){
                            var allocationClick="showAllocationResource('" + index + "')";
                            actions.push('<a class="btn btn-warning btn-xs ' + allocationFlag + '" href="javascript:void(0)" onclick="' + allocationClick + '" ><i class="fa fa-refresh"></i>分配资源</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        //点击编辑弹窗
        function comMeetingOrderInfo(index) {
            pageParam = { //页面传递参数
                mark: "upd",
                row: $("#bootstrap-table").bootstrapTable('getData')[index]
            }
            detail(index);
        }

        function detail(index) {
            $.modal.open('订单详情', prefix+'/view-order-detail', '900', '600');
        }
        //点击编辑弹窗
        function showAllocationResource(index) {
            pageParam = { //页面传递参数
                mark: "upd",
                row: $("#bootstrap-table").bootstrapTable('getData')[index]
            }
            resource(index);
        }

        function resource(index) {
            $.modal.open('分配资源', prefix+'/view-order-resource', '400', '260');
        }
    </script>
</body>
</html>