<!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-agent-edit" th:object="${kylinPerformanceAgentVo}">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">performances_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 is-required">演出名称：</label>
            <div class="col-sm-8">
                <input name="title" th:value="*{title}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div th:each="ticket : ${kylinPerformanceAgentVo.tickets}">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">票种名称：</label>
                <div class="col-sm-8">
                    <input name="title" th:value="${ticket.title}" class="form-control" type="text" readonly>
                    <input name="ticketsId" th:value="${ticket.ticketsId}" class="form-control" type="hidden" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">是否代理：</label>
                <div class="col-sm-8" th:if="${ticket.isAgent==1}">
                    <div class="radio check-box">
                        <input type="radio" value="1" th:name="'ticket_agent:'+${ticket.ticketsId}" checked>代理</label>
                    </div>
                    <div class="radio check-box">
                        <input type="radio" value="0" th:name="'ticket_agent:'+${ticket.ticketsId}">不代理</label>
                    </div>
                    <button type="button" class="btn btn-w-m btn-success" onclick="submitHandler(this)">
                        修改
                    </button>
                </div>
                <div class="col-sm-8" th:if="${ticket.isAgent==0}">
                    <div class="radio check-box">
                        <input type="radio" value="1" th:name="'ticket_agent:'+${ticket.ticketsId}">代理</label>
                    </div>
                    <div class="radio check-box">
                        <input type="radio" value="0" th:name="'ticket_agent:'+${ticket.ticketsId}" checked> 不代理</label>
                    </div>
                    <button type="button" class="btn btn-w-m btn-success" onclick="submitHandler(this)">
                        修改
                    </button>
                </div>
            </div>
        </div>
    </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(res) {
        var param = {
            "performancesId":'[[${kylinPerformanceAgentVo.performancesId}]]'.replaceAll("\"", ""),
            "ticketsId":$(res).parent().parent().parent().find("input[name^='ticketsId']").val(),
            "status": $(res).parent().find("input[name^='ticket_agent:"+$(res).parent().parent().parent().find("input[name^='ticketsId']").val()+"']:checked").val()
        }
        $.operate.post(prefix + "/agent/change", param, function (res) {
            location.reload();
        });
    }


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