<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>日志模板</title>
	<meta name="decorator" content="default"/>
	 <link href="${ctxStatic}/summernotenew/summernote.css" rel="stylesheet">
	 <link href="${ctxStatic}/summernotenew/summernote-bs3.css" rel="stylesheet">
	<script src="${ctxStatic}/summernotenew/summernote.min.js"></script>
	<script src="${ctxStatic}/summernotenew/lang/summernote-zh-CN.js"></script>
	<script type="text/javascript">
		var validateForm;
		function doSubmit(){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		  if(validateForm.form()){
			  $("#inputForm").submit();
			  return true;
		  }
	
		  return false;
		}
		$(document).ready(function() {
			if("${workLog.logType}" == "1"){
				$("#logType1").iCheck('check')
			}else if("${workLog.logType}" == "2"){
				$("#logType2").iCheck('check')
			}else if("${workLog.logType}" == "3"){
				$("#logType3").iCheck('check')
			}else if("${workLog.logType}" == "4"){
				$("#logType5").iCheck('check')
			}else if("${workLog.logType}" == "5"){
				$("#logType5").iCheck('check')
			}

			if($("#startDate").val()==null || $("#startDate").val()==''){
				$("#startDate").val(getNowFormatDate());
			}
			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);
					}
				}
			});
			
				//富文本初始化
			$('.summernote').summernote({
                lang: 'zh-CN',
				height:'300px'
            });
            getCurrentDocumentHei();

			laydate.render({
				elem: '#startDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
				format: 'yyyy-MM-dd',
				type : 'date'
			});

			$("#attachment_btn").click(function () {
				$("#attachment_file").click();
			});
		});
        function getCurrentDocumentHei(){
            var height = $(document).outerHeight();
            parent.$("#controltype").attr("height",height +"px")
		}

		function getNowFormatDate() {
			var date = new Date();
			var seperator1 = "-";
			var seperator2 = ":";
			var month = date.getMonth() + 1;
			var strDate = date.getDate();
			month = (month < 10)?"0"+month:month;
			strDate = (strDate < 10)?"0"+strDate:strDate;
			var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
			return currentdate;
		}

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

				var storeAs = "attachment-file/workClientInfo/" + 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>
	<style>
		.note-editor .panel-heading{
			padding:3px 5px;
		}
	</style>
</head>
<body>
<div class="single-form">
		<form:form id="inputForm" modelAttribute="workLog" action="${ctx}/worklog/workLog/save" method="post" class="form-horizontal">
			<form:hidden path="id"/>
			<sys:message content="${message}"/>
			<input type="hidden" name="projectId" id="projectId">

			<div class="form-group layui-row first">
				<div class="form-group-label"><h2>基础信息</h2></div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label  double-line">类型：</label>
					<div class="layui-input-block">
						<input type="radio" class="i-checks" name="logType" checked id="logType1" value="1">
						<label for="logType1">日报</label>
						<input type="radio" class="i-checks" name="logType" checked id="logType2" value="0">
						<label for="logType2">周报</label>
						<input type="radio" class="i-checks" name="logType" checked id="logType3" value="0">
						<label for="logType3">月报</label>
						<input type="radio" class="i-checks" name="logType" checked id="logType4" value="0">
						<label for="logType4">季度</label>
						<input type="radio" class="i-checks" name="logType" checked id="logType5" value="0">
						<label for="logType5">年度</label>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label">创建日期：</label>
					<div class="layui-input-block">
						<input id="startDate" name="startDate" type="text"  maxlength="20" class="laydate-icondate form-control layer-date required layui-input laydate-icon"
							   value="<fmt:formatDate value="${workLog.startDate}" pattern="yyyy-MM-dd"/>"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6 ">
					<label class="layui-form-label">地区：</label>
					<div class="layui-input-block  with-icon">
						<sys:treeselect id="area" name="area.id" value="${workLog.area.id}" labelName="area.name" labelValue="${workLog.area.name}"
										title="区域" url="/sys/area/treeData" cssClass="form-control layui-input" allowClear="true" notAllowSelectParent="ture"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>详细地址：</label>
					<div class="layui-input-block">
						<form:input path="address" htmlEscape="false"   id="model"  class="form-control required layui-input" value="${workLog.address}"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>天气：</label>
					<div class="layui-input-block">
						<form:select path="weather" class="form-control required  simple-select">
							<form:option value="" label=""/>
							<form:options items="${fns:getMainDictList('work_weather')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>温度：</label>
					<div class="layui-input-block">
						<form:input path="temperature" htmlEscape="false"   id="model"  class="form-control required layui-input" value="${workLog.temperature}"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm6">
					<label class="layui-form-label"><span class="require-item">*</span>主题：</label>
					<div class="layui-input-block">
						<form:input path="theme" htmlEscape="false"   id="model"  class="form-control required layui-input" value="${workLog.theme}"/>
					</div>
				</div>
				<div class="layui-item layui-col-sm12">
					<label class="layui-form-label"><span class="require-item">*</span>内容：</label>
					<div class="layui-input-block">
						<textarea id="content" name="content"  class="form-control summernote required" placeholder="内容" required>${workLog.content}</textarea>
					</div>
				</div>
			</div>

		</form:form>
</div>
</body>
</html>
