<%@ page contentType="text/html;charset=UTF-8"%>
<%@page import="com.blueland.bpm.engine.core.model.*,org.activiti.engine.task.Comment,org.apache.commons.lang3.StringUtils,com.blueland.bpm.common.util.DateUtil,java.util.*"%>
<%@ include file="/commons/taglibs.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/commons/meta.jsp"%>
<base href="<%=basePath%>">
<title>更新流程审批意见</title>
<script>
	function delComment(taskName,procInstId,commentId){
		//alert(commentId);
		if(confirm("您确认删除["+taskName+"]环节的审批意见吗？")){
			$.post('${ctx}/taskMgr/deleteProcessComment.do', {"procInstId":procInstId,"commentId":commentId},
					function (data, textStatus){
						if(data){
							alert("操作成功!");
							window.location.href=window.location.href
						}else{
							alert("操作失败！");
						}

					});
		}
	}
</script>
</head>
<body style="background-color: white;" class="white-page">

<form action="${ctx}/taskMgr/updateProcessComment.do" method="post" id="myform">
	<div class="widget-box">
		<%
			List<ProcessLogModel> processComments = (List) request
					.getAttribute("processComments");
		%>
		<input type="hidden" id="procInstId" name="procInstId" value="${procInstId}"></input>
		<%
			if (processComments != null && !processComments.isEmpty()) {
		%>
		<input type="submit" class="btn btn-sm btn-primary" id="submitButton" value="保 存" />

		<%
			}
		%>
		<input type="button" class="btn btn-sm btn-primary" value="关 闭" onclick="art.dialog.close();" />

		<div class="widget-body" style="margin-top: 15px">
			<div class="widget-main no-padding">
				<table class='table table-bordered' border="0" cellspacing="0" cellpadding="0" id="myTable">
					<%
						try {
							for (ProcessLogModel processComment : processComments) {
								Comment comment = processComment.getComment();
								String fullMessage = comment.getFullMessage();
								fullMessage = !StringUtils.isEmpty(fullMessage) ? fullMessage
										.replaceAll("\r\n", "<br/>") : fullMessage;
					%><div id='replayData' style='text-align: left; border: 1px solid #c5d3da; height: auto; margin-top: -1px;'>
					<div style='text-align: left; float: left; margin-left: 20px;'>
						<%=fullMessage%>

					</div>
					<br />
					<div style='text-align: left; float: left; margin-left: 20px;'>
						修改意见为：
						<input type="text" name="commentId_<%=comment.getId()%>" id="commentId_<%=comment.getId()%>" value="" />
					</div>
					<br /> <br />
					<div style='float: right;'>
						<%=processComment.getHistoricTaskInstance()
								.getName()%>：<%=processComment.getSendUserName()%>
						(<%=DateUtil.convertDateToString(
							"yyyy-MM-dd HH:mm:ss", comment.getTime())%>) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="javascript:void(0);" onclick="delComment('<%=processComment.getHistoricTaskInstance()
							.getName()%>','<%=processComment.getHistoricTaskInstance()
							.getProcessInstanceId()%>','<%=comment.getId()%>')">删除意见</a>
					</div>
					<br style='clear: both;' />
				</div>
					<%
							}
						} catch (Exception e) {
							e.printStackTrace();
						}
					%>

					<%
						if (processComments == null || processComments.isEmpty()) {
					%>
					<br style='clear: both;' />
					<div style='text-align: left; float: left; margin-left: 20px;'>该流程暂无审批意见！</div>
					<%
						}
					%>
				</table>
			</div>
		</div>
	</div>

</form>
</body>
</html>