<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>收入调整管理</title>
	<meta name="decorator" content="default"/>
	<style>
		label.error{
			left:0;
			top:40px;
		}
	</style>
	<script type="text/javascript">
		var validateForm;
		function doSubmit(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            if(validateForm.form()){
                if(obj == 2){
                    $("#inputForm").attr("action","${ctx}/workreceiptsrevise/workReceiptsRevise/store");
                }else{
                    $("#inputForm").attr("action","${ctx}/workreceiptsrevise/workReceiptsRevise/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: '#reviseDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			        });
            $("#reviseType").change(function(){
                if($(this). val()== 1 || $(this). val()== 2 || $(this). val()== 3 || $(this). val()== 4){
                    console.log($(this). val()+"----------2");
                    $("#workContractInfoName").attr("class","form-control layui-input required");
                    document.getElementById("workContractInfoName").disabled=false;
                    document.getElementById("workContractInfoId").disabled=false;
                    $("#inreviseOfficeName").attr("class","form-control layui-input");
                    $("#td1").removeClass("hide");
                    $("#td2").addClass("hide");
                    if($(this). val()== 1){
                        $("#td3").removeClass("hide");
                        $("#td4").addClass("hide");
                        $("#inreviseOfficeName").attr("class","form-control layui-input required");
					}
                }else{
                    console.log($(this). val()+"----------1");
                    $("#workContractInfoName").attr("class","form-control layui-input");
                    $("#inreviseOfficeName").attr("class","form-control layui-input");
                    document.getElementById("workContractInfoName").disabled=true;
                    document.getElementById("workContractInfoId").disabled=true;
                    $("#td1").addClass("hide");
                    $("#td2").removeClass("hide");
                    $("#td3").addClass("hide");
                    $("#td4").removeClass("hide");
				}
            });
		});
	</script>
</head>
<body>
<div class="single-form">
	<div class="container">
		<form:form id="inputForm" modelAttribute="workReceiptsRevise" action="${ctx}/workreceiptsrevise/workReceiptsRevise/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<%--<sys:message content="${message}"/>--%>
			<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">
						<form:input id="officeName" path="officeName" 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">
						<form:input id="officeNum" path="officeNum" htmlEscape="false"   readonly="true" class="form-control layui-input"/>
					</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">
						<input id="reviseDate" name="reviseDate" type="text" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon required"
							   value="<fmt:formatDate value="${workReceiptsRevise.reviseDate}" 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">
						<form:input id="userName" path="userName" htmlEscape="false" readonly="true" class="form-control  layui-input"/>
					</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:select id="reviseType" path="reviseType" class="form-control simple-select required">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('revise_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">调出合同：</label>
					<div class="layui-input-block with-icon" id="td1">
						<sys:gridselectrecord url="${ctx}/project/projectRecords/selectcontract" id="workContractInfo" name="workContractInfo.id"  value="${workReceiptsRevise.workContractInfo.id}"  title="选择合同" labelName="workContractInfo.name"
											  labelValue="${workReceiptsRevise.workContractInfo.name}" cssClass="form-control layui-input " fieldLabels="合同" fieldKeys="name" searchLabel="合同名称" searchKey="name" ></sys:gridselectrecord>
					</div>
					<div class="layui-input-block hide" id="td2">
						<form:input path="" 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 with-icon" id="td3">
						<sys:treeselect id="inreviseOffice" name="inreviseOffice.id" value="${workReceiptsRevise.inreviseOffice.id}" labelName="inreviseOffice.name"
										labelValue="${workReceiptsRevise.inreviseOffice.name}"
										title="部门" url="/sys/office/treeDataAlls?type=2" cssClass="form-control layui-input"
										allowClear="true"/>
					</div>
					<div class="layui-input-block hide" id="td4">
						<input  htmlEscape="false"  readonly="true"  class="form-control layui-input"/>
					</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 path="reviseMoney" htmlEscape="false" class="form-control required number  layui-input"/><%-- pattern="#.00"--%>
					</div>
				</div>
				<div class="layui-item layui-col-sm12  with-textarea">
					<label class="layui-form-label">备注：</label>
					<div class="layui-input-block">
						<form:textarea path="remarks" htmlEscape="false" rows="4"   maxlength="64" class="form-control "/>
					</div>
				</div>
			</div>

			<div class="form-group layui-row page-end"></div>
	</form:form>
	</div>
</div>
</body>
</html>