busQueryRuleScript.jsp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. editor.setCursor(1,'');
  75. }
  76. /**
  77. * OK事件处理
  78. */
  79. function onOk(obj){
  80. var _this = $(obj);
  81. //window.returnValue = getScriptContent();
  82. dialog.get('sucCall')(getScriptContent());
  83. dialog.close();
  84. };
  85. /**
  86. * 获取脚本内容
  87. */
  88. function getScriptContent(){
  89. editor.save();
  90. var json ={},
  91. script = $("#script").val(),
  92. tables = [];
  93. $('input[name="tables"]:checked').each(function(){
  94. var me = $(this),
  95. obj = {};
  96. obj.table = me.val(),
  97. obj.source = me.attr("source"),
  98. obj.mainTable = me.attr("maintable"),
  99. obj.relation = me.attr("relation");
  100. tables.push(obj);
  101. });
  102. json.script =script;
  103. json.tables =tables;
  104. return json;
  105. };
  106. </script>
  107. </head>
  108. <body>
  109. <div class="panel" >
  110. <div class="panel-top">
  111. <div class="tbar-title">
  112. <span class="tbar-label">设置条件脚本</span>
  113. </div>
  114. <div class="panel-toolbar">
  115. <div class="toolBar">
  116. <div class="group">
  117. <a class="link ok" onclick="onOk(this)"><span></span>确定</a>
  118. </div>
  119. <div class="l-bar-separator"></div>
  120. <div class="group">
  121. <a class="link del" href="javascript:;" onclick="dialog.close()"><span></span>关闭</a>
  122. </div>
  123. <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>
  124. </div>
  125. </div>
  126. </div>
  127. <div class="panel-body">
  128. <form id="scriptForm" method="post" action="save.ht">
  129. <table class="table-detail" cellpadding="1" cellspacing="1" border="0" >
  130. <tr>
  131. <td width="40%">字段:
  132. <select id="flowVarsSelect" class="left margin-set" name="flowVars" onchange="flowVarChange.apply(this)">
  133. <option value="">--请选择--</option>
  134. <optgroup class="main-table-item" label="${tableEntity.comment}" ></optgroup>
  135. <c:forEach items="${tableEntity.tableFieldList}" var="tableField">
  136. <option class="field-item" table="${tableEntity.tableName}" maintable="${tableEntity.tableName}" relation="${tableEntity.relation}"
  137. source="2" value="${tableField.name}" chosenopt="" ctltype="${tableField.controlType}" ftype="${tableField.dataType}" datefmt='${tableField.style}'>
  138. ${tableField.desc}
  139. </option>
  140. </c:forEach>
  141. <c:forEach items="${tableEntity.subTableList}" var="subTable">
  142. <optgroup class="sub-table-item" label="${subTable.comment}" ></optgroup>
  143. <c:forEach items="${subTable.tableFieldList}" var="subField">
  144. <option class="sub-field-item" table="${subTable.tableName}" maintable="${tableEntity.tableName}" relation="${subTable.relation}"
  145. source="2" value="${subField.name}" chosenopt="" ctltype="${tableField.controlType}" ftype="${subField.dataType}" datefmt='${tableField.style}'>${subField.desc}</option>
  146. </c:forEach>
  147. </c:forEach>
  148. </select>
  149. </td>
  150. <td>
  151. 常用字段:
  152. <select id="commFieldSelect" class="left margin-set" name="commFields" onchange="commFieldChange.apply(this)">
  153. <option value="">--请选择--</option>
  154. <option value="[CUR_USER]">当前人</option>
  155. <option value="[CUR_ORG]">当前人组织</option>
  156. </select>
  157. </td>
  158. </tr>
  159. <tr>
  160. <td colspan="2">
  161. 使用的表:<input type="checkbox" value="${tableEntity.tableName}" name="tables" maintable="${tableEntity.tableName}" relation="${tableEntity.relation}" source="1" >${tableEntity.comment}
  162. <c:forEach items="${tableEntity.subTableList}" var="subTable">
  163. <input type="checkbox" value="${subTable.tableName}" name="tables" maintable="${tableEntity.tableName}" relation="${subTable.relation}" source="1" >${subTable.comment}
  164. </c:forEach>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td colspan="2">
  169. <textarea id="script" style="width: 100px;height: 300px" ></textarea>
  170. </td>
  171. </tr>
  172. </table>
  173. </form>
  174. </div>
  175. </div>
  176. </body>
  177. </html>