<%@ 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;
        var count = 0;
        $(document).ready(function() {
            if($("#applyDate").val()==null || $("#applyDate").val()==''){
                $("#applyDate").val(getNowFormatDate());
            }
            validateForm = $("#inputForm").validate({
                submitHandler: function(form){
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                rules:{
                },
                messages:{
                },
                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: '#applyDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                format: 'yyyy-MM-dd',
                type : 'date'
            });

            laydate.render({
                elem: '#endDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                format: 'yyyy-MM-dd',
                type : 'date'
            });
        });
        function doSubmit(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。

            if(obj == 2){
                $("#inputForm").attr("action","${ctx}/workregularapply/workRegularApply/store");
            }else{
                $("#inputForm").attr("action","${ctx}/workregularapply/workRegularApply/save");
            }
            if(validateForm.form()){
                $("#inputForm").submit();
                return true;
            }else {
                parent.layer.msg("信息未填写完整!", {icon: 5});
            }

            return false;
        }

        function deleteRow(obj,index){
            $(obj).parent().parent().remove();
            str[index] = " ";
            mon[index] = 0;

        }
        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            month = (month < 10)?"0"+month:month;
            strDate = (strDate < 10)?"0"+strDate:strDate;
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
            return currentdate;
        }

        function addRow(list, idx, tpl, row){
            var idx1 = $("#workMonthlyPlanThisList tr").length;
            //tpl = tpl.replace("workMonthlyPlanThisList[0]_workClientInfoId","workMonthlyPlanThisList["+idx1+"].workClientInfoId");

            bornTemplete(list, idx, tpl, row, idx1);
        }
        function bornTemplete(list, idx, tpl, row, idx1){
            $(list).append(Mustache.render(tpl, {
                idx: idx, delBtn: true, row: row,
                order:idx1 + 1
            }));
            $(list+idx).find("select").each(function(){
                $(this).val($(this).attr("data-value"));
            });
            $(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
                var ss = $(this).attr("data-value").split(',');
                for (var i=0; i<ss.length; i++){
                    if($(this).val() == ss[i]){
                        $(this).attr("checked","checked");
                    }
                }
            });

        }

        function selectUserInfo(id) {
            $.ajax({
                type:'post',
                data:{
                    "id":id
                },
                url:'${ctx}/workregularapply/workRegularApply/userInfo',
                success:function(data){
                    setUserInfo(data);
                }
            })
        }
        function setUserInfo(obj){
            $("#no").val(obj.no);
            $("#basicInfoId").val(obj.id);
            $("#name").val(obj.name);
            $("#status").val(obj.status);
            $("#idCard").val(obj.idCard);
            $("#officeName").val(obj.office.name);
            $("#jobName").val(obj.jobGrade.name);
            $("#entryDate").val(obj.entryDate);
            $("#pay").val(obj.salary);
            $("#tryEndTime").val(obj.tryEndTime);

            $("#correctOpinion").val(1);
            $("#jobGradeId").val(obj.jobGrade.id);
            $("#jobGradeName").val(obj.jobGrade.name);
            $("#correctDate").val(obj.tryEndTime);


        }

        function getMoney(value,j){
            var score = "0";
            //方法一使用id选择器进行计算。
            //获取输入的数字
            //自动计算出结果并填充在相应的输入框中
            var size = $("#workRegularScoreList tr").length;
            for (var i = 0;i<size;i++){
                var scores = $("#workRegularScoreList"+i+"_score").val();
                var delFlag = $("#workRegularScoreList"+i+"_delFlag").val();
                if (scores!=undefined && isNumber(scores) && delFlag==0){
                    if(score==""){
                        score = parseFloat(scores);
                    }else {
                        score = (parseFloat(score) + parseFloat(scores));
                    }
                }
            }
            $("#score").val(score);

        }
        function isNumber(val){
            if(val === "" || val ==null){
                return false;
            }
            var regPos = /^\d+(\.\d+)?$/; //非负浮点数
            var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
            if(regPos.test(val) || regNeg.test(val)){
                return true;
            }else{
                return false;
            }

        }

	</script>
	<style>
		/*超过5个汉字，调整label的长度，以下是配套的*/
		.layui-item .layui-form-label{
			width:90px;
		}
		.form-group .layui-item .layui-input-block,
		.query .layui-input-block {
			margin-left: 116px;
		}
	</style>
