  <%@ page contentType="text/html;charset=UTF-8"%>
<%@page import="com.blueland.bpm.engine.config.model.*" %>
<%@ 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"%>
<link rel="stylesheet" href="${ctx}/resource/js/plugins/codemirror/codemirror.css">
<link rel="stylesheet" href="${ctx}/resource/js/plugins/codemirror/eclipse.css">
<script src="${ctx}/resource/js/plugins/codemirror/codemirror.js"></script>
<script src="${ctx}/resource/js/plugins/codemirror/clike.js"></script>
<base href="<%=basePath%>">
<title>流程环节规则表编辑</title>
<script>
	var javaEditor;
	$(document).ready(function() {
		 javaEditor = CodeMirror.fromTextArea(document.getElementById("ruleScript"), {
			  lineNumbers: true,
			  matchBrackets: true,
			  theme:"eclipse",
			  mode: "text/x-java"
		});
	});
	function save(){
		var ruleName = $("#ruleName").val();
		if(""==ruleName){
			alert("请填写规则名称！");
			return ;
		}
		
		var ruleScript = javaEditor.getValue();
		if(""==ruleScript){
			alert("验证脚本不能为空！");
			return ;
		}
		//document.getElementById("myForm").submit();
		$.post('${ctx}/actInfo/activityRule/updateMgr.do',$('#myform').serialize(),function(result){
			   alert(result);
			   art.dialog.opener.location.reload();
		});
	}
	function validate(){
		var ruleScript= javaEditor.getValue();
		if(ruleScript==""){
			alert("规则脚本不允许为空,请您重新输入！");
			return ;
		}
		var url="${ctx}/actInfo/activityRule/validate.do?ruleScript="+ruleScript;
		showDiaLog(url,'验证规则脚本','600px','300px');
	}
	function describe(){
		window.open("${ctx}/commons/bpm_script_info.html")
	}
</script>
</head>
<body class="white-page">
	<div class="box2" panelTitle="更新流程环节规则表" showStatus="false" roller="true">
	<form id="myForm" action="${ctx}/actInfo/activityRule/updateMgr.do" method="post">
			<button id="submitButton" class="btn btn-sm btn-primary" name="submitButton" type="button" onclick="save();">
				<span class="icon_save">保存</span>
				<i class="ace-icon fa fa-save bigger-110"></i>
			</button>
			<button type="button" class="btn btn-sm btn-primary" onclick="art.dialog.close();">
				<span class="icon_back">返回</span>
			</button>
			<table class='table table-bordered form-table' border="0" cellspacing="0"
						cellpadding="0" style="margin-top: 15px">
					<!-- 存放隐藏域的区域 -->
					<input type="hidden" name="procDefId" value="${activityRule.procDefId}" id="procDefId" />
					<input type="hidden" name="ruleType" value="${activityRule.ruleType}" id="ruleType" />
					<input type="hidden" name="sourceActId" value="${activityRule.sourceActId}" id="sourceActId" />
					<input type="hidden" name="targetActId" value="${activityRule.targetActId}" id="targetActId" />
					<input type="hidden" id="ruleId" name="ruleId" value="${activityRule.ruleId}" />
					<!-- 存放表单的区域 -->
					<tr>
						<td>环节规则名称<font color="red">*</font>：</td>
						<td><input type="text" name="ruleName" value="${activityRule.ruleName}" id="ruleName" /></td>
						<td>流程定义ID<font color="red">*</font>：</td>
						<td title="${activityRule.procDefId}"><input readonly="readonly" type="text"  value="${activityRule.procDefId}" /></td>
					</tr>
		
					<tr>
						<td>源环节ID<font color="red">*</font>：</td>
						<td><input type="text" readonly="readonly"  value="${activityRule.sourceActId}"  /></td>
						<td>目标环节ID<font color="red">*</font>：</td>
						<td><input type="text" readonly="readonly"  value="${activityRule.targetActId}" /></td>
					</tr>
					<tr>
						<td>环节规则脚本<font color="red">*</font>：</td>
						<td colspan="3">
							<!-- <a href="javascript:void(0);" onclick="">常用脚本</a>&nbsp;&nbsp;-->
							<a href="javascript:void(0);" onclick="validate();">验证脚本</a>&nbsp;&nbsp;
							<a href="javascript:void(0);" onclick="describe();">脚本说明</a>
							<br/>
							<input type="textarea" style="width: 700px;height: 50px" name="ruleScript" value="${activityRule.ruleScript}" id="ruleScript"  />
						</td>
					</tr>
					<tr>
						<td>环节规则优先级：</td>
						<td><input type="text" name="rulePriority" value="${activityRule.rulePriority}" id="rulePriority" /></td>
					</tr>
					<tr>
						<td>环节规则描述：</td>
						<td colspan="3"><input type="text" name="ruleRemark" value="${activityRule.ruleRemark}" id="ruleRemark" /></td>
					</tr>
			</table>
	</form>
	</div>
</body>
</html>
