<!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-refund-edit" th:object="${performanceRefundConfigVo}">
        <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="*{isCanRefund==1}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isCanRefund" checked>开启</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isCanRefund">关闭</label>
                </div>
            </div>
            <div class="col-sm-8" th:if="*{isCanRefund==0}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isCanRefund">开启</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isCanRefund" checked> 关闭</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">定时： </label>
            <input th:field="${performanceRefundConfigVo.refundOpenTime}" type="text" style="width: 200px;float: left"
                   class="form-control" id="startTime" placeholder="开始时间选择" name="refundOpenTime"
                   required/>
            <span class="control-label" style="float: left;margin-left: 10px;margin-right: 10px"> — </span>
            <input th:field="${performanceRefundConfigVo.refundCloseTime}" type="text" style="width: 200px;float: left"
                   class="form-control" id="endTime" placeholder="结束时间选择" name="refundCloseTime"
                   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-refund-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: '[[${performanceRefundConfigVo.performancesId}]]'.replaceAll("\"", ""),
            isCanRefund: parseInt($("input[name^='performance_isCanRefund']:checked").val()),
            refundOpenTime: $("input[name^='refundOpenTime']").val(),
            refundCloseTime: $("input[name^='refundCloseTime']").val()
        }

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