<!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>
            <div class="col-sm-8" th:if="*{isRefundPoundage==1}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isRefundPoundage" checked>开启</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isRefundPoundage">关闭</label>
                </div>
            </div>
            <div class="col-sm-8" th:if="*{isRefundPoundage==0}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isRefundPoundage">开启</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isRefundPoundage" checked> 关闭</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">退优惠券：</label>
            <div class="col-sm-8" th:if="*{isRefundVoucher==1}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isRefundVoucher" checked>开启</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isRefundVoucher">关闭</label>
                </div>
            </div>
            <div class="col-sm-8" th:if="*{isRefundVoucher==0}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isRefundVoucher">开启</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isRefundVoucher" checked> 关闭</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">快递费：</label>
            <div class="col-sm-8" th:if="*{isRefundExpress==1}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isRefundExpress" checked>用户承担</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isRefundExpress">无</label>
                </div>
            </div>
            <div class="col-sm-8" th:if="*{isRefundExpress==0}">
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isRefundExpress">用户承担</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isRefundExpress" checked>无</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">收货人：</label>
            <div class="col-sm-8">
                <input name="title" th:field="*{orderRefundAddress.name}" 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="*{orderRefundAddress.phone}" 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="*{orderRefundAddress.address}" class="form-control" type="text" readonly>
            </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(),
            isRefundPoundage: parseInt($("input[name^='performance_isRefundPoundage']:checked").val()),
            isRefundVoucher: parseInt($("input[name^='performance_isRefundVoucher']:checked").val()),
            isRefundExpress: parseInt($("input[name^='performance_isRefundExpress']:checked").val())
        }

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