</head>
<body>
<div class="single-form">
	<div class="container">
		<form:form id="inputForm" modelAttribute="workRegularApply" action="${ctx}/workregularapply/workRegularApply/save" method="post" class="form-horizontal" >
			<form:hidden path="id"/>
			<form:hidden path="jobGrade.id" id="jobGradeId"/>
			<form:hidden path="basicInfoId" id="basicInfoId"/>
			<form:hidden path="userId" id="userId"/>
			<form:hidden path="officeId" id="officeId"/>
			<form:hidden path="correctOpinion" id="correctOpinion"/>
			<div class="form-group layui-row first">
				<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:gridSelectUser id="userId" name="userId" value="${workRegularApply.userId}" labelName="name" labelValue="${workRegularApply.workStaffBasicInfo.name}"--%>
												 <%--title="用户" url="${ctx}/sys/office/gridSelectUser" cssClass="form-control required layui-input" isAll="true" type="1"  isSingle="true"></sys:gridSelectUser>--%>
								<input id="userName" readonly="true" name="userName" htmlEscape="false" class="form-control layui-input" value="${workRegularApply.workStaffBasicInfo.name}"/>
						</div>
					</div>
					<%--<div class="layui-input-block with-icon">
						<sys:gridselectItem url="${ctx}/workitem/workItem/selectItem" id="fixedAssetsNumber" name="fixedAssetsNumber"  value="${workBorrowMangement.fixedAssetsNumber}"  title="选择固定资产" labelName="assetsNumber"
											labelValue="${workBorrowMangement.assetsNumber}" cssClass="form-control layui-input required" fieldLabels="固定资产" fieldKeys="name" searchLabel="物品名称" searchKey="name" ></sys:gridselectItem>
					</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">
						<div class="input-group">
							<form:input id="no" 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 workRegularApply.state}">${fns:getDictLabel(workRegularApply.state, '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"><span class="require-item">*</span>员工状态：</label>
					<div class="layui-input-block">
						<form:input id="status" path="workStaffBasicInfo.status" htmlEscape="false" readonly="true"  class="form-control layui-input" value="${fns:getDictLabel(workRegularApply.workStaffBasicInfo.status, 'staff_status', '')}"/>
					</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="idCard" readonly="true" path="workStaffBasicInfo.idCard" htmlEscape="false" 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 id="officeName" readonly="true" path="workStaffBasicInfo.office.name" htmlEscape="false" 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 id="jobName" readonly="true" path="jobName" htmlEscape="false" 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="pay" name="pay" value="${workRegularApply.pay}"  readonly="true" htmlEscape="false" 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="entryDate" name="workStaffBasicInfo.entryDate" readonly="true" type="text"  maxlength="20" class="laydate-icondate form-control layer-date  layui-input laydate-icon"
							   value="<fmt:formatDate value="${workRegularApply.workStaffBasicInfo.entryDate}" pattern="yyyy-MM-dd"/>"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label double-line"><span class="require-item">*</span>试用期结束日期：</label>
					<div class="layui-input-block">
						<input id="tryEndTime" name="tryEndTime" type="text"  maxlength="20" readonly="true" class="laydate-icondate form-control layer-date  layui-input laydate-icon"
							   value="<fmt:formatDate value="${workRegularApply.workStaffBasicInfo.tryEndTime}" 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">
						<input id="applyDate" name="applyDate" type="text"  maxlength="20" class="laydate-icondate form-control layer-date  layui-input laydate-icon"
							   value="<fmt:formatDate value="${workRegularApply.applyDate}" pattern="yyyy-MM-dd"/>"/>
					</div>
				</div>
			</div>

			<div class="form-group layui-row">
				<div class="form-group-label"><h2>个人总结</h2></div>
				<div class="layui-item layui-col-sm12  with-textarea">
					<label class="layui-form-label">个人总结：</label>
					<div class="layui-input-block">
						<form:textarea path="summary"  htmlEscape="false" rows="7"    maxlength="500" class="form-control "/>
					</div>
				</div>
			</div>

			<div class="form-group layui-row view-form">
				<div class="form-group-label"><h2>部门鉴定</h2></div>
				<div class="layui-item layui-col-xs12 form-table-container" >
					<%--<div class="layui-item layui-col-sm6">--%>
						<%--<label class="layui-form-label"><span class="require-item">*</span>转正意见：</label>--%>
						<%--<div class="layui-input-block">--%>
							<%--<input  htmlEscape="false" readonly="true"   class="form-control layui-input" value="正常"/>--%>
						<%--</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  with-icon">--%>
							<%--<div class="input-group">--%>
								<%--<input id="jobGradeName" name="jobGrade.name" value="${workRegularApply.jobGrade.name}" readonly="true"  htmlEscape="false" class="form-control layui-input"/>--%>
							<%--</div>--%>
						<%--</div>--%>
					<%--</div>--%>
					<%--<div class="layui-item layui-col-sm6">--%>
						<%--<label class="layui-form-label double-line"><span class="require-item">*</span>新试用期结束日期：</label>--%>
						<%--<div class="layui-input-block">--%>
								<%--<input id="correctDate"  readonly="true" name="correctDate" type="text"  maxlength="20" class="laydate-icondate form-control layer-date  layui-input laydate-icon"--%>
									   <%--value="<fmt:formatDate value="${workRegularApply.correctDate}" pattern="yyyy-MM-dd"/>"/>--%>
						<%--</div>--%>
					<%--</div>--%>
					<div class="layui-item layui-col-sm12  with-textarea"style="margin-top: 20px">
						<label class="layui-form-label">部门评语：</label>
						<div class="layui-input-block">
							<form:textarea path="comment" htmlEscape="false" rows="4"  readonly="true"   maxlength="255" class="form-control "/>
						</div>
					</div>
					<%--<table id="contentTable1" class="table table-bordered table-condensed can-edit no-bottom-margin">--%>
						<%--<thead>--%>
						<%--<tr>--%>
							<%--<th width="400px">鉴定内容</th>--%>
							<%--<th width="200px">评价得分</th>--%>
						<%--</tr>--%>
						<%--</thead>--%>
						<%--<tbody id="workRegularScoreList">--%>
						<%--<c:if test="${not empty workRegularApply.workRegularScoreList}">--%>
							<%--<c:forEach items="${workRegularApply.workRegularScoreList}" var="workRegularScore" varStatus="index">--%>
								<%--<tr id="workRegularScoreList${index.index}">--%>
									<%--<td class="hide">--%>
										<%--<input id="workRegularScoreList${index.index}_id" name="workRegularScoreList[${index.index}].id" type="hidden" value="${workRegularScore.id}"/>--%>
										<%--<input id="workRegularScoreList${index.index}_regularContentId" name="workRegularScoreList[${index.index}].regularContentId" type="hidden" value="${workRegularScore.regularContentId}"/>--%>
										<%--<input id="workRegularScoreList${index.index}_delFlag" name="workRegularScoreList[${index.index}].delFlag" type="hidden" value="0"/>--%>
									<%--</td>--%>
									<%--<td>--%>
										<%--<input id="workRegularScoreList${index.index}_content"  readonly="true"   name="workRegularScoreList[${index.index}].content" type="text" value="${workRegularScore.content}"   class="form-control "/>--%>
									<%--</td>--%>
									<%--<td>--%>
										<%--<input id="workRegularScoreList${index.index}_score"  readonly="true"  name="workRegularScoreList[${index.index}].score" type="text" value="${workRegularScore.score}"   class="form-control number "/>--%>
									<%--</td>--%>
								<%--</tr>--%>
							<%--</c:forEach>--%>
							<%--<tr >--%>
								<%--<td  style="vertical-align:middle;text-align: center;"><label><font color="red">*</font>合计得分：</label></td>--%>
								<%--</td>--%>
								<%--<td>--%>
									<%--<input id="score"  readonly="true"   name="score" type="text" value="${workRegularApply.score}"   class="form-control "/>--%>
								<%--</td>--%>
							<%--</tr>--%>
						<%--</c:if>--%>
						<%--</tbody>--%>
					<%--</table>--%>

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

</body>
</html>