<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>项目归档</title>
	<meta name="decorator" content="default"/>
	<script src="${ctxStatic}/layer-v2.3/laydate/laydate.js"></script>
	<style type="text/css">
		.table{
			margin-bottom: 0px;
		}
		.workfull>.form-horizontal{
			margin: 0;
			padding: 0;
		}
	</style>
	<script type="text/javascript">
        $(function(){
            $("#attachment_btn").click(function () {
                $("#attachment_file").click();
            });
            var oneSize = $(".oneTab").size();
            for(var i = 0;i < oneSize;i++){
                var hei = $(".oneTab:eq("+i+")").parent().height();
                $(".oneTab:eq("+i+")").css("height",hei)
                    .css("vertical-align","middle")
                    .css("line-height",hei+"px")
            }
            $("img").not(".upload_ico").each(function () {
                var num = 1 ;
                $(this).click(function () {
                    var flag = num%2;
                    if(flag == 1){
                        $(this).css("width","90%");
                        $(this).css("height","90%");
                        num++;
                    }else if(flag ==0){
                        $(this).css("width","50px");
                        $(this).css("height","50px");
                        num++;
                    }
                })
            });
        })
        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);
                    }
                }
            });
        });

        function insertTitle(tValue){
            var list = "${workAttachmentList}";
            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 = "66";
            console.log(file);
            var timestamp=new Date().getTime();

            var storeAs = "attachment-file/workProjectRecord/"+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 deleteFileFromAliyun(obj,deleteUrl){
            $.ajax({
                type:"post",
                url:deleteUrl,
                success:function(data){
                    if(data.str){
                        parent.layer.msg('删除成功',{icon:1});
                        $(obj).parent().parent().remove();
                    }else {
                        parent.layer.msg('删除失败',{icon:1});
                    }
                }
            });
        }
	</script>
</head>
<body class="hideScroll">
<div class="wrapper wrapper-content">
	<div class="ibox">
	<div class="ibox-content">
		<div class="col-sm-12 m-t-xs">
			<div class="col-sm-2 gray-bg text-center oneTab">
				<label>档案信息</label>
			</div>
			<div class="col-sm-10 workfull" >
				<form:form id="inputForm" modelAttribute="workFullRecord" action="${ctx}/workproject/workProject/updateRd" method="post" class="form-horizontal">
					<form:hidden path="id"/>
					<sys:message content="${message}"/>
					<table class="table table-striped table-bordered table-hover table-condensed dataTables-example">
						<tbody>
						<tr>
							<td class="width-15 active"><label class="pull-right"><font color="red">*</font>案卷名称：</label></td>
							<td class="width-25" colspan="3">
								<form:input path="recordName" htmlEscape="false"    class="form-control " readonly="true" value="${workFullRecord.recordName}"/>
								<input type="hidden" name="workProject.id" value="${workProject.id}"   class="form-control "/>
							</td>
						</tr>
						<tr>
							<td class="width-15 active"><label class="pull-right"><font color="red">*</font>案卷号：</label></td>
							<td class="width-35">
								<form:input path="recordNumber" htmlEscape="false" readonly="true" value="${workFullRecord.recordNumber}"   class="form-control "/>
							</td>
							<td class="width-15 active"><label class="pull-right">归档号：</label></td>
							<td class="width-35">
								<form:input path="backRecordNumber" htmlEscape="false"    class="form-control "/>
							</td>
						</tr>
						<tr>
							<td class="width-15 active"><label class="pull-right">所属卷库：</label></td>
							<td class="width-25">
								<form:select path="recordLibNumber" class="form-control ">
									<form:option value="" label=""/>
									<form:options items="${fns:getDictList('record_lib_number')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
								</form:select>
							</td>
							<td class="width-15 active"><label class="pull-right">归档年代：</label></td>
							<td class="width-25">
								<form:input path="backRecordYear" htmlEscape="false"    class="form-control "/>
							</td>
						</tr>
						<tr>
							<td class="width-15 active"><label class="pull-right">所属部门：</label></td>
							<td class="width-25">
								<sys:treeselect id="backRecordDept" name="backRecordDept.id" value="${workFullRecord.backRecordDept.id}" labelName="backRecordDept.name" labelValue="${workFullRecord.backRecordDept.name}"
												title="部门" url="/sys/office/treeDataAll?type=2" cssClass="form-control " allowClear="true" notAllowSelectParent="true"/>
							</td>
							<td class="width-15 active"><label class="pull-right">编制机构：</label></td>
							<td class="width-25">
								<form:input path="compleOrganization" htmlEscape="false"    class="form-control "/>
							</td>
						</tr>
						<tr>
							<td class="width-15 active"><label class="pull-right">保管期限：</label></td>
							<td class="width-25">
								<form:select path="retentionPeriod" class="form-control ">
									<form:option value="" label=""/>
									<form:options items="${fns:getDictList('retention_period')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
								</form:select>
							</td>
							<td class="width-15 active"><label class="pull-right">起止日期：</label></td>
							<td class="width-25" style="display: inline-block;">
									<%--<input id="startTime" name="startTime" type="text" maxlength="20" class="laydate-icon form-control layer-date "--%>
									<%--value="<fmt:formatDate value="${startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>--%>
									<%--<input id="endTime" name="endTime" type="text" maxlength="20" class="laydate-icon form-control layer-date "--%>
									<%--value="/>--%>
								<div class="col-sm-5" style="padding: 0;">
									<input class="form-control" id="startTime" name="startTime" value="<fmt:formatDate value="${workFullRecord.startTime}" pattern="yyyy-MM-dd"/>" onclick="laydate({istime: false, format: 'YYYY-MM-DD'})">
								</div>
								<div class="col-sm-2 text-center" style="padding: 0;vertical-align: middle;line-height: 30px;">
									至
								</div>
								<div class="col-sm-5" style="padding: 0;">
									<input class="form-control" id="endTime" name="endTime" value="<fmt:formatDate value="${workFullRecord.endTime}" pattern="yyyy-MM-dd"/>" onclick="laydate({istime: false, format: 'YYYY-MM-DD'})">
								</div>
							</td>
						</tr>
						<tr>
							<td class="width-15 active"><label class="pull-right">案卷密级：</label></td>
							<td class="width-25">
								<form:select path="recordSecretLevel" class="form-control ">
									<form:option value="" label=""/>
									<form:options items="${fns:getDictList('record_secret_level')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
								</form:select>
							</td>
							<td class="width-15 active"><label class="pull-right">全宗号：</label></td>
							<td class="width-25">
								<form:input path="fondsNumber" htmlEscape="false"    class="form-control "/>
							</td>
						</tr>
						<tr>
							<td class="width-15 active"><label class="pull-right">目录号：</label></td>
							<td class="width-25">
								<form:input path="listsNumber" htmlEscape="false"    class="form-control "/>
							</td>
							<td class="width-15 active"><label class="pull-right">归档馆号：</label></td>
							<td class="width-25">
								<form:input path="recordProNumber" htmlEscape="false"    class="form-control "/>
							</td>
						</tr>
						<tr>
							<td class="width-15 active"><label class="pull-right">保险箱号：</label></td>
							<td class="width-25">
								<form:input path="strongboxNumber" htmlEscape="false"    class="form-control "/>
							</td>
							<td class="width-15 active"><label class="pull-right">缩微号：</label></td>
							<td class="width-25">
								<form:input path="microNumber" htmlEscape="false"    class="form-control "/>
							</td>
						</tr>
						<tr>
							<td class="width-15 active"><label class="pull-right">凭证类别：</label></td>
							<td class="width-25">
								<form:select path="ekkoType" class="form-control ">
									<form:option value="" label=""/>
									<form:options items="${fns:getDictList('ekko_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
								</form:select>
							</td>
							<td class="width-15 active"><label class="pull-right">凭证编号：</label></td>
							<td class="width-25">
								<div class="col-sm-5" style="padding: 0;">
									<form:input path="ekkoBstypOne" htmlEscape="false" class="form-control "/>
								</div>
								<div class="col-sm-2 text-center" style="padding: 0;vertical-align: middle;line-height: 30px;">
									至
								</div>
								<div class="col-sm-5" style="padding: 0;">
									<form:input path="ekkoBstypTwo" htmlEscape="false"  class="form-control "/>
								</div>
							</td>
						</tr>
						<tr>
							<td class="width-15 active"><label class="pull-right">报告号：</label></td>
							<td class="width-25">
								<form:input path="reportNumber" htmlEscape="false"    class="form-control "/>
							</td>
							<td class="width-15 active"><label class="pull-right">页数：</label></td>
							<td class="width-25">
								<form:input path="pageNumber" htmlEscape="false"    class="form-control "/>
							</td>
						</tr>
						<tr>
							<td class="width-15 active"><label class="pull-right">案卷管理员：</label></td>
							<td class="width-25">
								<form:input path="manageUser" htmlEscape="false"    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="remarks" htmlEscape="false" rows="4"    class="form-control "/>
							</td>
						</tr>
						<tr>
							<td colspan="4" style="background:white;">
							<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 class="table table-striped table-bordered table-hover table-condensed dataTables-example">
									<thead>
									<tr>
										<%--<th>序号</th>--%>
										<th>文件名称</th>
										<th>上传人</th>
										<th>上传时间</th>
										<th>操作</th>
									</tr>
									</thead>
									<tbody id="file_attachment">
									<c:forEach items="${workAttachments}" varStatus="status" var="workClientAttachment">
										<tr>
											<%--<td>${status.index + 1}</td>--%>
											<td>${workClientAttachment.attachmentName}</td>
											<td>${workClientAttachment.createBy.name}</td>
											<td><fmt:formatDate value="${workClientAttachment.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
											<td>
												<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>
							</td>
						</tr>
						</tbody>
					</table>
				</form:form>
			</div>
		</div>
	</div>
	</div>
</div>
</body>
</html>