<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('转赠管理')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-transfer-edit" th:object="${performanceTransferConfigVo}">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">演出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: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="*{isCanTransfer==1}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isCanTransfer" checked>开启</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isCanTransfer">关闭</label>
                </div>
            </div>
            <div class="col-sm-8" th:if="*{isCanTransfer==0}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isCanTransfer">开启</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isCanTransfer" checked> 关闭</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">定时： </label>
            <input th:field="${performanceTransferConfigVo.transferStartTime}" type="text"
                   style="width: 200px;float: left"
                   class="form-control" id="startTime" placeholder="开始时间选择" name="transferOpenTime"
                   required/>
            <span class="control-label" style="float: left;margin-left: 10px;margin-right: 10px"> — </span>
            <input th:field="${performanceTransferConfigVo.transferEndTime}" type="text"
                   style="width: 200px;float: left"
                   class="form-control" id="endTime" placeholder="结束时间选择" name="transferCloseTime"
                   required/>
        </div>

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

    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    var prefix = ctx + "kylin/performances";

    $("#form-transfer-edit").validate({
        focusCleanup: true
    });

    $("#startTime").datetimepicker({
        format: "yyyy-mm-dd hh:ii:ss",
        autoclose: true
    });
    $("#endTime").datetimepicker({
        format: "yyyy-mm-dd hh:ii:ss",
        autoclose: true
    });

    function submitHandler() {
        var param = {
            performancesId: '[[${performanceTransferConfigVo.performancesId}]]'.replaceAll("\"", ""),
            isCanTransfer: parseInt($("input[name^='performance_isCanTransfer']:checked").val()),
            transferStartTime: $("input[name^='transferStartTime']").val(),
            transferEndTime: $("input[name^='transferEndTime']").val()
        }

        if ($("input[name^='transferStartTime']").val() == "" || $("input[name^='transferEndTime']").val() == "") {
            alert("定时时间不能为空");
        } else {
            $.operate.post(prefix + "/transferConfig/change",
                param,
                function (res) {
                    alert(res.msg);
                    location.reload();
                });
        }
    }
</script>
</body>
</html>
