<%@ 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);
					}
				}
			});
		});

        $(function () {
            $("#attachment_btn").click(function () {
                $("#attachment_file").click();
            });
        })
        function attachment_insertTitle(tValue){
            var list = "${workFullConstructsheet.workAttachments}";
            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 = "47";
            console.log(file);
            var timestamp=new Date().getTime();

            var storeAs = "attachment-file/workFullConstructsheet/"+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);}
           /* $("#attachment_title_div").remove();
            var t1 = tValue.lastIndexOf("\\");
            if(t1 >= 0 && t1 < tValue.length){
                $("#attachment_title").text(tValue.substring(t1+1));
                $("#attachment_title").after("<div id='attachment_title_div' style='float: right'>&nbsp;&nbsp;<span id='attachment_delete' onclick='attachment_del()'style='color: red ; cursor: pointer;'>x</span></div>");
            }*/
        }
        function attachment_del() {
            $("#attachment_file").val("");
            $("#attachment_title").text("");
            $("#attachment_delete").remove();
            $("#attachment_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}/workfullconstructsheet/workFullConstructsheet/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="workFullConstructsheet" enctype="multipart/form-data" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="workFullManageId"/>
		<input type="hidden" name="listpage" value="${listpage}"/>
		<sys:message content="${requestScope.message}"/>
		<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		   <tbody>
		   		<tr>
					<td class="width-15 active" rowspan="9"><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">
						${workFullManage.constructId.unitName}
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>联系单主题：</label></td>
					<td class="width-40" colspan="3">
						<form:input path="constructsheetTopic" htmlEscape="false"    class="form-control required"/>
					</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="projectNumber" 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:input path="constructsheetNumber" htmlEscape="false"    class="form-control required"/>
					</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="constructSection" htmlEscape="false"    class="form-control required"/>
					</td>
					<td class="width-15 active"><label class="pull-right">是否产生费用增减：</label></td>
					<td class="width-30">
						<form:radiobuttons path="costIncreaseDecrease" items="${fns:getDictList('cost_increase_decrease')}" itemLabel="label" itemValue="value" htmlEscape="false" class="i-checks "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">业主处理意见：</label></td>
					<td class="width-40" colspan="3">
						<form:textarea path="proprietorComment" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">变更原因及主要内容：</label></td>
					<td class="width-40" colspan="3">
						<form:textarea path="changeContext" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">备注信息：</label></td>
					<td class="width-40" colspan="3">
						<form:textarea path="remarks" htmlEscape="false"     class="form-control "/>
					</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="attachment_file" type="file" name="attachment_file" style="display: none;" multiple="multiple" onChange="if(this.value)attachment_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 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_attachment">
										<c:if test="${not empty workFullConstructsheet.workAttachments}">
											<c:forEach items="${workFullConstructsheet.workAttachments}" var="attachment" varStatus="varStatus">
												<tr>
												<%--	<td>${varStatus.index+1}</td>--%>
													<%--<td><span title="${attachment.attachmentName}">${fns:abbr(attachment.attachmentName, 30)}</span></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')}">
															<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:when>
														<c:otherwise>
															<c:choose>
																<c:when test="${fn:containsIgnoreCase(attachment.attachmentName,'pdf')}">
																	<%--<td><a href="${workFullConstructsheet.workattachment.url}"><span title="${workFullConstructsheet.workattachment.attachmentName}">${fns:abbr(workFullConstructsheet.workattachment.attachmentName, 20)}</span></a></td>--%>
																	<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="openDialogViewPre('预览','${ctx}/previewController/previewUrl?fileUrl=${workFullConstructsheet.workattachment.url}','80%','80%')"><span title="${workFullConstructsheet.workattachment.attachmentName}">${fns:abbr(workFullConstructsheet.workattachment.attachmentName, 20)}</span></a></td>--%>
																	<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="${ctx}/workfullmanage/workFullManage/downLoadAttach?file=${attachment.url}" class="btn btn-success btn-xs">下载</a>
														<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="delFile('${workFullConstructsheet.id}','${attachment.id}','${attachment.url}',this)">删除</a>
													<%--<shiro:hasPermission name="workfullconstructsheet:workFullConstructsheet:delFile">--%>
															<%--<a href="${ctx}/workfullconstructsheet/workFullConstructsheet/delFile?id=${workFullConstructsheet.id}&attachmentFlag=47" onclick="return confirmx('确认要删除该附件吗？', this.href)">删除</a>--%>
														<%--</shiro:hasPermission>--%>
													</td>
												</tr>
											</c:forEach>
										</c:if>
									</tbody>
								</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">项目编号：</label></td>
					<td class="width-30">
							${workFullManage.fullProjectNumber}
					</td>
					<td class="width-15 active"><label class="pull-right">项目来源：</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">
							${workFullManage.fullProjectName}
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">行业分类：</label></td>
					<td class="width-30">
							${fns:getDictLabel(workFullManage.fullIndustryType, 'full_industry_type', '')}
					</td>
					<td class="width-15 active"><label class="pull-right">结构类型：</label></td>
					<td class="width-30">
							${fns:getDictLabel(workFullManage.fullStructureType, 'full_structure_type', '')}
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">投资额(元)：</label></td>
					<td class="width-40">
							${workFullManage.fullInvestMoney}
					</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-40" colspan="3">
							${workFullManage.workClientInfo.name}
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">客户信用等级：</label></td>
					<td class="width-30">
							${workFullManage.workClientInfo.creditRank}
					</td>
					<td class="width-15 active"><label class="pull-right">业主联系人：</label></td>
					<td class="width-30">
							${workFullManage.workClientInfo.workClientLinkman.name}
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">职务：</label></td>
					<td class="width-30">
							${workFullManage.workClientInfo.workClientLinkman.position}
					</td>
					<td class="width-15 active"><label class="pull-right">联系方式：</label></td>
					<td class="width-30">
							${workFullManage.workClientInfo.workClientLinkman.linkPhone}
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">QQ：</label></td>
					<td class="width-30">
							${workFullManage.workClientInfo.workClientLinkman.qq}
					</td>
					<td class="width-15 active"><label class="pull-right">Email：</label></td>
					<td class="width-30">
							${workFullManage.workClientInfo.workClientLinkman.email}
					</td>
				</tr>
		 	</tbody>
		</table>
	</form:form>
</body>
</html>