<%@ page contentType="text/html;charset=UTF-8"%>
<%@page import="org.activiti.engine.repository.ProcessDefinition"%>
<%@page import="org.activiti.engine.repository.Model"%>
<%@page import="com.blueland.bpm.engine.config.model.*"%>
<%@page import="com.blueland.bpm.common.page.*"%>
<%@page import="com.blueland.bpm.common.util.*"%>
<%@page import="com.blueland.bpm.manage.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%>">
<link href="${ctx}/resource/js/plugins/loadmask/jquery.loadmask.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='${ctx}/resource/js/plugins/loadmask/jquery.loadmask.js'></script>

<title>编辑环节信息</title>
<script type="text/javascript">
	$(document).ready(function() {
		$("#submitButton").click(function() {
			setMask("main-container");
			//用jquery中的ajax方法，向服务器提交请求 
			jQuery.ajax({
				type : "POST",
				url : "${ctx}/activityInfo/update.do",
				data : $('#myform').serialize(),
				success : function(resp) {
					if (resp == 'SUCCESS') {
						alert("操作成功!");
						$("#main-container").unmask();
						//window.location.reload();
						//art.dialog.close();
						//art.dialog.opener.location.reload();
					} else {
						$("#main-container").unmask();
						alert("操作失败！");
					}

				}
			});
		});
		$('#mprotocol').change(function(){ 
			var val=$(this).children('option:selected').val();
			if(val=="http"){
				$("#otherSysDealStatus option[value='no']").attr("selected", "selected"); 
			}else if(val=="none"){
				$("#otherSysDealStatus option[value='yes']").attr("selected", "selected");
			}else{
				$("#otherSysDealStatus option[value='']").attr("selected", "selected");
			}
		});
		var sys = $("#sys").val();
		var mAppId = $("#mAppId").val();
		if(sys !=""){
			var activityPageUrlHid = $("#activityPageUrlHid").val();
			var activityMurlHid = $("#activityMurlHid").val();
			var href = window.top.location.href;
			var list = href.split("/");
			var name = "/"+list[3];
			var url = "<%=MyContants.KSKF_PAHT%>"+name+"/customForm/list/workflow/"+sys+"/PC";
			jQuery.ajax({	      
	            url : url,
	            type : "GET",
	            success : function(resp) {
	            	if(resp.resultCode == 200){
	            		var html = "<select name='activityPageUrl' id='activityPageUrl'>";
	            		html = html +"<option value='' ></option>";
	            		for(var i = 0; i < resp.result.length; i++) {
	                        var bean = resp.result[i];
	                        if(activityPageUrlHid==bean.code){
	                        	html=html+"<option selected value="+bean.code+">"+bean.name+"</option>"
	                        }else{
	                        	html=html+"<option value="+bean.code+">"+bean.name+"</option>"
	                        }
	                        
	            		}
	            		html=html+"</select>"
	            		$("#addSelect").html(html);
	            	}else{
	            		alert("获取应用表单数据失败！");
	            	}
	            }
	        });
			
			//移动端
			var urlApp = "<%=MyContants.KSKF_PAHT%>"+name+"/customForm/list/workflow/"+sys+"/APP";
			jQuery.ajax({	      
	            url : urlApp,
	            type : "GET",
	            success : function(resp) {
	            	if(resp.resultCode == 200){
	            		var html = "<select name='murl' id='murl'>";
	            		html = html +"<option value='' ></option>";
	            		for(var i = 0; i < resp.result.length; i++) {
	                        var bean = resp.result[i];
	                        if(activityMurlHid==bean.code){
	                        	html=html+"<option selected value="+bean.code+">"+bean.name+"</option>"
	                        }else{
	                        	html=html+"<option value="+bean.code+">"+bean.name+"</option>"
	                        }
	                        
	            		}
	            		html=html+"</select>"
	            		$("#addMurlSelect").html(html);
	            	}else{
	            		alert("获取应用表单数据失败！");
	            	}
	            }
	        });
		}
	});
