<!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">
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isCanRefund"
                           th:checked="*{isCanRefund==0 ? true : false}" checked> 关闭</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isCanRefund"
                           th:checked="*{isCanRefund==1 ? true : false}">开启</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>
        <!-- todo 阶梯退票  添加了 style="display: none" 这个注释你看完需要删除-->
        <div class="form-group" style="display: none">
            <label class="col-sm-3 control-label is-required">用户退款手续费：</label>
            <div class="col-sm-8">
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isRefundPoundage"
                           th:checked="*{isRefundPoundage==0 ? true : false}" checked> 关闭</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isRefundPoundage"
                           th:checked="*{isRefundPoundage==1 ? true : false}">开启</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">用户退款快递票上门取货快递费：</label>
            <div class="col-sm-8">
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isRefundExpress"
                           th:checked="*{isRefundExpress==0 ? true : false}" checked> 公司月结</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isRefundExpress"
                           th:checked="*{isRefundExpress==1 ? true : false}">用户承担</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">用户退款快递票是否需要退回：</label>
            <div class="col-sm-8">
                <div class="radio check-box">
                    <input type="radio" value="1" name="isBackPaperTicket"
                           th:checked="*{isBackPaperTicket==1 ? true : false}" checked> 需要</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="isBackPaperTicket"
                           th:checked="*{isBackPaperTicket==0 ? true : false}">不需要</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">用户退款快递票快递费是否退回：</label>
            <div class="col-sm-8">
                <div class="radio check-box">
                    <input type="radio" value="1" name="isRefundExpressNew"
                           th:checked="*{isRefundExpressNew==1 ? true : false}" checked> 退回</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="0" name="isRefundExpressNew"
                           th:checked="*{isRefundExpressNew==0 ? true : false}">不退回</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">退款是否退优惠券：</label>
            <div class="col-sm-8">
                <div class="radio check-box">
                    <input type="radio" value="0" name="performance_isRefundVoucher"
                           th:checked="*{isRefundVoucher==0 ? true : false}" checked> 关闭</label>
                </div>
                <div class="radio check-box">
                    <input type="radio" value="1" name="performance_isRefundVoucher"
                           th:checked="*{isRefundVoucher==1 ? true : false}">开启</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>

        <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()),
            isRefundPoundage: 0,
            isRefundVoucher: parseInt($("input[name^='performance_isRefundVoucher']:checked").val()),
            isRefundExpress: parseInt($("input[name^='performance_isRefundExpress']:checked").val()),
            isBackPaperTicket: parseInt($("input[name^='isBackPaperTicket']:checked").val()),
            isRefundExpressNew: parseInt($("input[name^='isRefundExpressNew']: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>