<!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="title"/>
                        </li>
                        <li>
                            <label>演出ID：</label>
                            <input type="text" name="performancesId"/>
                        </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 performanceOrderListFlag = [[${@permission.hasPermi('kylin:performancesExpress:performanceOrderList')}]];
    var batchPlaceOrderFlag = [[${@permission.hasPermi('kylin:performancesExpress:batchPlaceOrder')}]];
    var batchCancelOrderFlag = [[${@permission.hasPermi('kylin:performancesExpress:batchCancelOrder')}]];
    var prefix = ctx + "kylin/performancesExpress";
    var batchPrintFlag = [[${@permission.hasPermi('kylin:performancesExpress:batchPrint')}]];

    function printAjax(performanceId) {
        var configPrint = {
            url: prefix + "/batchPrint",
            type: "post",
            dataType: "json",
            data: {ids: performanceId},
            beforeSend: function () {
                $.modal.loading("正在处理中，请稍后...");
            },
            success: function (result) {
                $.modal.closeLoading();
                if (result.data != '' && result.data != null) {
                    var url = "https://img.zhengzai.tv/" + result.data;
                    window.location.href = url;
                } else {
                    $.modal.msg("暂无需打印单");
                }

            }
        };
        $.ajax(configPrint)
    }

    $(function () {
        var options = {
            url: prefix + "/performancesList",
            detailUrl: prefix + "/performanceOrderList/{id}",
            batchPlaceOrderUrl: prefix + "/batchPlaceOrder",
            batchCancelOrderUrl: prefix + "/batchCancelOrder",
            printUrl: prefix + "/print",
            modalName: "演出快递",
            columns: [
                {
                    field: 'performancesId',
                    title: '演出id'
                },
                {
                    field: 'title',
                    title: '演出名称'
                },
                {
                    field: 'timeStart',
                    title: '开演时间'
                },
                {
                    field: 'totalNumber',
                    title: '总数'
                },
                {
                    field: 'total1',
                    title: '已下单'
                },
                {
                    field: 'total2',
                    title: '已揽收'
                },
                {
                    field: 'total3',
                    title: '已签收'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + performanceOrderListFlag + '" href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.performancesId + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + batchPlaceOrderFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.performancesId + '\', \'确定批量下单吗？\', table.options.batchPlaceOrderUrl)"></i>下单</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + batchCancelOrderFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.performancesId + '\', \'确定批量取消吗？\', table.options.batchCancelOrderUrl)"></i>取消</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + batchPrintFlag + '" href="javascript:void(0)" onclick="printAjax(\'' + row.performancesId + '\',)"></i>下载快递单</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

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