bpmDefinitionSetCondition.jsp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <%--
  2. time:2011-11-28 22:02:01
  3. --%>
  4. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  5. <%@include file="/commons/include/html_doctype.html"%>
  6. <html>
  7. <head>
  8. <%@include file="/commons/include/form.jsp"%>
  9. <title>设置分支条件</title>
  10. <script type="text/javascript"src="${ctx}/js/hotent/platform/bpm/FlowVarWindow.js"></script>
  11. <script type="text/javascript"src="${ctx}/js/hotent/platform/system/ScriptDialog.js"></script>
  12. <script type="text/javascript" src="${ctx}/js/javacode/codemirror.js"></script>
  13. <script type="text/javascript" src="${ctx}/js/javacode/InitMirror.js"></script>
  14. <style type="text/css">
  15. body{
  16. overflow-x:hidden;
  17. overflow-y:auto;
  18. }
  19. </style>
  20. <script type="text/javascript">
  21. /*KILLDIALOG*/
  22. var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
  23. var nodeId = "${nodeId}",
  24. deployId = "${deployId}",
  25. defId = "${defId}",
  26. selectNodeId="${selectCanChoicePathNodeId}";
  27. $(function() {
  28. $("a[name='btnVars']").click(selectVar);
  29. $("#btnScript").click(selectScript);
  30. $("#canChoicePath").click(function(){
  31. var targ=$("#canChoicePathNodeId");
  32. if($(this).attr("checked")){
  33. targ.removeClass("hidden");
  34. InitMirror.each(function(e){
  35. e.setCode('NextPathId.contains("'+e.targetId+'")');
  36. });
  37. }
  38. else{
  39. targ.addClass("hidden");
  40. InitMirror.each(function(e){
  41. e.setCode('');
  42. });
  43. }
  44. });
  45. if(selectNodeId){
  46. $("#canChoicePathNodeId").val(selectNodeId);
  47. }
  48. $("a[name='signResult']").click(function() {
  49. addToTextarea($(this).attr("result"));
  50. });
  51. $("a.save").click(saveCondition);
  52. });
  53. var flowVarWindow;
  54. //选择变量
  55. function selectVar() {
  56. FlowVarWindow({
  57. deployId : deployId,
  58. nodeId : nodeId,
  59. callback : function(vars) {
  60. addToTextarea(vars);
  61. }
  62. });
  63. };
  64. //将条件表达式追加到脚本输入框内
  65. function addToTextarea(str){
  66. InitMirror.editor.insertCode(str);
  67. };
  68. function selectScript() {
  69. ScriptDialog({
  70. callback : function(script) {
  71. addToTextarea(script);
  72. }
  73. });
  74. };
  75. function handFlowVars(obj) {
  76. addToTextarea($(obj).val());
  77. };
  78. function saveCondition() {
  79. InitMirror.save();
  80. var tasks = [];
  81. var conditions = [];
  82. $("tr.taskTr > td").each(function(){
  83. var condition=$("[name='condition']", $(this)).val();
  84. var task=$("[name='task']", $(this)).val();
  85. tasks.push(task);
  86. conditions.push(condition);
  87. });
  88. var canChoicePathNodeId=$("#canChoicePathNodeId:visible").val();
  89. var url = __ctx + "/platform/bpm/bpmDefinition/saveCondition.ht";
  90. var paras = {
  91. "defId" : defId,
  92. "nodeId" : nodeId,
  93. "tasks" : tasks.join('#split#'),
  94. "conditions" : conditions.join('#split#'),
  95. "canChoicePathNodeId":canChoicePathNodeId
  96. };
  97. $.post(url, paras, function(data) {
  98. var resultObj = new com.hotent.form.ResultMessage(data);
  99. if (resultObj.isSuccess()) {
  100. $.ligerDialog.success("编辑规则成功!","提示信息", function() {
  101. dialog.close();
  102. });
  103. } else {
  104. $.ligerDialog.warn("编辑规则失败,请检查条件表达式是否正确!","提示信息");
  105. }
  106. });
  107. };
  108. </script>
  109. </head>
  110. <body>
  111. <div class="panel" >
  112. <div class="panel-top">
  113. <div class="tbar-title">
  114. <span class="tbar-label">条件分支设置</span>
  115. </div>
  116. <div class="panel-toolbar">
  117. <div class="toolBar">
  118. <div class="group">
  119. <a class="link save" id="btnSearch"><span></span>保存</a>
  120. </div>
  121. <div class="l-bar-separator"></div>
  122. <div class="group">
  123. <a class="link del" onclick="javasrcipt:dialog.close()"><span></span>关闭</a>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. <div class="panel-body">
  129. <form id="bpmNodeRuleForm" method="post" action="save.ht">
  130. <table class="table-detail" cellpadding="0" cellspacing="0" border="0" >
  131. <tr>
  132. <th>条件表达式</th>
  133. <td>
  134. <div style="margin: 8px 0; ">
  135. <a href="javascript:;" id="btnScript" class="link var" title="常用脚本">常用脚本</a>
  136. &nbsp;&nbsp;表单变量:
  137. <f:flowVar defId="${defId}" parentActDefId="${param.parentActDefId}" change="handFlowVars(this)"></f:flowVar>
  138. <c:if test="${ifInclusiveGateway}">
  139. &nbsp;&nbsp;&nbsp;&nbsp;<label><input type="checkbox" id="canChoicePath" <c:if test="${selectCanChoicePathNodeId!=null}">checked="checked"</c:if> />可以选择条件同步路径</label>&nbsp;
  140. <select <c:if test="${selectCanChoicePathNodeId==null}">class="hidden"</c:if> id="canChoicePathNodeId">
  141. <c:forEach items="${incomeNodes}" var="incomeNode">
  142. <option value="${incomeNode.nodeId}">${incomeNode.nodeName}</option>
  143. </c:forEach>
  144. </select>
  145. </c:if>
  146. </div>
  147. <c:forEach items="${incomeNodes}" var="inNode">
  148. <div style="padding: 4px;">
  149. <c:choose>
  150. <c:when test="${inNode.isMultiple==true}">
  151. <a href="#1" name="signResult"
  152. result='return signResult_${inNode.nodeId}=="pass"'>[${inNode.nodeName}]投票通过</a>
  153. &nbsp;
  154. <a href="#2" name="signResult"
  155. result='return signResult_${inNode.nodeId}=="refuse"'>[${inNode.nodeName}]投票不通过</a>
  156. </c:when>
  157. <c:otherwise>
  158. <a href="#1" name="signResult"
  159. result="return approvalStatus_${inNode.nodeId}==1">[${inNode.nodeName}]-通过</a>
  160. &nbsp;
  161. <a href="#2" name="signResult"
  162. result="return approvalStatus_${inNode.nodeId}==2">[${inNode.nodeName}]-反对</a>
  163. </c:otherwise>
  164. </c:choose>
  165. <ul>
  166. <li>1.先选中下方的脚本输入框,然后再插入条件表达式。</li>
  167. <li>2.脚本为groovy语法。</li>
  168. <li>3.这个脚本需要使用返回语句(return)返回布尔值,返回true流程将跳转到指定的节点。</li>
  169. </ul>
  170. </div>
  171. </c:forEach>
  172. </td>
  173. </tr>
  174. <c:forEach items="${outcomeNodes}" var="outNode">
  175. <tr class="taskTr">
  176. <th width="20%">
  177. ${outNode.nodeName }
  178. </th>
  179. <td>
  180. <input type="hidden" name="task" value="${outNode.nodeId}" />
  181. <textarea id="${outNode.nodeId}" codemirror="true" mirrorheight="110px" name="condition" rows="3" cols="20" class="inputText"> ${outNode.condition}</textarea>
  182. </td>
  183. </tr>
  184. </c:forEach>
  185. </table>
  186. </form>
  187. </div>
  188. </div>
  189. </body>
  190. </html>