<%@ 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;
		$(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: '#startTime', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus', //响应事件。如果没有传入event，则按照默认的click
						type : 'datetime'
			        });
					laydate.render({
			            elem: '#endTime', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus', //响应事件。如果没有传入event，则按照默认的click
						type : 'datetime'
			        });
		});
	</script>
	<script type="text/javascript">
		$(function () {
            $("#execute_btn").click(function () {
                var trLength = $("#file_attachment tr").length;
                if(trLength>=1){
                    top.layer.alert("项目实施文件只能上传一个,可以删除后重新上传",{icon:2});
                    return;
                }
                $("#execute_file").click();
            });
			$("#manuscript_btn").click(function () {
				$("#manuscript_file").click();
            });
        });


        function execute_insertTitle(tValue){
            var list = "${workFullExecute.executeFile}";
            var size = (list.split('url')).length-1;
            var files = $("#execute_file")[0].files;            for(var i = 0;i<files.length;i++) {                var file = files[i];
            var attachmentId = $("#id").val();
            var attachmentFlag = "2";
            //console.log(file);
            var timestamp=new Date().getTime();

            var storeAs = "attachment-file/workFullExecute/"+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 execute_del() {
            $("#execute_file").val("");
            $("#execute_title").text("");
            $("#execute_delete").remove();
            $("#execute_title_div").remove();
        }
        function manuscript_insertTitle(tValue){
            var list = "${workFullExecute.manuscriptFile}";
            var size = (list.split('url')).length-1;
            var files = $("#manuscript_file")[0].files;            for(var i = 0;i<files.length;i++) {                var file = files[i];
            var attachmentId = $("#id").val();
            var attachmentFlag = "3";
            var timestamp=new Date().getTime();

            var storeAs = "attachment-file/workFullExecute/"+timestamp+"/"+file['name'];
            var uploadPath="http://gangwan-app.oss-cn-hangzhou.aliyuncs.com/"+storeAs;/*将这段字符串存到数据库即可*/
            var divId = "_manuscript_attachment";
            $("#addFile"+divId).show();
            multipartUploadWithSts(storeAs, file,attachmentId,attachmentFlag,uploadPath,divId,size);}
            /*$("#manuscript_title_div").remove();
            var t1 = tValue.lastIndexOf("\\");
            if(t1 >= 0 && t1 < tValue.length){
                $("#manuscript_title").text(tValue.substring(t1+1));
                $("#manuscript_title").after("<div id='manuscript_title_div' style='float: right'>&nbsp;&nbsp;<span id='execute_delete' onclick='manuscript_del()'style='color: red ; cursor: pointer;'>x</span></div>");
            }*/
        }
        function manuscript_del() {
            $("#manuscript_file").val("");
            $("#manuscript_title").text("");
            $("#manuscript_delete").remove();
            $("#manuscript_title_div").remove();
        }
        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}/workfullexecute/workFullExecute/delFile',
                data:{"id":id,"attaId":attaId,"attachmentUrl":attachmentUrl},
                cache:false,
                success: function() {
                    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="workFullExecute"  method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="workFullManageId"/>
		<input type="hidden" name="listpage" value="${listpage}"/>
		<input type="hidden" value="${workFullManage.id}" id="workFullId">
		<input type="hidden" value="${workFullManage.fullProjectStatus}" id="status">
		<sys:message content="${message}"/>
		<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		   <tbody>
			   <tr>
				   <td class="width-15 active" rowspan="5"><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="fileName" 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="fileType" class="form-control required">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('work_full_execute_fileType')}" 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-40" colspan="3">
						<form:input path="fileTypeDeclare" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">编制开始日期：</label></td>
					<td class="width-30">
						<input id="startTime" name="startTime" type="text" maxlength="20" class="laydate-icondate form-control layer-date "
							value="<fmt:formatDate value="${workFullExecute.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
					</td>
					<td class="width-15 active"><label class="pull-right">编制完成日期：</label></td>
					<td class="width-30">
						<input id="endTime" name="endTime" type="text" maxlength="20" class="laydate-icondate form-control layer-date "
							value="<fmt:formatDate value="${workFullExecute.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
					</td>
				</tr>
			    <tr>
					<td class="width-15 active"><label class="pull-right">文件附件：</label></td>
					<td class="width-40" colspan="3">
						<div>
							<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>
									<input id="execute_file" type="file" name="execute_file" style="display: none;" onChange="if(this.value)execute_insertTitle(this.value);"/>
									<a id="execute_btn" class="btn btn-info btn-xs" ><i class="fa fa-plus"></i> 添加附件</a>
									<span id="execute_title"></span>
								</div>
								<table id="listExecuteFile"  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">
										<c:if test="${not empty workFullExecute.executeFile}">
											<c:forEach items="${workFullExecute.executeFile}" var="exeFile" varStatus="varStatus">
												<tr>
													<%--<td>${varStatus.index+1}</td>--%>
													<%--<td><span title="${exeFile.attachmentName}">${fns:abbr(exeFile.attachmentName, 20)}</span></td>--%>
													<c:choose>
														<c:when test="${fn:containsIgnoreCase(exeFile.attachmentName,'jpg')
													   or fn:containsIgnoreCase(exeFile.attachmentName,'png')
													   or fn:containsIgnoreCase(exeFile.attachmentName,'gif')
													   or fn:containsIgnoreCase(exeFile.attachmentName,'jpeg')}">
															<td><img src="${exeFile.url}" onclick="openDialogView(' ','${ctx}/sys/picturepreview/picturePreview?url=${exeFile.url}','860px','600px')" width="50" height="50" alt="${exeFile.attachmentName}"/></td>
														</c:when>
														<c:otherwise>
															<c:choose>
																<c:when test="${fn:containsIgnoreCase(exeFile.attachmentName,'pdf')}">
																	<td><a href="javascript:void(0)" onclick="preview('预览','${exeFile.url}','80%','80%','1')">
																		<span title="${exeFile.attachmentName}">${fns:abbr(exeFile.attachmentName, 30)}</span></a></td>
																</c:when>
																<c:otherwise>
																	<td><a href="javascript:void(0)" onclick="preview('预览','${exeFile.url}','80%','80%')">
																		<span title="${exeFile.attachmentName}">${fns:abbr(exeFile.attachmentName, 30)}</span>
																	</a></td>
																</c:otherwise>
															</c:choose>
														</c:otherwise>
													</c:choose>
													<td>${exeFile.attachmentUser}</td>
													<td><fmt:formatDate value="${exeFile.createDate}" pattern="yyyy-MM-dd"/></td>
													<td>
														<a href="${ctx}/workfullmanage/workFullManage/downLoadAttach?file=${exeFile.url}" class="btn btn-success btn-xs">下载</a>
														<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="delFile('${workFullExecute.id}','${exeFile.id}','${exeFile.url}',this)">删除</a>
													<%--<shiro:hasPermission name="workfullexecute:workFullExecute:delFile">--%>
															<%--<a href="${ctx}/workfullexecute/workFullExecute/delFile?id=${workFullExecute.id}&attachmentFlag=2" onclick="return confirmx('确认要删除该实施文件吗？', this.href)" class="btn btn-danger btn-xs">删除</a>--%>
														<%--</shiro:hasPermission>--%>
													</td>
												</tr>
											</c:forEach>
										</c:if>
								</table>
							</div>
						</div>
					</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-40" colspan="3">
					   <div>
						   <div style="float:left; height: 100%; width: 100%; ">
							   <div style="display: inline-block">
								   <div id="addFile_manuscript_attachment" style="display: none">
									   <div>
										   <span id="fileName_manuscript_attachment" ></span>
										   <b><span id="baifenbi_manuscript_attachment" ></span></b>
									   </div>
									   <div>
										   <div class="progress">
											   <div id="jindutiao_manuscript_attachment" class="progress-bar" style="width: 0%" aria-valuenow="0">
											   </div>
										   </div>
									   </div>
								   </div>
								   <input id="manuscript_file" type="file" name="manuscript_file" style="display: none;" onChange="if(this.value)manuscript_insertTitle(this.value);"/>
								   <a id="manuscript_btn" class="btn btn-info btn-xs" ><i class="fa fa-plus"></i> 添加附件</a>
								   <span id="manuscript_title"></span>
							   </div>
							   <table id="listManuscriptFile"  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_manuscript_attachment">
									<c:if test="${not empty workFullExecute.manuscriptFile}">
										<c:forEach items="${workFullExecute.manuscriptFile}" var="mFile" varStatus="varStatus">
											<tr>
												<%--<td>${varStatus.index + 1}</td>--%>
												<%--<td><span title="${mFile.attachmentName}">${fns:abbr(mFile.attachmentName, 30)}</span></td>--%>
												<c:choose>
													<c:when test="${fn:containsIgnoreCase(mFile.attachmentName,'jpg')
													   or fn:containsIgnoreCase(mFile.attachmentName,'png')
													   or fn:containsIgnoreCase(mFile.attachmentName,'gif')
													   or fn:containsIgnoreCase(mFile.attachmentName,'jpeg')}">
														<td><img src="${mFile.url}" onclick="openDialogView(' ','${ctx}/sys/picturepreview/picturePreview?url=${mFile.url}','860px','600px')" width="50" height="50" alt="${mFile.attachmentName}"/></td>
													</c:when>
													<c:otherwise>
														<c:choose>
															<c:when test="${fn:containsIgnoreCase(mFile.attachmentName,'pdf')}">
																<td><a href="javascript:void(0)" onclick="preview('预览','${mFile.url}','80%','80%','1')">
																	<span title="${mFile.attachmentName}">${fns:abbr(mFile.attachmentName, 30)}</span></a></td>
															</c:when>
															<c:otherwise>
																<td><a href="javascript:void(0)" onclick="preview('预览','${mFile.url}','80%','80%')">
																	<span title="${mFile.attachmentName}">${fns:abbr(mFile.attachmentName, 30)}</span>
																</a></td>
															</c:otherwise>
														</c:choose>
													</c:otherwise>
												</c:choose>
												<td>${mFile.attachmentUser}</td>
												<td><fmt:formatDate value="${mFile.createDate}" pattern="yyyy-MM-dd"/></td>
												<td>
													<a href="${ctx}/workfullmanage/workFullManage/downLoadAttach?file=${mFile.url}" class="btn btn-success btn-xs">下载</a>
													<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="delFile('${workFullExecute.id}','${mFile.id}','${mFile.url}',this)">删除</a>
												<%--<shiro:hasPermission name="workfullexecute:workFullExecute:delFile">--%>
														<%--<a href="${ctx}/workfullexecute/workFullExecute/delFile?id=${workFullExecute.id}&attachmentFlag=3" onclick="return confirmx('确认要删除该底稿吗？', this.href)" class="btn btn-danger btn-xs">删除</a>--%>
													<%--</shiro:hasPermission>--%>
												</td>
											</tr>
										</c:forEach>
									</c:if>
							   </table>
						   </div>
					   </div>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active" rowspan="5"><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">
					   <input value="${workFullManage.fullProjectNumber}" htmlEscape="false"  readonly="readonly"  class="form-control required"/>
				   </td>
				   <td class="width-15 active"><label class="pull-right"></font>项目来源：</label></td>
				   <td class="width-30">
					   <input value="${fns:getDictLabel(workFullManage.fullProjectSource, 'full_project_source', '')}" htmlEscape="false" readonly="readonly"   class="form-control required"/>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">项目名称：</label></td>
				   <td class="width-30" colspan="3">
					   <input value="${workFullManage.fullProjectName}" htmlEscape="false" readonly="readonly"   class="form-control "/>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right"><font color="red">*</font>行业分类：</label></td>
				   <td class="width-30">
					   <input value="${fns:getDictLabel(workFullManage.fullIndustryType, 'full_industry_type', '')}" htmlEscape="false"  readonly="readonly"  class="form-control required"/>
				   </td>
				   <td class="width-15 active"><label class="pull-right"></font>结构类型：</label></td>
				   <td class="width-30">
					   <input value="${fns:getDictLabel(workFullManage.fullStructureType, 'full_structure_type', '')}" htmlEscape="false" readonly="readonly"   class="form-control required"/>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">投资额(元)：</label></td>
				   <td class="width-40">
					   <input value="${workFullManage.fullInvestMoney}" htmlEscape="false" readonly="readonly"   class="form-control "/>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active" rowspan="5"><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">
					   <input value="${workFullManage.workClientInfo.name}" htmlEscape="false" readonly="readonly"   class="form-control "/>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">客户信用等级：</label></td>
				   <td class="width-30">
					   <input value="${workFullManage.workClientInfo.creditRank}" htmlEscape="false" readonly="readonly"   class="form-control "/>
				   </td>
				   <td class="width-15 active"><label class="pull-right">业主联系人：</label></td>
				   <td class="width-30">
					   <input value="${workFullManage.workClientInfo.workClientLinkman.name}" htmlEscape="false" readonly="readonly"   class="form-control "/>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">职务：</label></td>
				   <td class="width-30">
					   <input value="${workFullManage.workClientInfo.workClientLinkman.position}" htmlEscape="false" readonly="readonly"   class="form-control "/>
				   </td>
				   <td class="width-15 active"><label class="pull-right">联系方式：</label></td>
				   <td class="width-30">
					   <input value="${workFullManage.workClientInfo.workClientLinkman.linkPhone}" htmlEscape="false" readonly="readonly"   class="form-control "/>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">QQ：</label></td>
				   <td class="width-30">
					   <input value="${workFullManage.workClientInfo.workClientLinkman.qq}" htmlEscape="false" readonly="readonly"   class="form-control "/>
				   </td>
				   <td class="width-15 active"><label class="pull-right">Email：</label></td>
				   <td class="width-30">
					   <input value="${workFullManage.workClientInfo.workClientLinkman.email}" htmlEscape="false" readonly="readonly"   class="form-control "/>
				   </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">
						<input value="${workFullManage.hostCompany}" htmlEscape="false" readonly="readonly"   class="form-control "/>
					</td>
					<td class="width-15 active"><label class="pull-right">协办公司/部门：</label></td>
					<td class="width-30">
						<input value="${workFullManage.followCompany}" htmlEscape="false" readonly="readonly"   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">
					   <textarea htmlEscape="false" readonly="readonly"   class="form-control ">${workFullManage.hostMasterName}</textarea>
				   </td>
				   <td class="width-15 active"><label class="pull-right">主办公司/部门项目组成员：</label></td>
				   <td class="width-30">
					   <textarea htmlEscape="false" readonly="readonly"   class="form-control ">${workFullManage.hostMemberName}</textarea>
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">协办公司/部门负责人：</label></td>
				   <td class="width-30">
					   <textarea htmlEscape="false" readonly="readonly"   class="form-control ">${workFullManage.followMasterName}</textarea>
				   </td>
				   <td class="width-15 active"><label class="pull-right">协办公司/部门项目组成员：</label></td>
				   <td class="width-30">
					   <textarea htmlEscape="false" readonly="readonly"   class="form-control ">${workFullManage.followMemberName}</textarea>
				   </td>
			   </tr>
		   </tbody>
		</table>
	</form:form>
</body>
</html>