<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>还款</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
        var validateForm;
        function doSubmit(){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            if(validateForm.form()){
				$("#inputForm").attr("action","${ctx}/workrepay/workRepay/save");
                $("#inputForm").submit();
                return true;
            }else {
                parent.layer.msg("信息未填写完整!", {icon: 5});
            }
            return false;
        }
        $(document).ready(function() {
            validateForm = $("#inputForm").validate({
                submitHandler: function(form){
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });

            laydate.render({
                elem: '#repayDate',
                event: 'focus',
                type : 'date'
            });
        });

        function checkMoney(obj){
            var notRepay =  ${workRepay.notRepay};
            if(notRepay != undefined && notRepay != '' && obj > notRepay){
                $("#money").val("");
                console.log(obj+"--------"+notRepay);
                parent.layer.msg("所填值大于未还款金额！请重新输入",{icon:5});
                return;
			}
		}
	</script>
</head>
<body>
<div class="single-form">
	<div class="container">
		<form:form id="inputForm" modelAttribute="workRepay" action="${ctx}/workrepay/workRepay/save" method="post" class="form-horizontal">
			<form:hidden path="id"/>
			<form:hidden path="workLoan.id"/>
			<form:hidden path="source"/>
			<div class="form-group layui-row first lw8">
				<div class="form-group-label"><h2>基础信息</h2></div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">借款人：</label>
					<div class="layui-input-block with-icon">
						<div class="input-group">
							<form:input path="workLoan.workStaffBasicInfo.name" htmlEscape="false"   readonly="true" class="form-control layui-input"/>
						</div>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">借款编号：</label>
					<div class="layui-input-block with-icon">
						<div class="input-group">
							<form:input path="workLoan.num" htmlEscape="false"   readonly="true" class="form-control layui-input"/>
						</div>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">所属部门：</label>
					<div class="layui-input-block">
						<form:input id="officeName" path="workLoan.workStaffBasicInfo.office.name" htmlEscape="false" readonly="true" class="form-control  layui-input"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">借款日期：</label>
					<div class="layui-input-block">
						<input name="loanDate" type="text" readonly="true" class="laydate-icondate form-control layer-date layui-input laydate-icon"
							   value="<fmt:formatDate value="${workRepay.workLoan.loanDate}" pattern="yyyy-MM-dd"/>"/>
						</input>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">借款金额：</label>
					<div class="layui-input-block">
						<input  htmlEscape="false" readonly="true" class="form-control layui-input" value="<fmt:formatNumber value="${workRepay.workLoan.money}" pattern="#,#0.00"/>"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">还款日期：</label>
					<div class="layui-input-block">
						<input readonly="true" name="repayDate" type="text" class="laydate-icondate form-control layer-date layui-input laydate-icon"
							   value="<fmt:formatDate value="${workRepay.repayDate}" pattern="yyyy-MM-dd"/>"/>
						</input>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">剩余未还款：</label>
					<div class="layui-input-block">
						<input  id="notRepay" htmlEscape="false" readonly="true" class="form-control layui-input"
								value="<fmt:formatNumber value="${workRepay.notRepay}" pattern="#,#0.00"/>"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>还款金额：</label>
					<div class="layui-input-block">
						<form:input id="money" path="money" onchange="checkMoney(this.value)" htmlEscape="false"  class="form-control number layui-input"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">还款人：</label>
					<div class="layui-input-block with-icon">
						<div class="input-group">
							<form:input path="createBy.name" htmlEscape="false"   readonly="true" class="form-control layui-input"/>
						</div>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">还款状态：</label>
					<div class="layui-input-block">
						<input id="repayState" htmlEscape="false" readonly="true" class="form-control  layui-input"
							   value="${fns:getDictLabel(workRepay.workLoan.repayState, 'repay_state','')}"/>
					</div>
				</div>
			</div>
			<div class="form-group layui-row page-end"></div>
		</form:form>
	</div>
</div>
</body>
</html>