<%@ 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(){//回调函数，在编辑和保存动作时，供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);
					}
				}
			});
			
					laydate({
			            elem: '#startDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			        });
					laydate({
			            elem: '#finishDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			        });

            //只做查看时，禁用掉以下标签
            $('input,textarea,select').attr('disabled',<%=request.getAttribute("disabled")%>);
		});
		function addRow(list, idx, tpl, row){
			$(list).append(Mustache.render(tpl, {
				idx: idx, delBtn: true, row: row
			}));
			$(list+idx).find("select").each(function(){
				$(this).val($(this).attr("data-value"));
			});
			$(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
				var ss = $(this).attr("data-value").split(',');
				for (var i=0; i<ss.length; i++){
					if($(this).val() == ss[i]){
						$(this).attr("checked","checked");
					}
				}
			});
		}
		function delRow(obj, prefix){
			var id = $(prefix+"_id");
			var delFlag = $(prefix+"_delFlag");
			if (id.val() == ""){
				$(obj).parent().parent().remove();
			}else if(delFlag.val() == "0"){
				delFlag.val("1");
				$(obj).html("&divide;").attr("title", "撤回删除");
				$(obj).parent().parent().addClass("error");
			}else if(delFlag.val() == "1"){
				delFlag.val("0");
				$(obj).html("&times;").attr("title", "删除");
				$(obj).parent().parent().removeClass("error");
			}
		}
	</script>
</head>
<body class="hideScroll">
	<form:form id="inputForm" modelAttribute="workReport" action="${ctx}/work/report/workReport/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>	
		<table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
		   <tbody>
				<tr>
					<td class="width-15 active"><label class="pull-right">类型：</label></td>
					<td class="width-35">

						<c:choose>
							<c:when test="${!disabled}">
								<form:select path="type" class="form-control " readonly="true">
									<form:option value="" label=""/>
									<form:options items="${fns:getDictList('work_report_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
								</form:select>
							</c:when>
							<c:otherwise>
								${fns:getDictLabel(workReport.type, 'work_report_type', '')}
							</c:otherwise>
						</c:choose>
					</td>	
				</tr>
				<tr>
				     <td  class="width-15 active">	<label class="pull-right"><font color="red">*</font>状态：</label></td>
			         <td class="width-35" >
						 <c:choose>
							 <c:when test="${!disabled}">
								 <form:radiobuttons path="status" items="${fns:getDictList('oa_notify_status')}" itemLabel="label" itemValue="value" htmlEscape="false" class="i-checks required"/>
							 </c:when>
							 <c:otherwise>
								 ${fns:getDictLabel(workReport.status, 'oa_notify_status', '')}
							 </c:otherwise>
						 </c:choose>
					 </td>
				</tr>
				<tr>
				<td class="width-15 active"><label class="pull-right">本次工作内容：</label></td>
					<td class="width-35">
						<c:choose>
							<c:when test="${!disabled}">
								<form:textarea  path="thisContent" htmlEscape="false" row="4"   class="form-control "/>
							</c:when>
							<c:otherwise>
								${workReport.thisContent,}
							</c:otherwise>
						</c:choose>
					</td>		
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">本次工作内容附件：</label></td>
					<td class="width-35">
							<img src="${workReport.thisFiles}">
					</td>
				</tr>
				<tr>
				<td class="width-15 active"><label class="pull-right">下次工作计划：</label></td>
					<td class="width-35">
						<c:choose>
							<c:when test="${!disabled}">
								<form:textarea   path="nextContent" htmlEscape="false"  row="4"  class="form-control "/>
							</c:when>
							<c:otherwise>
								${workReport.nextContent}
							</c:otherwise>
						</c:choose>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">下次工作附件：</label></td>
					<td class="width-35">
						<c:choose>
							<c:when test="${!disabled}">
								<form:input path="nextFiles" htmlEscape="false"    class="form-control "/>
							</c:when>
							<c:otherwise>
								${workReport.nextFiles}
							</c:otherwise>
						</c:choose>
					</td>
					
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">备注：</label></td>
					<td class="width-35">
						<c:choose>
							<c:when test="${!disabled}">
								<form:textarea   path="remarks" htmlEscape="false" row="4"   class="form-control "/>
							</c:when>
							<c:otherwise>
								${workReport.remarks}
							</c:otherwise>
						</c:choose>
					</td>
				</tr>
																																																								
				<tr>
					<td class="width-15 active"><label class="pull-right">开始时间：</label></td>
					<td class="width-35">
						<c:choose>
							<c:when test="${!disabled}">
								<input id="startDate" name="startDate" type="text" maxlength="20" class="laydate-icon form-control layer-date "
									   value="<fmt:formatDate value="${workReport.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
							</c:when>
							<c:otherwise>
								<fmt:formatDate value="${workReport.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
							</c:otherwise>
						</c:choose>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">结束时间：</label></td>
					<td class="width-35">
						<c:choose>
							<c:when test="${!disabled}">
								<input id="finishDate" name="finishDate" type="text" maxlength="20" class="laydate-icon form-control layer-date "
									   value="<fmt:formatDate value="${workReport.finishDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
							</c:when>
							<c:otherwise>
								<fmt:formatDate value="${workReport.finishDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
							</c:otherwise>
						</c:choose>
					</td>
				</tr>
				<c:if test="${workReport.status ne '1'}">
		      	 <tr> 
			         <td  class="width-15 active">	<label class="pull-right"><font color="red">*</font>接收人：</label></td>
			         <td  class="width-35" >
						 <c:choose>
							 <c:when test="${!disabled}">
								 <sys:treeselect id="workReportRecordUser" name="workReportRecordIdsUser" value="${workReport.workReportRecordIdsUser}" labelName="workReportRecordNamesUser" labelValue="${workReport.workReportRecordNamesUser}"
												 title="用户" url="/sys/office/treeData?type=3" cssClass="form-control required" notAllowSelectParent="true" checked="true"/>
							 </c:when>
							 <c:otherwise>
								 ${workReport.workReportRecordNamesUser}
							 </c:otherwise>
						 </c:choose>
					 </td>

		      		</tr>
		        <tr> 
			         <td  class="width-15 active">	<label class="pull-right"><font color="red">*</font>接收群：</label></td>
				     <td  class="width-35" >
						 <c:choose>
							 <c:when test="${!disabled}">
								 <sys:treeselect id="workReportRecordGroup" name="workReportRecordIdsGroup" value="${workReport.workReportRecordIdsGroup}" labelName="workReportRecordNamesGroup" labelValue="${workReport.workReportRecordNamesGroup}"
												 title="群组" url="/iim/layGroup/treeData" cssClass="form-control required" notAllowSelectParent="true" checked="true"/>
							 </c:when>
							 <c:otherwise>
								 ${workReport.workReportRecordNamesGroup}
							 </c:otherwise>
						 </c:choose>
					 </td>
		      	</tr>
			</c:if>
				<c:if test="${workReport.status eq '1'}">
					  <tr>
				         <td  class="width-15 active">	<label class="pull-right">接收人：</label></td>
				         <td class="width-35" colspan="3"><table id="contentTableUser" class="table table-striped table-bordered table-hover table-condensed dataTables-example dataTable">
								<thead>
									<tr>
										<th>接收人</th>
										<th>接收部门</th>
										<th>阅读状态</th>
										<th>阅读时间</th>
									</tr>
								</thead>
								<tbody>
								<c:forEach items="${workReport.workReportRecordListUser}" var="workReportRecord">
									<tr>
										<td>
											${workReportRecord.user.name}
										</td>
										<td>
											${workReportRecord.user.office.name}
										</td>
										<td>
											${fns:getDictLabel(workReportRecord.readFlag, 'oa_notify_read', '')}
										</td>
										<td>
											<fmt:formatDate value="${workReportRecord.readDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
										</td>
									</tr>
								</c:forEach>
								</tbody>
							</table>
							</td>
				      </tr>
				      
				       <tr>
				         <td  class="width-15 active">	<label class="pull-right">接收群：</label></td>
				         <td class="width-35" colspan="3"><table id="contentTableGroup" class="table table-striped table-bordered table-hover table-condensed dataTables-example dataTable">
								<thead>
									<tr>
										<th>接收群</th>
									</tr>
								</thead>
								<tbody>
								<c:forEach items="${workReport.workReportRecordListGroup}" var="workReportRecord">
									<tr>
										<td>
											${workReportRecord.group.groupname}
										</td>
									</tr>
								</c:forEach>
								</tbody>
							</table>
							</td>
				      </tr>
		</c:if>
		 	</tbody>
		</table>
		
	</form:form>
</body>
</html>