<%@ 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">
        function doSubmit(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            $("#correctDate").removeAttr("disabled");
            if(validateForm.form()){
                if(obj == 1){
                    // if(taskKey=='bmzr'){
                    //     var correctDate = new Date($("#correctDate").val().replace(/-/g, "/"));
                    //     var tryEndTime = new Date($("#tryEndTime").val().replace(/-/g, "/"));
                    //     if($("#correctOpinion").val()=='1'){
					//
                    //     }else if($("#correctOpinion").val()=='2'){//提前
                    //         if(correctDate.getTime()>tryEndTime.getTime()){
                    //             parent.layer.msg("新试用期结束日期不能大于试用期结束日期!", {icon: 5});
                    //             return false;
                    //         }
                    //     }else if($("#correctOpinion").val()=='3'){
                    //         if(correctDate.getTime()<tryEndTime.getTime()){
                    //             parent.layer.msg("新试用期结束日期不能小于试用期结束日期!", {icon: 5});
                    //             return false;
                    //         }
                    //     }
                    // }

                    $('#flag').val('yes');
                }else{
                    $('#flag').val('no');
                }
                $("#inputForm").submit();
                return true;
            }

            return false;
        }
        var validateForm;
        var count = 0;
        var taskKey;
        var defaultCorrectDate;
        $(document).ready(function() {
            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);
                    }
                }
            });
            defaultCorrectDate=$("#correctDate").val();
            taskKey="${workRegularApply.act.taskDefKey}";
            if(taskKey=='bmzr'){
                var value=$("#correctOpinion").val();
                getChange(value);
			}

			laydate.render({
				elem: '#correctDate',
				format: 'yyyy-MM-dd',
				type : 'date'
			});
        });
        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 getChange(value){
            if(value==1){
                $("#jobGradeButton").show();
                $("#correctDate").attr("disabled","disabled");
                $("#correctDate").val(defaultCorrectDate);
			}else if(value==2) {
                $("#jobGradeButton").show();
                $("#correctDate").removeAttr("disabled");
                laydate.render({
                    elem: '#correctDate',
                    format: 'yyyy-MM-dd',
                    type : 'date'
                });
			}else if(value==3){
                $("#jobGradeButton").hide();
                $("#correctDate").removeAttr("disabled");
                laydate.render({
                    elem: '#correctDate',
                    format: 'yyyy-MM-dd',
                    type : 'date'
                });
			}


        }

        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));
                        if(parseFloat(score)>100){
                            parent.layer.msg("鉴定得分合计不可超过100分!", {icon: 5});
                            $("#workRegularScoreList"+i+"_score").val('');
                            return false;
                        }
                    }
                }
            }
            $("#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/saveAudit" method="post" class="form-horizontal" >
			<form:hidden path="id"/>
			<form:hidden path="basicInfoId" id="basicInfoId"/>
			<form:hidden path="home"/>
			<form:hidden path="act.taskId"/>
			<form:hidden path="act.taskName"/>
			<form:hidden path="act.taskDefKey"/>
			<form:hidden path="act.procInsId"/>
			<form:hidden path="act.procDefId"/>
			<form:hidden id="flag" path="act.flag"/>
			<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">
							<form:input id="userId" readonly="true" path="workStaffBasicInfo.name" htmlEscape="false" class="form-control layui-input"/>
						</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">
						<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"  readonly="true"  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" value="${workRegularApply.summary}" cssStyle="resize: none" readonly="true" htmlEscape="false" rows="6"    maxlength="500" class="form-control "/>
					</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"style="margin-top: 20px">
					<label class="layui-form-label">部门评语：</label>
					<div class="layui-input-block">
						<c:choose>
							<c:when test="${workRegularApply.act.taskDefKey eq 'bmzr'}">
								<form:textarea path="comment" htmlEscape="false" rows="4"    maxlength="255" class="form-control "/>
							</c:when>
							<c:otherwise>
								<form:textarea path="comment" htmlEscape="false" rows="4"  readonly="true"   maxlength="255" class="form-control "/>
							</c:otherwise>
						</c:choose>
					</div>
				</div>

				<c:choose>
					<c:when test="${workRegularApply.act.taskDefKey eq 'bmzr'}">
						<%--<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="correctOpinion"  class=" form-control  simple-select">--%>
									<%--<form:option value="" label=""/>--%>
									<%--<form:options items="${fns:getDictList('correct_opinion')}" itemLabel="label" itemValue="value" htmlEscape="false"/>--%>
								<%--</form:select>--%>
							<%--</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">--%>
									<%--<sys:treeselectJob id="jobGrade" name="jobGrade.id" value="jobGrade.id" labelName="jobGrade.name" labelValue="${workRegularApply.jobGrade.name}"--%>
													   <%--title="职级类型" url="/workjobgrade/workJobGrade/treeData"  cssClass="form-control layui-input " allowClear="false" notAllowSelectParent="true"/>--%>
								<%--</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"  name="correctDate" type="text"   class="laydate-icondate form-control required layer-date  layui-input laydate-icon"--%>
									   <%--value="<fmt:formatDate value="${workRegularApply.correctDate}" pattern="yyyy-MM-dd"/>" readonly="true"/>--%>
							<%--</div>--%>
						<%--</div>--%>
					</c:when>
					<c:otherwise>
						<%--<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="${fns:getDictLabel(workRegularApply.correctOpinion, 'correct_opinion', '')}"/>--%>
							<%--</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=""  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>--%>
					</c:otherwise>
				</c:choose>

				<div class="layui-item layui-col-xs12 form-table-container" >
					<%--<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>--%>
									<%--<c:choose>--%>
										<%--<c:when test="${workRegularApply.act.taskDefKey eq 'ywbfzr'}">--%>
											<%--<td>--%>
												<%--<input id="workRegularScoreList${index.index}_score" onchange="getMoney(this.value,'1')"   name="workRegularScoreList[${index.index}].score" type="text" value="${workRegularScore.score}"   class="form-control number "/>--%>
											<%--</td>--%>
										<%--</c:when>--%>
										<%--<c:otherwise>--%>
											<%--<td>--%>
												<%--<form:input path="workRegularScoreList[${index.index}].score" id="workRegularScoreList${index.index}_score" htmlEscape="false" readonly="true" onchange="getMoney(this.value,'1')"    type="text" value="${workRegularScore.score}"   class="form-control"/>--%>
											<%--</td>--%>
										<%--</c:otherwise>--%>
									<%--</c:choose>--%>

								<%--</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">
				<div class="form-group-label"><h2>审批意见</h2></div>
				<div class="layui-item layui-col-xs12 with-textarea" >
					<label class="layui-form-label">审批意见：</label>
					<div class="layui-input-block">
						<c:choose>
							<c:when test="${workRegularApply.act.taskDefKey eq 'zzr'}">
								<form:textarea path="act.comment" readonly="true" class="form-control" rows="3" maxlength="127" />
							</c:when>
							<c:otherwise>
								<form:textarea path="act.comment" class="form-control" rows="3" maxlength="127" />
							</c:otherwise>
						</c:choose>
					</div>
				</div>
			</div>
			<div class="form-group layui-row">
				<div class="form-group-label"><h2>审批流程</h2></div>
				<div class="layui-item layui-col-xs12 form-table-container" >
					<act:flowChart procInsId="${workRegularApply.act.procInsId}"/>
					<act:histoicFlow procInsId="${workRegularApply.act.procInsId}"/>
				</div>
			</div>
			<div class="form-group layui-row page-end"></div>
		</form:form>
	</div>
</div>

</body>
</html>