bpmDataTemplateScript.jsp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@include file="/commons/include/html_doctype.html"%>
  3. <html>
  4. <head>
  5. <%@include file="/commons/include/form.jsp"%>
  6. <title>设置脚本</title>
  7. <script type="text/javascript" src="${ctx}/js/javacode/codemirror.js"></script>
  8. <link rel="stylesheet" type="text/css" href="${ctx}/js/codemirror/lib/codemirror.css" >
  9. <script type="text/javascript" src="${ctx}/js/codemirror/lib/codemirror.js"></script>
  10. <script type="text/javascript" src="${ctx}/js/codemirror/mode/sql/sql.js"></script>
  11. <style type="text/css">
  12. .CodeMirror{
  13. font-size:medium;
  14. _position:relative;
  15. }
  16. </style>
  17. <script type="text/javascript">
  18. /*KILLDIALOG*/
  19. var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
  20. var winArgs =null;
  21. var editor=null;
  22. $(function(){
  23. //winArgs = window.dialogArguments;
  24. winArgs = dialog.get('data');
  25. var width = $("#scritp").width();
  26. var height = $("#script").height();
  27. editor = CodeMirror.fromTextArea(document.getElementById("script"), {
  28. mode: "text/x-mariadb",
  29. lineWrapping:true,
  30. lineNumbers: true
  31. });
  32. editor.setSize(width,height);
  33. var script =winArgs && winArgs.script;
  34. var tables =winArgs && winArgs.tables;
  35. if(script)
  36. editor.setValue(script);
  37. if(tables)
  38. initCheckTables(tables);
  39. });
  40. function initCheckTables(tables){
  41. for (var i = 0, c; c = tables[i++];) {
  42. var table = c.table;
  43. $('input[name="tables"]').each(function(){
  44. var me=$(this),
  45. val = me.val();
  46. if(table==val)
  47. me.attr("checked",'true');
  48. });
  49. }
  50. }
  51. /**
  52. *选择字段
  53. */
  54. function flowVarChange (){
  55. var me = $(this),
  56. selected=me.find("option:selected"),
  57. source = selected.attr('source'),
  58. table = selected.attr('table'),
  59. val = me.val();
  60. if($.isEmpty(val))
  61. return;
  62. val = table +"." +(source ==1?("F_"+val):val);
  63. me.val('');
  64. editor.replaceSelection(val);
  65. editor.setCursor(1,'');
  66. }
  67. function commFieldChange(){
  68. var me = $(this),
  69. val = me.val();
  70. if($.isEmpty(val))
  71. return;
  72. me.val('');
  73. editor.replaceSelection(val);
  74. }
  75. /**
  76. * OK事件处理
  77. */
  78. function onOk(obj){
  79. var _this = $(obj);
  80. //window.returnValue = getScriptContent();
  81. dialog.get('sucCall')(getScriptContent());
  82. dialog.close();
  83. };
  84. /**
  85. * 获取脚本内容
  86. */
  87. function getScriptContent(){
  88. editor.save();
  89. var json ={},
  90. script = $("#script").val(),
  91. tables = [];
  92. $('input[name="tables"]:checked').each(function(){
  93. var me = $(this),
  94. obj = {};
  95. obj.table = me.val(),
  96. obj.source = me.attr("source"),
  97. obj.mainTable = me.attr("maintable"),
  98. obj.relation = me.attr("relation");
  99. tables.push(obj);
  100. });
  101. json.script =script;
  102. json.tables =tables;
  103. return json;
  104. };
  105. </script>
  106. </head>
  107. <body>
  108. <div class="panel" >
  109. <div class="panel-top">
  110. <div class="tbar-title">
  111. <span class="tbar-label">设置条件脚本</span>
  112. </div>
  113. <div class="panel-toolbar">
  114. <div class="toolBar">
  115. <div class="group">
  116. <a class="link ok" onclick="onOk(this)"><span></span>确定</a>
  117. </div>
  118. <div class="l-bar-separator"></div>
  119. <div class="group">
  120. <a class="link del" href="javascript:;" onclick="dialog.close()"><span></span>关闭</a>
  121. </div>
  122. <div class="tipbox"><a href="javascript:;" class="tipinfo"><span>该脚本为SQL 脚本 ,为where后的脚本,<br/>例:1.BPM_BUS_LINK.BUS_CREATOR_ID=:[CUR_USER]<br/>2.table.field like '%value%'</span></a></div>
  123. </div>
  124. </div>
  125. </div>
  126. <div class="panel-body">
  127. <form id="scriptForm" method="post" action="save.ht">
  128. <table class="table-detail" cellpadding="1" cellspacing="1" border="0" >
  129. <tr>
  130. <td width="40%">字段:
  131. <select id="flowVarsSelect" class="left margin-set" name="flowVars" onchange="flowVarChange.apply(this)">
  132. <option value="">--请选择--</option>
  133. <optgroup class="main-table-item" label="${bpmFormTable.tableDesc}" ></optgroup>
  134. <c:forEach items="${bpmFormTable.fieldList}" var="field">
  135. <option class="field-item" table="${bpmFormTable.tableName}" maintable="${bpmFormTable.tableName}" relation="${bpmFormTable.relation}" source="1" value="${field.fieldName}" chosenopt="${field.jsonOptions}" ctltype="${field.controlType}" ftype="${field.fieldType}" datefmt='${field.datefmt}'>${field.fieldDesc}</option>
  136. </c:forEach>
  137. <c:forEach items="${bpmFormTable.subTableList}" var="subTable">
  138. <optgroup class="sub-table-item" label="${subTable.tableDesc}" ></optgroup>
  139. <c:forEach items="${subTable.fieldList}" var="subField">
  140. <option class="sub-field-item" table="${subTable.tableName}" maintable="${bpmFormTable.tableName}" relation="${subTable.relation}" source="1" value="${subField.fieldName}" chosenopt="${subField.jsonOptions}" ctltype="${subField.controlType}" ftype="${subField.fieldType}" datefmt='${subField.datefmt}'>${subField.fieldDesc}</option>
  141. </c:forEach>
  142. </c:forEach>
  143. <c:forEach items="${bpmFormTable.otherTableList}" var="otherTable">
  144. <optgroup class="other-table-item" label="${otherTable.tableDesc}" ></optgroup>
  145. <c:forEach items="${otherTable.fieldList}" var="otherField">
  146. <option class="other-field-item" table="${otherTable.tableName}" maintable="${bpmFormTable.tableName}" relation="${otherTable.relation}" source="2" value="${otherField.fieldName}" chosenopt="${otherField.jsonOptions}" ctltype="${otherField.controlType}" ftype="${otherField.fieldType}" datefmt='${otherField.datefmt}'>${otherField.fieldDesc}</option>
  147. </c:forEach>
  148. </c:forEach>
  149. </select>
  150. </td>
  151. <td>
  152. 常用字段:
  153. <select id="commFieldSelect" class="left margin-set" name="commFields" onchange="commFieldChange.apply(this)">
  154. <option value="">--请选择--</option>
  155. <c:forEach items="${commonVars}" var="commonVar">
  156. <option value=":${commonVar.alias}">${commonVar.name}</option>
  157. </c:forEach>
  158. </select>
  159. </td>
  160. </tr>
  161. <tr>
  162. <td colspan="2">
  163. 使用的表:<input type="checkbox" value="${bpmFormTable.tableName}" name="tables" maintable="${bpmFormTable.tableName}" relation="${bpmFormTable.relation}" source="1" >${bpmFormTable.tableDesc}
  164. <c:forEach items="${bpmFormTable.subTableList}" var="subTable">
  165. <input type="checkbox" value="${subTable.tableName}" name="tables" maintable="${bpmFormTable.tableName}" relation="${subTable.relation}" source="1" >${subTable.tableDesc}
  166. </c:forEach>
  167. <c:forEach items="${bpmFormTable.otherTableList}" var="otherTable">
  168. <input type="checkbox" value="${otherTable.tableName}" name="tables" maintable="${bpmFormTable.tableName}" relation="${otherTable.relation}" source="2" >${otherTable.tableDesc}
  169. </c:forEach>
  170. </td>
  171. </tr>
  172. <tr>
  173. <td colspan="2">
  174. <textarea id="script" style="width: 100px;height: 300px" ></textarea>
  175. </td>
  176. </tr>
  177. </table>
  178. </form>
  179. </div>
  180. </div>
  181. </body>
  182. </html>