<%@ 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(){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		  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: '#birthday', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus' //响应事件。如果没有传入event，则按照默认的click
            });
            laydate.render({
                elem: '#createDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus' //响应事件。如果没有传入event，则按照默认的click
            });
            $("#attachment_btn").click(function () {
                $("#attachment_file").click();
            });
		});
	</script>
	<script type="text/javascript">
        var currentTime;
        $(function () {
            currentTime = new Date().getTime();
            $("#currentTime").val(currentTime);
			$(".file_input").hide();
        })
        function clickFileBtn() {
            $("#fileUploadInput").click();
        }
        function insertTitle(tValue) {
            var list = "${judgeAttachmentList}";
            var size = (list.split('url')).length-1;
            var files = $("#attachment_file")[0].files;
            for(var i = 0;i<files.length;i++) {
                var file = files[i];
            var attachmentId = $("#id").val();
            var attachmentFlag = "65";
            var timestamp=new Date().getTime();

            var storeAs = "attachment-file/judgeAttachment/"+timestamp+"/"+file['name'];
            var uploadPath="http://gangwan-app.oss-cn-hangzhou.aliyuncs.com/"+storeAs;/*将这段字符串存到数据库即可*/
            var divId = "_attachment";
            $("#addFile"+divId).show();
            multipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size);
            }
        }

        function delFile(id,attaId,attachmentUrl,obj) {
            var loadingMessage = parent.layer.load(0, {shade: [0.1,'#393d49']});
            var tr = $(obj).parent().parent();
			$.ajax({
				type:'POST',
				dataType:'json',
				url:'${ctx}/sys/judge/delFile',
				data:{"id":id,"attaId":attaId,"attachmentUrl":attachmentUrl},
				cache:false,
                success: function() {
				    //先修改序号，再删除
                    $(tr).nextAll().each(function (i,n) {
                        var num = $(n).find("td:first").text().trim();
                        $(n).find("td:first").text(parseInt(num)-1);
                    });
                    tr.remove();
                    parent.layer.msg("删除成功！！！",{icon:6});
                    parent.layer.close(loadingMessage);
                },
				error:function () {
                    parent.layer.msg("删除失败！！！",{icon:3});
                    parent.layer.close(loadingMessage);
                }
			});
        }
	</script>
