<%@ 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 == 2){
                  $("#inputForm").attr("action","${ctx}/workvisa/workVisa/store");
              }else if (obj == 3){
                  $("#inputForm").attr("action","${ctx}/workvisa/workVisa/save");
              }else if (obj == 4){
                  $("#inputForm").attr("action","${ctx}/workvisa/workVisa/store");
              }else{
                  $("#inputForm").attr("action","${ctx}/workvisa/workVisa/save");
              }
              $("#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);
					}
				}
			});
			
		});

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

            var storeAs = "attachment-file/workVisa/"+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);}
        }

	</script>
</head>
<body class="hideScroll">
		<form:form id="inputForm" modelAttribute="workVisa" method="post" enctype="multipart/form-data" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="fullManage.id" value="${workFullManage.id}"/>
		<sys:message content="${message}"/>
		<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		   <tbody>
			   <tr>
				   <td class="width-20 active" rowspan="6"><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-25">
						<form:input path="initiateClient" htmlEscape="false"    class="form-control required"/>
					</td>
					<td class="width-15 active"><label class="pull-right">单位工程名称：</label></td>
					<td class="width-25">
						<form:input path="cprojectName" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
			   <tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>施工标段：</label></td>
					<td class="width-25">
						<form:input path="constructionExample" htmlEscape="false"    class="form-control required"/>
					</td>
				   <td class="width-15 active"><label class="pull-right">签证单编号：</label></td>
				   <td class="width-25">
					   <form:input path="visaNumber" htmlEscape="false"   readonly="true" class="form-control required"/>
				   </td>
			   </tr>
			   <tr>
					<td class="width-15 active"><label class="pull-right">签证范围：</label></td>
					<td class="width-25">
						<form:input path="visaArea" htmlEscape="false"    class="form-control "/>
					</td>
				   <td class="width-15 active"><label class="pull-right"><font color="red">*</font>主题内容：</label></td>
				   <td class="width-25">
					   <form:input path="theme" htmlEscape="false"    class="form-control required"/>
				   </td>
			   </tr>
			   <tr>
					<td class="width-15 active"><label class="pull-right">签证单主要内容：</label></td>
					<td class="width-25" colspan="3">
						<form:textarea path="visaContent" htmlEscape="false" rows="4"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">审价批复意见：</label></td>
					<td class="width-25" colspan="3">
						<form:textarea path="replySuggest" htmlEscape="false" rows="4"    class="form-control "/>
					</td>
					<%--<td class="width-15 active"><label class="pull-right">全过程管理项目：</label></td>--%>
					<%--<td class="width-35">--%>
						<%--<sys:gridselect url="${ctx}/workvisa/workVisa/selectfullManage" id="fullManage" name="fullManage.id"  value="${workVisa.fullManage.id}"  title="选择全过程管理项目" labelName="fullManage.id" --%>
						 <%--labelValue="${workVisa.fullManage.id}" cssClass="form-control required" fieldLabels="全过程项目表" fieldKeys="WorkFullManage" searchLabel="id" searchKey="id" ></sys:gridselect>--%>
					<%--</td>--%>
				</tr>
			<%--   <tr>
				   <td class="width-15 active"><label class="pull-right">备注信息：</label></td>
				   <td class="width-25" colspan="3">
					   <form:textarea path="remarks" htmlEscape="false" rows="4"    class="form-control "/>
				   </td>
			   </tr>--%>
			   <tr>
				   <td class="width-20 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-25">
						   ${workFullManage.fullProjectNumber}
				   </td>
				   <td class="width-15 active"><label class="pull-right">项目来源：</label></td>
				   <td class="width-25">
						   ${fns:getDictLabel(workFullManage.fullProjectSource, 'full_project_source', '')}
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">项目名称：</label></td>
				   <td class="width-25">
						   ${workFullManage.fullProjectName}
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">行业分类：</label></td>
				   <td class="width-25">
						   ${fns:getDictLabel(workFullManage.fullIndustryType, 'full_industry_type', '')}
				   </td>
				   <td class="width-15 active"><label class="pull-right">结构类型：</label></td>
				   <td class="width-25">
						   ${fns:getDictLabel(workFullManage.fullStructureType, 'full_structure_type', '')}
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">投资额（元）：</label></td>
				   <td class="width-25">
						   ${workFullManage.fullInvestMoney}
				   </td>
			   </tr>
			   <tr>
				   <td class="width-20 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-25" colspan="3">
					   <input type="hidden" id="clientId" name="clientId" value="${workFullManage.workClientInfo.id}"/>
						   ${workFullManage.workClientInfo.name}
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">客户信用等级：</label></td>
				   <td class="width-25">
						   ${workFullManage.workClientInfo.creditRank}
				   </td>
				   <td class="width-15 active"><label class="pull-right">业主联系人：</label></td>
				   <td class="width-25">
						   ${workFullManage.workClientInfo.workClientLinkmanList[0].name}
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">职务：</label></td>
				   <td class="width-25">
						   ${workFullManage.workClientInfo.workClientLinkmanList[0].position}
				   </td>
				   <td class="width-15 active"><label class="pull-right">联系方式：</label></td>
				   <td class="width-25">
						   ${workFullManage.workClientInfo.workClientLinkmanList[0].linkPhone}
				   </td>
			   </tr>
			   <tr>
				   <td class="width-15 active"><label class="pull-right">QQ：</label></td>
				   <td class="width-25">
						   ${workFullManage.workClientInfo.workClientLinkmanList[0].qq}
				   </td>
				   <td class="width-15 active"><label class="pull-right">Email：</label></td>
				   <td class="width-25">
						   ${workFullManage.workClientInfo.workClientLinkmanList[0].email}
				   </td>
			   </tr>

			   <tr>
				   <td class="width-25" colspan="4">
					   <div style="width: 580px; ">
						   <div style="float:left;width: 80px; height: 100%; ">
							   附件
						   </div>
						   <div style="float:left; height: 100%; width: 500px; ">
							   <div style="display: inline-block">
								   <div id="addFile_attachment" style="display: none">
									   <span id="fileName_attachment" ></span>
									   <b><span id="baifenbi_attachment" ></span></b>
									   <div class="progress">
										   <div id="jindutiao_attachment" class="progress-bar" style="width: 0%" aria-valuenow="0">
										   </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 id="listAttachment"  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:forEach items="${workAttachments}" var="attachment" varStatus="index">
									   <tr>
										   <%--<td>${index.index + 1}</td>--%>
										   <td>${attachment.attachmentName}</td>
										   <td>${attachment.attachmentUser}</td>
										   <td><fmt:formatDate value="${attachment.createDate}" pattern="yyyy-MM-dd"/></td>
										   <td>
											   <a href="javascript:location.href='${ctx}/workfullmanage/workFullManage/downLoadAttach?file='+encodeURIComponent('${attachment.url}');" class="btn btn-success btn-xs">下载</a>

											  <%-- <a href="${attachment.url}">下载</a>--%>
											   <a href="${ctx}/workvisa/workVisa/deleteFileFromAliyun?attachmentId=${attachment.id}&id=${workVisa.id}">删除</a>
										   </td>
									   </tr>
								   </c:forEach>
								   </tbody>
							   </table>

						   </div>
					   </div>
				   </td>
			   </tr>

			   <%--<tr>--%>
					<%--<td class="width-15 active"><label class="pull-right">项目状态：</label></td>--%>
					<%--<td class="width-35">--%>
						<%--<form:textarea path="status" htmlEscape="false" rows="4"    class="form-control "/>--%>
					<%--</td>--%>
					<%--<td class="width-15 active"></td>--%>
		   			<%--<td class="width-35" ></td>--%>
		  		<%--</tr>--%>
		 	</tbody>
		</table>
	</form:form>
</body>
</html>