<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('代理相关')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-damai-edit" th:object="${kylinPerformanceDamaiVo}">
        <div class="form-group">
            <label class="col-sm-3 control-label">演出ID：</label>
            <div class="col-sm-8">
                <input name="performancesId" th:field="*{performancesId}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">演出名称：</label>
            <div class="col-sm-8">
                <input name="title" th:field="*{title}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">是否开启同步大麦：</label>
            <div class="col-sm-8" th:if="*{syncDamai==1}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_sync_damai" checked>开启同步</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_sync_damai">关闭同步</label>
                </div>
            </div>
            <div class="col-sm-8" th:if="*{syncDamai==0}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_sync_damai">开启同步</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_sync_damai" checked>关闭同步</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"></label>
            <div class="col-sm-8">
                <span style="color: #EF9C26;font-size: 14px;">说明:开启同步大麦后,该演出的票务订单每隔一分钟同步大麦一次,直至售票结束;"开启后再关闭"需注意关闭同步后产生的的演出订单信息,及时对订单信息进行处理,避免订单信息遗漏导致的的客诉问题</span>
            </div>
        </div>
<!--        <div th:each="tickets : ${kylinPerformanceDamaiVo.damaiTickets}">-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">票种名称：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="title" th:value="${tickets.title}" class="form-control" type="text" readonly>-->
<!--                    <input name="ticketsId" th:value="${tickets.ticketsId}" class="form-control" type="hidden" required>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">是否同步：</label>-->
<!--                <div class="col-sm-8" th:if="${tickets.syncDamai==1}">-->
<!--                    <div class="radio check-box">-->
<!--                        <input type="radio" value="1" th:name="'ticket_syncDamai:'+${tickets.ticketsId}"-->
<!--                               checked>同步</label>-->
<!--                    </div>-->
<!--                    <div class="radio check-box">-->
<!--                        <input type="radio" value="0" th:name="'ticket_syncDamai:'+${tickets.ticketsId}">不同步</label>-->
<!--                    </div>-->
<!--                </div>-->
<!--                <div class="col-sm-8" th:if="${tickets.syncDamai==0}">-->
<!--                    <div class="radio check-box">-->
<!--                        <input type="radio" value="1" th:name="'ticket_syncDamai:'+${tickets.ticketsId}">同步</label>-->
<!--                    </div>-->
<!--                    <div class="radio check-box">-->
<!--                        <input type="radio" value="0" th:name="'ticket_syncDamai:'+${tickets.ticketsId}" checked>-->
<!--                        不同步</label>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->

        <button type="button" class="btn btn-w-m btn-success" onclick="submitHandler()">
            修改
        </button>

    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "kylin/performances";
    $("#form-performances-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        const paramList = [];
        var param = {
            id: '[[${kylinPerformanceDamaiVo.performancesId}]]'.replaceAll("\"", ""),
            type: "performance",
            status: parseInt($("input[name^='performance_sync_damai']:checked").val())
        }
        paramList.push(param)
        // var ticketObj = JSON.parse('[[${kylinPerformanceDamaiVo.damaiTickets}]]');
        // $.each(ticketObj, function (i, damaiTickets) {
        //     var param = {
        //         id:damaiTickets.ticketsId,
        //         type:"ticket",
        //         status:parseInt($("input[name^='ticket_syncDamai:"+damaiTickets.ticketsId+"']:checked").val())
        //     }
        //     paramList.push(param)
        // });

        $.operate.post(prefix + "/damai/change",
            {params:JSON.stringify(paramList)},
            function (res) {
                location.reload();
            });
    }
</script>
</body>
</html>