</head>
<body class="hideScroll">
		<form:form id="inputForm" modelAttribute="judge" action="${ctx}/sys/judge/save"  method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<input type="hidden" id="currentTime" name="currentTime"/>
		<sys:message content="${message}"/>	
		<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		   <tbody>
			   <tr>
				   <td class="width-15 active" rowspan="11"><label class="pull-right">评委信息：</label></td>
			   </tr>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>姓名：</label></td>
					<td class="width-30">
						<form:input path="name" htmlEscape="false"    class="form-control required"/>
					</td>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>性别：</label></td>
					<td class="width-30">
						<form:select path="gender" class="form-control required">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('sex')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">编号：</label></td>
					<td class="width-30">
						<form:input path="number" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">出生年月：</label></td>
					<td class="width-30">
						<input id="birthday" name="birthday" type="text" maxlength="20" class="laydate-icondate form-control layer-date "
							   value="<fmt:formatDate value="${judge.birthday}" pattern="yyyy-MM-dd"/>"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">联系电话：</label></td>
					<td class="width-30">
						<form:input path="mobile" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">qq：</label></td>
					<td class="width-30">
						<form:input path="qq" htmlEscape="false"    class="form-control  number"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">身份证号：</label></td>
					<td class="width-30">
						<form:input path="idcard" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">email：</label></td>
					<td class="width-30">
						<form:input path="email" htmlEscape="false"    class="form-control  email"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">家庭住址：</label></td>
					<td class="width-30" colspan="3">
						<form:input path="address" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">工作单位：</label></td>
					<td class="width-30" colspan="3">
						<form:input path="companyName" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">注册资格：</label></td>
					<td class="width-30">
						<form:input path="registrationQualification" htmlEscape="false"    class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">职称：</label></td>
					<td class="width-30">
						<form:select path="titleLevel" class="form-control ">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('title_level')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>咨询类型：</label></td>
					<td class="width-30">
						<form:select path="consultType" class="form-control required">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('consult_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</td>
					<td class="width-15 active"><label class="pull-right">咨询专业：</label></td>
					<td class="width-30">
						<form:select path="consultProfession" class="form-control ">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('consult_profession')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">入库日期：</label></td>
					<td class="width-30">
						<c:if test="${empty judge.id}">
							${fns:getDate("yyyy-MM-dd")}
						</c:if>
						<c:if test="${not empty judge}">
							<fmt:formatDate value="${judge.createDate}" pattern="yyyy-MM-dd"/>
						</c:if>
					</td>
					<td class="width-15 active"><label class="pull-right">是否退休：</label></td>
					<td class="width-30">
						<form:select path="isRetire" class="form-control ">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('is_retire')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">工作业绩：</label></td>
					<td class="width-30" colspan="3">
						<form:textarea path="performance" htmlEscape="false" rows="2"    class="form-control "/>
					</td>
				</tr>
			   <tr>
				   <td class="width-15 active" rowspan="3"><label class="pull-right">执业资格：</label></td>
			   </tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">执业资格：</label></td>
					<td class="width-30" colspan="3">

						<form:checkboxes path="qualificationCredentials" items="${fns:getDictList('qualification_credentials')}" itemLabel="label" itemValue="value" htmlEscape="false" class="i-checks "/>
						<script type="text/javascript">
							$(function () {
                                var qs = [${judge.qualificationCredentials}];
                                $("input[name='qualificationCredentials']").each(function () {
                                    var q = parseInt($(this).val());
                                    if($.inArray(q,qs) != -1){
                                        $(this).parent("div").addClass("checked");
                                    }
                                });
                            })
						</script>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">其他执业资格说明：</label></td>
					<td class="width-30" colspan="3">
						<form:textarea path="qualificationCredentialsMore" htmlEscape="false" rows="2"    class="form-control "/>
					</td>
				</tr>
			   <tr>
				   <td class="width-15 active" rowspan="2"><label class="pull-right">附件管理：</label></td>
			   </tr>
			   <tr>
				   <td class="width-30" colspan="4">
					   <div style="float:left; height: 100%; width: 100%; ">
						   <div style="display: inline-block">
					   			<div id="addFile_attachment" style="display: none">
								   <div>
									   <span id="fileName_attachment" ></span>
									   <b><span id="baifenbi_attachment" ></span></b>
								   </div>
								   <div>
									   <div class="progress">
										   <div id="jindutiao_attachment" class="progress-bar" style="width: 0%" aria-valuenow="0">
										   </div>
									   </div>
									</div>
					   			</div>
						   </div>
                           <input id="attachment_file" type="file" name="attachment_file" multiple="multiple" style="display: none;" onChange="if(this.value)insertTitle(this.value);"/>
						   <a id="attachment_btn" class="btn btn-info btn-xs" ><i class="fa fa-plus"></i> 添加附件</a>
						   <span id="attachment_title"></span>
					   </div>
					   <table  style="text-align: center;width: 100%;margin-top:10px;"  class="table table-striped table-bordered table-condensed" >
					   <thead>
					   	<%--<td>序号</td>--%><td>文件名</td><td>上传人</td><td>上传时间</td><td>操作</td>
					   </thead>
					   <tbody id="file_attachment" >
					   <c:forEach items="${judgeAttachmentList}" var="attachment" varStatus="varStatus">
						   <tr>
							  <%-- <td>${varStatus.index + 1 }</td>--%>
							   <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,'jpeg')}">
										   <img src="${attachment.url}" onclick="openDialogView(' ','${ctx}/sys/picturepreview/picturePreview?url=${attachment.url}','860px','600px')" width="50" height="50" alt="${attachment.attachmentName}"/>
									   </c:when>
									   <c:otherwise>
										   <c:choose>
											   <c:when test="${fn:containsIgnoreCase(attachment.attachmentName,'pdf')}">
												   <a href="javascript:void(0)" onclick="preview('预览','${attachment.url}','80%','80%','1')">
													   <span title="${attachment.attachmentName}">${fns:abbr(attachment.attachmentName, 30)}</span></a>
											   </c:when>
											   <c:otherwise>
												   <a href="javascript:void(0)" onclick="preview('预览','${attachment.url}','80%','80%')">
													   <span title="${attachment.attachmentName}">${fns:abbr(attachment.attachmentName, 30)}</span>
												   </a>
											   </c:otherwise>
										   </c:choose>
									   </c:otherwise>
								   </c:choose>
							   </td>
							   <td>${attachment.attachmentUser}</td>
							   <td><fmt:formatDate value="${attachment.createDate}" pattern="yyyy-MM-dd"/> </td>
							   <td>
								  <%-- <a href="${ctx}/workfullmanage/workFullManage/downLoadAttach?file=${attachment.url}" class="btn btn-success btn-xs">下载</a>--%>
								   <a href="javascript:location.href='${ctx}/workfullmanage/workFullManage/downLoadAttach?file='+encodeURIComponent('${attachment.url}');" class="btn btn-success btn-xs">下载</a>
								   <a class="delFile btn btn-danger btn-xs" href="javascript:void(0)" onclick="delFile('${judge.id}','${attachment.id}','${attachment.url}',this)">删除</a>
								   <%--href="${ctx}/sys/judge/delFile?id=${judge.id}&attId=${attachment.id}&attachmentUrl=${attachment.url}"--%>
							   </td>
						   </tr>
					   </c:forEach>
					   </tbody>
				   </table>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active" rowspan="2"><label class="pull-right">备注信息：</label></td>
			   </tr>
		   		<tr>
					<td class="width-15 active"><label class="pull-right">备注信息：</label></td>
					<td class="width-30" colspan="3">
						<form:textarea path="remarks" htmlEscape="false" rows="2"    class="form-control "/>
					</td>
				</tr>
		 	</tbody>
		</table>
	</form:form>
</body>
</html>