</script>
</head>
<body class="white-page">
  	<input type="hidden" name="sys" id="sys" value="${sys}" />
  	<input type="hidden" name="mAppId" id="mAppId" value="${mAppId}" />
  	<input type="hidden" name="activityPageUrlHid" value="${activityInfoConfig.activityPageUrl}" id="activityPageUrlHid"/>
  	<input type="hidden" name="activityMurlHid" value="${activityInfoConfig.murl}" id="activityMurlHid"/>
	<form action="${ctx}/activityInfo/update.do" method="post" id="myform">
		<div class="main-container" id="main-container">
			<div class="panel panel-primary">
				<div class="panel-body">
					<table class='table table-bordered form-table' border="0" cellspacing="0" cellpadding="0" id="myTable">
						<!-- 存放隐藏域的区域 -->
						<input type="hidden" name="activityDefId" value="${activityInfoConfig.activityDefId}" />
						<input type="hidden" name="activityDefName" value="${activityInfoConfig.activityDefName}" />
						<input type="hidden" name="processDefId" value="${activityInfoConfig.processDefId}" />
						<input type="hidden" name="processDefName" value="${activityInfoConfig.processDefName}" />
						<input type="hidden" name="activityOperationRoleid" value="${activityInfoConfig.activityOperationRoleid}" />
						<!-- 存放表单的区域 -->

						<tr>
							<td>
								<font color="red">*</font>环节ID：
							</td>
							<td>${activityInfoConfig.activityDefId}</td>
							<td>环节名称：</td>
							<td>${activityInfoConfig.activityDefName}</td>

						</tr>
						<tr>
							<!-- 不是第一步处理    则环节处理类型放在此处 -->
							<td>环节处理类型：</td>
							<td>
								<select name="activityDefDealType" id="activityDefDealType">
									<option ${activityInfoConfig.activityDefDealType=='single'?'selected':''} value="single">单人处理</option>
									<%-- <c:if test="${!isStartTask}"> --%>
										<option ${activityInfoConfig.activityDefDealType=='multi'?'selected':''} value="multi">多人处理-并行</option>
										<option ${activityInfoConfig.activityDefDealType=='multi-x'?'selected':''} value="multi-x">多人处理-串行</option>
									<%-- </c:if> --%>
								</select>
							</td>
							<td>环节跳转类型：</td>
							<td>

								<select name="jumpType" id="jumpType">
									<option value="MANUAL" ${activityInfoConfig.jumpType=="MANUAL"?"selected":""}>人工选择跳转</option>
									<option value="AUTO" ${activityInfoConfig.jumpType=="AUTO"?"selected":""}>自动路径跳转</option>
									<!-- <option value="FREE" ${activityInfoConfig.jumpType=="FREE"?"selected":""}>自由选择跳转</option> -->
								</select>
							</td>
						</tr>
						<tr>

							<td>意见显示区域(用于界面意见分栏)：</td>
							<td colspan="1">
								<input type="text" style="width: 200px" name="ideaDisplayArea" value="${activityInfoConfig.ideaDisplayArea}" id="ideaDisplayArea" class="validate[length[0,50]]" maxlength="30" />
							</td>
							<td>是否显示意见：</td>
							<td colspan="1">
								<select name="isShowIdea" id="isShowIdea">
									<option value="ENABLED" ${activityInfoConfig.isShowIdea=='ENABLED'?'selected':''}>是</option>
									<option value="DISABLE" ${activityInfoConfig.isShowIdea=='DISABLE'?'selected':''}>否</option>
								</select>
							</td>
						</tr>
						<tr>
							<td>环节审批时限：</td>
							<td>
								<!-- 
					    	<input type="checkbox" name="" id="" />超时后自动流转下一步<br/> -->
								<select name="activityLimitTime" id="activityLimitTime">
									<option value="">--请选择--</option>
									<c:forEach begin="1" end="30" varStatus="item">
										<option ${activityInfoConfig.activityLimitTime==item.index?'selected':''} value="${item.index}">${item.index}</option>
									</c:forEach>
								</select> 天
							</td>
							<td>环节排序号：</td>
							<td colspan="2">
								<input type="text" name="activityOrder" preValue="${activityInfoConfig.activityOrder}" onblur="moveout(this.id);" value="${activityInfoConfig.activityOrder}" id="activityOrder" maxlength="200" class="validate[length[0,1000]]" onkeyup="this.value=this.value.replace(/\D/g,'')"
									onafterpaste="this.value=this.value.replace(/\D/g,'')" />
							</td>
						</tr>

						<tr>
							<td rowspan="2" style="width: 200px;">桌面端相关配置：</td>
							<td style="width: 100px;">环节表单路径</td>
							<td colspan="3">						
								<c:if test="${sys ne '' }">
									<div id ="addSelect">
									
									</div>
									<!--  <input style="width: 600px" type="text" name="activityPageUrl" value="${activityInfoConfig.activityPageUrl}" id="activityPageUrl" class="validate[length[0,500]]" />-->
								</c:if>
								<c:if test="${sys eq ''}">
									<input style="width: 600px" type="text" name="activityPageUrl" value="${activityInfoConfig.activityPageUrl}" id="activityPageUrl" class="validate[length[0,500]]" />
								</c:if>
								
							</td>
						</tr>
						<tr>
							<td>处理协议</td>
							<td colspan="3">
								<select name="cprotocol" id="cprotocol">
									<option value="hnzy:workitem" ${activityInfoConfig.cprotocol=='hnzy:workitem'||activityInfoConfig.cprotocol==null||activityInfoConfig.cprotocol==null?'selected':''}>和+浏览器模式</option>
									<option value="http" ${activityInfoConfig.cprotocol=='http'?'selected':''}>普通浏览器模式</option>
								</select>
							</td>
						</tr>
						<tr>
							<td rowspan="3">手机端相关配置：</td>
							<td>环节表单路径</td>
							<td colspan="3">
								<c:if test="${sys ne '' }">
									<div id ="addMurlSelect">
									
									</div>
									<!--  <input style="width: 600px" type="text" name="activityPageUrl" value="${activityInfoConfig.activityPageUrl}" id="activityPageUrl" class="validate[length[0,500]]" />-->
								</c:if>
								<c:if test="${sys eq ''}">
									<input style="width: 600px" type="text" name="murl" value="${activityInfoConfig.murl}" id="mUrl" class="validate[length[0,500]]" />
								</c:if>
								
							</td>
						</tr>

						<tr>
							<td>处理协议</td>
							<td colspan="3">
								<select name="mprotocol" id="mprotocol">
									<option value="none" ${activityInfoConfig.mprotocol=='none'||activityInfoConfig.mprotocol==null?'selected':''}>不支持手机处理</option>
									<option value="http" ${activityInfoConfig.mprotocol=='http'?'selected':''}>WEBVIEW模式（H5）</option>
									<option value="" ${activityInfoConfig.mprotocol==null?'selected':''}>沿用流程配置</option>
								</select>
							</td>
							
						</tr>
						<tr>
							<td>处理状态</td>
							<td colspan="3">
								<select name="otherSysDealStatus" id="otherSysDealStatus">
									<option value="" ${processInfoConfig.mprotocol==null?'selected':''}>沿用流程配置</option>
									<option value="yes" ${activityInfoConfig.otherSysDealStatus=='yes'?'selected':''}>仅阅读</option>
									<option value="no" ${activityInfoConfig.otherSysDealStatus=='no'?'selected':''}>可处理</option>
								</select>
							</td>
						</tr>
						<tr>

							<td>备注：</td>
							<td colspan="3">
								<textarea rows="2" cols="50" name="remark">${activityInfoConfig.remark}</textarea>

							</td>
						</tr>

					</table>
					<div class="col-md-offset-1 col-md-9" style="text-align: center;">
						<button type="button" class="btn btn-sm btn-primary" id="submitButton">
							保存 <i class="ace-icon fa fa-save bigger-110"></i>
						</button>
						<!-- <button onclick="art.dialog.close();" type="button" class="btn btn-sm btn-primary">
							关闭 <i class="ace-icon fa fa-times bigger-110"></i>
						</button> -->
					</div>
				</div>
			</div>
		</div>
	</form>

</body>
</html>
