taskVariableConfig.jsp 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <%@include file="/context/mytags.jsp"%>
  4. <t:base type="jquery,easyui,tools" cssTheme="default"></t:base>
  5. <script type="text/javascript">
  6. <!--
  7. var variableFieldsEditCount = 0;
  8. var variableId = '${id}';
  9. var processNode='${processNode}';
  10. var processId='${processId}';
  11. var processDefinitionId='${processDefinitionId}';
  12. var files='processproid,processprokey,processprotype,processproval,processproexp,processproname,processprodatatype';
  13. $(function(){
  14. _task_variable_fields_dg=$('#task-variables-fields-list').datagrid({
  15. //title:"Listener",
  16. url:'activitiController.do?getVariable&processNode='+processNode+'&processId='+processId+'&field='+files+'&variableId='+variableId,//
  17. singleSelect:true,
  18. width:700,
  19. height:200,
  20. iconCls:'icon-edit',
  21. //fit:true,
  22. //idField:'id',
  23. //pagination:true,
  24. //pageSize:15,
  25. //pageNumber:1,
  26. //pageList:[10,15],
  27. rownumbers:true,
  28. //sortName:'id',
  29. //sortOrder:'asc',
  30. striped:true,
  31. toolbar:[{
  32. text:'New',
  33. iconCls:'icon-add',
  34. handler:function(){
  35. if(variableFieldsEditCount>0){
  36. $.messager.alert("error","有可编辑的单元格,不能添加",'error');
  37. return;
  38. }
  39. $('#task-variables-fields-list').datagrid('appendRow',{
  40. processproid:'',
  41. processprokey:'',
  42. processprotype:'',
  43. processproval:'',
  44. processproexp:'',
  45. processproname:'',
  46. processprodatatype:'',
  47. action:''
  48. });
  49. var index = $('#task-variables-fields-list').datagrid('getRows').length-1;
  50. $('#task-variables-fields-list').datagrid('beginEdit', index);
  51. }
  52. }],
  53. onDblClickRow:function(rowIndex,rowData){
  54. editVariableField(rowIndex);
  55. },
  56. onBeforeEdit:function(index,row){
  57. row.editing = true;
  58. $(this).datagrid('refreshRow', index);
  59. variableFieldsEditCount++;
  60. },
  61. onAfterEdit:function(index,row){
  62. row.editing = false;
  63. $(this).datagrid('refreshRow', index);
  64. variableFieldsEditCount--;
  65. },
  66. onCancelEdit:function(index,row){
  67. row.editing = false;
  68. $(this).datagrid('refreshRow', index);
  69. variableFieldsEditCount--;
  70. }
  71. });
  72. $('#fieldSaveBt').linkbutton({
  73. iconCls:"icon-save"
  74. });
  75. $('#fieldCancelBt').linkbutton({
  76. iconCls:"icon-cancel"
  77. });
  78. });
  79. function variableFieldsActionFormatter(value,rowData,rowIndex){
  80. var id = rowIndex;
  81. var s='<img onclick="saveVariableField('+id+')" src="plug-in/designer/img/ok.png" title="'+"确定"+'" style="cursor:hand;"/>';
  82. var c='<img onclick="cancelVariableField('+id+')" src="plug-in/designer/img/cancel.png" title="'+"取消"+'" style="cursor:hand;"/>';
  83. var e='<img onclick="editVariableField('+id+')" src="plug-in/designer/img/modify.png" title="'+"修改"+'" style="cursor:hand;"/>';
  84. if(rowData.editing)
  85. return s;
  86. else
  87. return e;
  88. }
  89. function cancelVariableField(id){
  90. _task_variable_fields_dg.datagrid('cancelEdit', id);
  91. }
  92. function editVariableField(id){
  93. _task_variable_fields_dg.datagrid('beginEdit', id);
  94. }
  95. function saveVariableField(id){
  96. //alert(id);
  97. _task_variable_fields_dg.datagrid('endEdit', id);
  98. //alert(editcount);
  99. }
  100. function refreshAllVariableFields(){
  101. var rs = _task_variable_fields_dg.datagrid('getRows');
  102. for(var i=0;i<rs.length;i++){
  103. var ri =_task_variable_fields_dg.datagrid('getRowIndex',rs[i]);
  104. _task_variable_fields_dg.datagrid('refreshRow',ri);
  105. }
  106. }
  107. function createNewVariable(){
  108. }
  109. function getExsitingForm(){
  110. }
  111. function getVariableFieldsGridChangeRows(){
  112. if(variableFieldsEditCount>0){
  113. $.messager.alert("error","",'error');
  114. return null;
  115. }
  116. var insertRows = _task_variable_fields_dg.datagrid('getChanges','inserted');
  117. var updateRows = _task_variable_fields_dg.datagrid('getChanges','updated');
  118. var deleteRows = _task_variable_fields_dg.datagrid('getChanges','deleted');
  119. var changesRows = {
  120. inserted : [],
  121. updated : [],
  122. deleted : []
  123. };
  124. if (insertRows.length>0) {
  125. for (var i=0;i<insertRows.length;i++) {
  126. changesRows.inserted.push(insertRows[i]);
  127. }
  128. }
  129. if (updateRows.length>0) {
  130. for (var k=0;k<updateRows.length;k++) {
  131. changesRows.updated.push(updateRows[k]);
  132. }
  133. }
  134. if (deleteRows.length>0) {
  135. for (var j=0;j<deleteRows.length;j++) {
  136. changesRows.deleted.push(deleteRows[j]);
  137. }
  138. }
  139. return changesRows;
  140. }
  141. function saveVariableConfig(){
  142. if(variableId != "" && variableId != null && variableId!="null"&&variableId!="NULL"){
  143. var r = updateExistingVariable();
  144. if(!r)return;
  145. }else{
  146. var r = insertNewVariable();
  147. if(!r)return;
  148. }
  149. _variable_win.window('close');
  150. }
  151. function insertNewVariable(){
  152. var changesRows = getVariableFieldsGridChangeRows();
  153. var params="";
  154. if(changesRows == null)return false;
  155. var insertRows = changesRows['inserted'];
  156. if (insertRows.length>0) {
  157. for (var i=0;i<insertRows.length;i++) {
  158. var id=insertRows[i].processproid;
  159. var name=insertRows[i].processprokey;
  160. var value=insertRows[i].processproval;
  161. var type=insertRows[i].processprotype;
  162. var exp=insertRows[i].processproexp;
  163. var remark=insertRows[i].processproname;
  164. var source=insertRows[i].processprodatatype;
  165. params=params+"processId="+processId+"###tid="+tid+"###name="+name+"###type="+type+"###value="+value+"###exp="+exp+"###remark="+remark+"###source="+source+"###varibleid="+id+"@@@";
  166. }
  167. }
  168. $.ajax({
  169. url : "activitiController.do?saveProcessDescriptor",
  170. type : 'POST',
  171. data : {
  172. processDescriptor : '',
  173. processName : '',
  174. processId : processId,
  175. params:params,
  176. nodes:'',
  177. processDefinitionId:processDefinitionId
  178. },
  179. dataType : 'json',
  180. error : function() {
  181. return "";
  182. },
  183. success : function(data) {
  184. if (data.success) {
  185. $.messager.alert('Info', '保存成功!', 'info');
  186. $('#task-variable-properties-list').datagrid('reload');
  187. }
  188. }
  189. });
  190. return true;
  191. }
  192. function updateExistingVariable(){
  193. var params="";
  194. var changesRows = getVariableFieldsGridChangeRows();
  195. if(changesRows == null)return false;
  196. var insertRows = changesRows['inserted'];
  197. var updateRows = changesRows['updated'];
  198. if (insertRows.length>0) {
  199. for (var i=0;i<insertRows.length;i++) {
  200. var id=insertRows[i].processproid;
  201. var name=insertRows[i].processprokey;
  202. var value=insertRows[i].processproval;
  203. var type=insertRows[i].processprotype;
  204. var exp=insertRows[i].processproexp;
  205. var remark=insertRows[i].processproname;
  206. var source=insertRows[i].processprodatatype;
  207. params=params+"processId="+processId+"###tid="+tid+"###name="+name+"###type="+type+"###value="+value+"###exp="+exp+"###remark="+remark+"###source="+source+"###varibleid="+id+"@@@";
  208. }
  209. }
  210. if (updateRows.length>0) {
  211. for (var k=0;k<updateRows.length;k++) {
  212. var id=updateRows[k].processproid;
  213. var name=updateRows[k].processprokey;
  214. var value=updateRows[k].processproval;
  215. var type=updateRows[k].processprotype;
  216. var exp=updateRows[k].processproexp;
  217. var remark=updateRows[k].processproname;
  218. var source=updateRows[k].processprodatatype;
  219. params=params+"processId="+processId+"###tid="+tid+"###name="+name+"###type="+type+"###value="+value+"###exp="+exp+"###remark="+remark+"###source="+source+"###varibleid="+id+"@@@";
  220. }
  221. }
  222. $.ajax({
  223. url : "activitiController.do?saveProcessDescriptor",
  224. type : 'POST',
  225. data : {
  226. processDescriptor : '',
  227. processName : '',
  228. processId : processId,
  229. params:params,
  230. nodes:'',
  231. processDefinitionId:processDefinitionId
  232. },
  233. dataType : 'json',
  234. error : function() {
  235. return "";
  236. },
  237. success : function(data) {
  238. if (data.success) {
  239. $.messager.alert('Info', '保存成功!', 'info');
  240. $('#task-variable-properties-list').datagrid('reload');
  241. }
  242. }
  243. });
  244. return true;
  245. }
  246. function closeTaskVariableWin(){
  247. _variable_win.window('close');
  248. }
  249. //-->
  250. </script>
  251. <table>
  252. <tr>
  253. <td>
  254. <table id="task-variables-fields-list">
  255. <thead>
  256. <tr>
  257. <th field="processproid" hidden="true"></th>
  258. <th field="processprokey" width="100" align="middle" sortable="false" editor="{
  259. type:'validatebox',
  260. options:{
  261. required:true,
  262. validType:'length[1,100]'
  263. }}">名称</th>
  264. <th field="processprotype" width="100" align="middle" sortable="false" editor="{
  265. type:'combobox',
  266. options:{
  267. editable:false,
  268. data:[{id:'S',text:'字符',selected:true},{id:'I',text:'整型'},{id:'B',text:'布尔型'},{id:'F',text:'单精度浮点数'},{id:'L',text:'长整型'},{id:'D',text:'日期'},{id:'SD',text:'sql Date类型'},{id:'N',text:'双精度浮点数'}],
  269. valueField:'id',
  270. textField:'text'
  271. }}">类型</th>
  272. <th field="processproval" width="100" align="middle" sortable="false" editor="{
  273. type:'validatebox',
  274. options:{
  275. validType:'length[1,100]'
  276. }}">值</th>
  277. <th field="processproexp" width="100" align="middle" sortable="false" editor="{
  278. type:'validatebox',
  279. options:{
  280. validType:'length[1,100]'
  281. }}">表达式</th>
  282. <th field="processproname" width="100" align="middle" sortable="false" editor="{
  283. type:'validatebox',
  284. options:{
  285. validType:'length[1,100]'
  286. }}">描述</th>
  287. <th field="processprodatatype" width="100" align="middle" sortable="false" editor="{
  288. type:'combobox',
  289. options:{
  290. editable:false,
  291. data:[{id:'database',text:'数据库'},{id:'page',text:'页面'}],
  292. valueField:'id',
  293. textField:'text'
  294. }}">来源</th>
  295. <th field="action" width="80" align="middle" formatter="variableFieldsActionFormatter">操作</th>
  296. </tr>
  297. </thead>
  298. </table>
  299. </td>
  300. </tr>
  301. <tr>
  302. <td align="center">
  303. <a href="##" id="fieldSaveBt" onclick="saveVariableConfig()">Save</a>
  304. <a href="##" id="fieldCancelBt" onclick="closeTaskVariableWin()">Cancel</a>
  305. </td>
  306. </tr>
  307. </table>