<%@ 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(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		  if(validateForm.form()){
              if(obj == 1){
                  $('#flag').val('yes');
              }else{
                  $('#flag').val('no');
              }
			  $("#inputForm").submit();
			  return true;
		  }
	
		  return false;
		}
		$(document).ready(function() {
			$("#name").focus();
			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);
					}
				}
			});
            //只做查看时，禁用掉以下标签
            $('input,textarea,select').attr('disabled',<%=request.getAttribute("disabled")%>);
            if (${requestScope.disabled eq 'false'}) {
                $("#leaveType").attr('disabled',true);
                $("#startTime").attr('disabled',true);
                $("#endTime").attr('disabled',true);
                $("#reason").attr('disabled',true);
			}
		});
	</script>
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content">
	<div class="ibox">
	<div class="ibox-title">
		<h5>审批详情</h5>
	</div>
	<div class="ibox-content">
	<form:form id="inputForm" modelAttribute="leave" action="${ctx}/oa/leave/saveAudit" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<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"/>
		<sys:message content="${message}"/>
		<c:set var="status" value="${leave.act.status}" />
		<div class="control-group">
			<label class="control-label">请假类型：</label>
			<div class="controls" style="margin-top: 8px;">
				<c:choose>
					<c:when test="${!disabled}">
						<input id="leaveType" name="leaveType" type="text" disabled="true" class="form-control required" value="${fns:getDictLabel(leave.leaveType, 'oa_leave_type', '')}"/>
					</c:when>
					<c:otherwise>
						${fns:getDictLabel(leave.leaveType, 'oa_leave_type', '')}
					</c:otherwise>
				</c:choose>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">开始时间：</label>
			<div class="controls" style="margin-top: 8px;">
				<c:choose>
					<c:when test="${!disabled}">
						<input id="startTime" name="startTime" type="text" disabled="true" maxlength="20" class="laydate-icon form-control layer-date required"
							   value="${leave.startTime}"/></c:when>
					<c:otherwise>
						${leave.startTime}
					</c:otherwise>
				</c:choose>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">结束时间：</label>
			<div class="controls" style="margin-top: 8px;">
				<c:choose>
					<c:when test="${!disabled}">
						<input id="endTime" name="endTime" type="text" disabled="true" maxlength="20" class="laydate-icon form-control layer-date required"
							   value="${leave.endTime}"/></c:when>
					<c:otherwise>
						${leave.endTime}
					</c:otherwise>
				</c:choose>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">请假原因：</label>
			<div class="controls" style="margin-top: 8px;">
				<c:choose>
					<c:when test="${!disabled}">
						<form:textarea id="reason" path="reason" class="form-control required" rows="5" maxlength="20"/>
					</c:when>
					<c:otherwise>
						${leave.reason}
					</c:otherwise>
				</c:choose>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">图片：</label>
			<div class="controls">
				<table style="text-align: center;width: 100%;margin-top:10px;" class="table table-striped table-bordered table-condensed" >
					<tr>
						<%--<td>序号</td>--%><td>文件名</td><td>上传人</td><td>上传时间</td><td>操作</td>
					</tr>
					<c:if test="${not empty leave.workattachmentList}">
						<c:forEach items="${leave.workattachmentList}" var="attachment" varStatus="varStatus">
							<tr>
								<%--<td>${varStatus.index+1}</td>--%>
								<c:if test="${fn:containsIgnoreCase(attachment.attachmentName,'jpg')
												   or fn:containsIgnoreCase(attachment.attachmentName,'png')
												   or fn:containsIgnoreCase(attachment.attachmentName,'gif')
												   or fn:containsIgnoreCase(attachment.attachmentName,'jpeg')}">
									<td><img src="${attachment.url}" onclick="openDialogView(' ','${ctx}/sys/picturepreview/picturePreview?url=${attachment.url}','860px','600px')" width="50" height="50" alt="${attachment.attachmentName}"/></td>
								</c:if>
								<td>${fns:getUserById(attachment.attachmentUser).name}</td>
								<td><fmt:formatDate value="${attachment.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
									<td>
										<a href="javascript:location.href='${ctx}/workfullmanage/workFullManage/downLoadAttach?file='+encodeURIComponent('${attachment.url}');" class="btn btn-success btn-xs">下载</a>

										<%--<a href="${ctx}/workfullmanage/workFullManage/downLoadAttach?file=${attachment.url}" class="btn btn-success btn-xs">下载</a>
									--%></td>
							</tr>
						</c:forEach>
					</c:if>
				</table>
			</div>
		</div>
		<c:if test="${not empty status}">
			<div class="control-group" id="comment">
				<label class="control-label">审批意见：</label>
				<div class="controls">
					<form:textarea path="act.comment" class="form-control" rows="5" maxlength="127"/>
				</div>
			</div>
			<%--<div class="form-actions">
					<c:if test="${leave.act.taskDefKey eq 'audit1'}">
						<input id="btnSubmit" class="btn btn-primary" type="submit" value="同 意" onclick="$('#flag').val('yes')"/>&nbsp;
						<input id="btnSubmit" class="btn btn-inverse" type="submit" value="驳 回" onclick="$('#flag').val('no')"/>&nbsp;
					</c:if>
				<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
			</div>--%>
		</c:if>
		<act:flowChart procInsId="${leave.act.procInsId}"/>
		<act:histoicFlow procInsId="${leave.act.procInsId}"/>
	</form:form>
</div>
	</div>
	</div>
</body>
</html>

