<%@ 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;
		}
		
		$('#btnPresent').click(function () { 

			$.ajax({
	             url:"${ctx}/worksealform/workSealForm/present",
	             data:$('#loginForm').serialize(),
	             type:"post",
	             success:function(data){
	        
	             }					
		});
		});	
			
		$(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);
					}
				}
			});
            $('input,textarea,select').attr('disabled',<%=request.getAttribute("disabled")%>);
            if (${requestScope.disabled eq 'false'}) {
                $("#applicationDate").attr('disabled',true);
                $("#documentName").attr('disabled',true);
                $("#reason").attr('disabled',true);
                $("#documentCount").attr('disabled',true);
                $("#sealType").attr('disabled',true);
            }
		});
	</script>
</head>

<body class="gray-bg">

  <div class="wrapper wrapper-content">
	<div class="ibox">
	<div class="ibox-title">
		<h5>用印详情 </h5>
		<div class="ibox-tools">
			<a class="collapse-link">
				<i class="fa fa-chevron-up"></i>
			</a>
			<a class="dropdown-toggle" data-toggle="dropdown" href="javascript:void(0)">
				<i class="fa fa-wrench"></i>
			</a>
			<ul class="dropdown-menu dropdown-user">
				<li><a href="javascript:void(0)">选项1</a>
				</li>
				<li><a href="javascript:void(0)">选项2</a>
				</li>
			</ul>
			<a class="close-link">
				<i class="fa fa-times"></i>
			</a>
		</div>
	</div>
		<div class="ibox-content">
		<form:form id="inputForm" modelAttribute="workSealForm" action="${ctx}/worksealform/workSealForm/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="${workSealForm.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="applicationDate" name="applicationDate" type="text" readonly="readonly" maxlength="20" class="laydate-icon form-control layer-date required"
							   value="${workSealForm.applicationDate}"/></c:when>
					<c:otherwise>
						${workSealForm.applicationDate}
					</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 path="reason" readonly="readonly" class="form-control required" rows="3" maxlength="20"/>
						</c:when>
						<c:otherwise>
							${workSealForm.reason}
						</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="documentName" name="documentName" readonly="readonly" type="text" class="form-control required"
								   value="${workSealForm.documentName}"/></c:when>
						<c:otherwise>
							${workSealForm.documentName}
						</c:otherwise>
					</c:choose>
					<span class="help-inline"></span>
				</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="documentCount" name="documentCount" readonly="readonly" type="text" class="form-control required"
								   value="${workSealForm.documentCount}"/></c:when>
						<c:otherwise>
							${workSealForm.documentCount}
						</c:otherwise>
					</c:choose>
					<span class="help-inline"></span>
				</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="sealType" name="sealType" type="text" disabled="true" class="form-control required" value="${fns:getMainDictLabel(workSealForm.sealType, 'seal_type', '')}"/>
						</c:when>
						<c:otherwise>
							${fns:getMainDictLabel(workSealForm.sealType, 'seal_type', '')}
						</c:otherwise>
					</c:choose>
					<span class="help-inline"></span>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label">附件信息：</label>
				<div id="fileid" class="controls">
					<table id="workReportList"  style="text-align: center;width: 100%;margin-top:10px;"  class="table table-striped table-bordered table-condensed" >
						<thead>
						<tr>
							<%--<td>序号</td>--%><td>文件名</td><td>上传人</td><td>上传时间</td><td>操作</td>
						</tr>
						</thead>
						<tbody id="file_attachment_report">
						<c:forEach items="${workSealForm.workAttachments}" var="attachment" varStatus="index">
							<tr>
								<%--<td>${index.index + 1}</td>--%>
								<c:choose>
									<c:when test="${fn:containsIgnoreCase(attachment.attachmentName,'jpg')
                                                               or fn:containsIgnoreCase(attachment.attachmentName,'png')
                                                               or fn:containsIgnoreCase(attachment.attachmentName,'gif')
                                                               or fn:containsIgnoreCase(attachment.attachmentName,'bmp')
                                                               or fn:containsIgnoreCase(attachment.attachmentName,'jpeg')}">
										<td><img src="${attachment.url}" width="50" height="50" alt="${fns:abbr(attachment.attachmentName,30)}"/></td>
									</c:when>
									<c:otherwise>
										<c:choose>
											<c:when test="${fn:containsIgnoreCase(attachment.attachmentName,'pdf')}">
												<td><a href="javascript:void(0)" onclick="preview('预览','${attachment.url}','80%','80%','1')"><span title="${attachment.attachmentName}">${fns:abbr(attachment.attachmentName,30)}</span></a></td>
											</c:when>
											<c:otherwise>
												<td><a href="javascript:void(0)" onclick="preview('预览','${attachment.url}','80%','80%')"><span title="${attachment.attachmentName}">${fns:abbr(attachment.attachmentName,30)}</span></a></td>
											</c:otherwise>
										</c:choose>
									</c:otherwise>
								</c:choose>
								<td>${attachment.attachmentUser}</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>--%>
									<a href="javascript:void(0)" onclick="deleteFileFromAliyun(this,'${ctx}/workengineeringproject/workEngineeringProject/deleteFileFromAliyun?attachmentId=${attachment.id}&id=${workEngineeringProject.id}&type=2')" class="btn btn-danger btn-xs" >删除</a>
								</td>
							</tr>
						</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
			<c:if test="${not empty status}">
				<div class="control-group">
					<label class="control-label">审批意见：</label>
					<div class="controls">
						<form:textarea path="act.comment" class="form-control" rows="3" maxlength="127"/>
					</div>
				</div>
				<%--<div class="form-actions">
				<c:if test="${workSealForm.act.taskDefKey ne 'apply_end'}">
						<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>
		</br>
		</br>
			<act:flowChart procInsId="${workSealForm.act.procInsId}"/>
			<act:histoicFlow procInsId="${workSealForm.act.procInsId}"/>
	</form:form>
	</div>
	</div>
	</div>
</body>
</html>