<%@ 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{
			top:40px;
			left:0;
		}
	</style>
	<script type="text/javascript">
		var validateForm;
		function doSubmit(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            if(obj == 2){
                $("#inputForm").attr("action","${ctx}/workresignations/workResignations/store");
            }else{
                $("#inputForm").attr("action","${ctx}/workresignations/workResignations/save");
            }
		  if(validateForm.form()){
			  $("#inputForm").submit();
			  return true;
		  }
	
		  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: '#date', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			        });
            		laydate.render({
			            elem: '#endDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			        });
		});

        function selectUserInfo(id) {
            $.ajax({
                type:'post',
                data:{
                    "id":id
                },
                url:'${ctx}/workregularapply/workRegularApply/userInfo',
                success:function(data){
                    setUserInfo(data);
                }
            })
        }
        function setUserInfo(obj){
            $("#sNo").val(obj.no);
            // $("#basicInfoId").val(obj.id);
            //$("#name").val(obj.name);
            $("#sStatus").val(obj.status);
            $("#sIdCard").val(obj.idCard);
            $("#sOffice").val(obj.office.name);
            $("#sJobGrade").val(obj.jobGrade.name);
            $("#entryDate").val(obj.entryDate);
            $("#baseSalary").val(obj.salary);
        }
	</script>
</head>
<body>
<div class="single-form">
	<div class="container">
		<form:form id="inputForm" modelAttribute="workResignation" action="${ctx}/workresignations/workResignations/save" method="post" class="form-horizontal">
			<form:hidden path="id"/>
			<form:hidden path="home"/>
			<sys:message content="${message}"/>
			<div class="form-group layui-row first lw16">
				<div class="form-group-label"><h2>基础信息</h2></div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>姓名：</label>
					<div class="layui-input-block with-icon">
						<div class="input-group">
							<sys:gridSelectUserRship id="sId" name="workStaffBasicInfo.id" value="${workResignation.workStaffBasicInfo.id}" labelName="workStaffBasicInfo.name" labelValue="${workResignation.workStaffBasicInfo.name}"
													 title="用户" url="${ctx}/sys/office/gridSelectUser" cssClass="form-control required layui-input" isAll="true" type="3"  isSingle="true"></sys:gridSelectUserRship>
						</div>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">工号：</label>
					<div class="layui-input-block">
						<div class="input-group">
							<form:input id="sNo" path="workStaffBasicInfo.no" htmlEscape="false" readonly="true" class="form-control layui-input"/>
							<span class="input-group-btn">
                            <label class="form-status"><c:choose><c:when test="${not empty workResignation.status}">${fns:getDictLabel(workResignation.status, 'audit_state', '')}</c:when><c:otherwise>新添</c:otherwise></c:choose></label>
                         </span>
						</div>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">员工状态：</label>
					<div class="layui-input-block">
						<form:input id="sStatus" path="workStaffBasicInfo.status" htmlEscape="false" readonly="true" class="form-control layui-input"/>
							<%--<form:select path="projectType" class="form-control required simple-select"  onChange="changeTypeExplain(this)">
                                <form:option value="" label=""/>
                                <form:options items="${fns:getMainDictList('contract_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">
						<form:input id="sIdCard" path="workStaffBasicInfo.idCard" 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="sOffice" path="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">
						<form:input id="sJobGrade" path="jobGrade" 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="baseSalary" path="pay" 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 htmlEscape="false"  id="entryDate" readonly="true" class="form-control layui-input"
							   value="<fmt:formatDate value="${workResignation.workStaffBasicInfo.entryDate}" pattern="yyyy年MM月dd日"/>"/>
					</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 path="type" id="type" class="form-control required simple-select">
							<form:options items="${fns:getDictList('resignation_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">
						<input id="date" name="date" type="text" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon"
							   value="<fmt:formatDate value="${workResignation.date}" pattern="yyyy-MM-dd"/>"/>
					</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 path="reason" id="reason" class="form-control required simple-select">
							<form:option value="" label=""/>
							<form:options items="${fns:getMainDictList('resignation_reason')}" 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">
						<input id="endDate" name="endDate" type="text" maxlength="20" class="laydate-icondate form-control layer-date layui-input laydate-icon"
							   value="<fmt:formatDate value="${workResignation.endDate}" pattern="yyyy-MM-dd"/>"/>
					</div>
				</div>
			</div>

			<div class="form-group layui-row first lw16">
				<div class="form-group-label"><h2>离职审核</h2></div>
				<div class="layui-input-block">
					<table id="bankinfo5" class="table table-bordered table-condensed can-edit">
						<thead>
						<tr>
							<th width="">审核部门</th>
							<th width="">审核人</th>
							<th >审核项目</th>
						</tr>
						</thead>
						<tbody id="templateList">
						<c:if test="${not empty workResignation.templateList}">
							<c:forEach items="${workResignation.templateList}" var="workResignationTemplate" varStatus="index">
								<tr id="templateList${index.index}">
									<td class="hide">
										<input id="templateList${index.index}_id" name="templateList[${index.index}].id" type="hidden" value="${workResignationTemplate.id}"/>
										<input id="templateList${index.index}_delFlag" name="templateList[${index.index}].delFlag" type="hidden" value="0"/>
									</td>
									<td>
										<input id="templateList${index.index}_officeName" name="templateList[${index.index}].officeName" type="text" value="${workResignationTemplate.officeName}" readonly="true" class="form-control "/>
										<input id="templateList${index.index}_officeId" name="templateList[${index.index}].officeId" type="hidden" value="${workResignationTemplate.officeId}" readonly="true" class="form-control "/>
									</td>
									<td>
										<input id="templateList${index.index}_userName" name="templateList[${index.index}].userName" type="text" value="${workResignationTemplate.userName}" readonly="true" class="form-control "/>
										<input id="templateList${index.index}_auditor" name="templateList[${index.index}].auditor" type="hidden" value="${workResignationTemplate.auditor}" readonly="true" class="form-control "/>
									</td>
									<td title="${workResignationTemplate.comment}">
										<input id="templateList${index.index}_comment" name="templateList[${index.index}].comment" type="text" value="${workResignationTemplate.comment}" readonly="true" class="form-control "/>
									</td>
								</tr>
							</c:forEach>
						</c:if>
						</tbody>
					</table>
				</div>
			</div>
			<%--<div class="form-actions">
				<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
				<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
			</div>--%>
			<div class="form-group layui-row page-end"></div>
		</form:form>
	</div>
</div>
</body>
</html>