RestActions.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. MWF.xApplication.process = MWF.xApplication.process || {};
  2. MWF.xApplication.process.Work = MWF.xApplication.process.Work || {};
  3. MWF.xApplication.process.Work.Actions = MWF.xApplication.process.Work.Actions || {};
  4. MWF.require("MWF.xDesktop.Actions.RestActions", null, false);
  5. MWF.xApplication.process.Work.Actions.RestActions = new Class({
  6. initialize: function(){
  7. this.actionPath = "/x_component_process_Work/Actions/action.json";
  8. this.actionWork = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "x_component_process_Work");
  9. this.actionWork.getActions = function(callback){
  10. this.getActionActions(this.actionWork, callback);
  11. }.bind(this);
  12. this.actionProcess = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "x_component_process_Work");
  13. this.actionProcess.getActions = function(callback){
  14. this.getActionActions(this.actionProcess, callback);
  15. }.bind(this);
  16. this.actionWorkCompleted = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "x_component_process_Work");
  17. this.actionWorkCompleted.getActions = function(callback){
  18. this.getActionActions(this.actionWorkCompleted, callback);
  19. }.bind(this);
  20. this.actionData = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "x_component_process_Work");
  21. this.actionData.getActions = function(callback){
  22. this.getActionActions(this.actionData, callback);
  23. }.bind(this);
  24. this.actionTask = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "x_component_process_Work");
  25. this.actionTask.getActions = function(callback){
  26. this.getActionActions(this.actionTask, callback);
  27. }.bind(this);
  28. this.actionAttachment = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "x_component_process_Work");
  29. this.actionAttachment.getActions = function(callback){
  30. this.getActionActions(this.actionAttachment, callback);
  31. }.bind(this);
  32. this.actionDesigner = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_designer", "x_component_process_Work");
  33. this.actionDesigner.getActions = function(callback){
  34. this.getActionActions(this.actionDesigner, callback);
  35. }.bind(this);
  36. this.actionView = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface_lookup", "x_component_process_Work");
  37. this.actionView.getActions = function(callback){
  38. this.getActionActions(this.actionView, callback);
  39. }.bind(this);
  40. },
  41. getActionActions: function(action, callback){
  42. if (!action.actions){
  43. this.getActions(function(json){
  44. action.actions = this.actions;
  45. if (callback) callback();
  46. }.bind(this));
  47. }else{
  48. if (callback) callback();
  49. }
  50. },
  51. getActions: function(callback){
  52. if (!this.actions){
  53. MWF.getJSON(this.actionPath, function(json){
  54. this.actions = json;
  55. if (callback) callback();
  56. }.bind(this));
  57. }else{
  58. if (callback) callback();
  59. }
  60. },
  61. getJobByTask: function(success, failure, id, async){
  62. this.actionWork.invoke({"name": "getJobByTask","async": async, "parameter": {"id": id}, "success": success, "failure": failure});
  63. },
  64. getJobByWork: function(success, failure, id, async){
  65. this.actionWork.invoke({"name": "getJobByWork","async": async, "parameter": {"id": id}, "success": success, "failure": failure});
  66. },
  67. getJobByWorkAssignForm: function(success, failure, id, application, form, async){
  68. this.actionWork.invoke({"name": "getJobByWorkAssignForm","async": async, "parameter": {"id": id, "applicationTag": application, "formTag": form}, "success": success, "failure": failure});
  69. },
  70. getJobByWorkMobile: function(success, failure, id, async){
  71. this.actionWork.invoke({"name": "getJobByWorkMobile","async": async, "parameter": {"id": id}, "success": success, "failure": failure});
  72. },
  73. getJobByWorkAssignFormMobile: function(success, failure, id, application, form, async){
  74. this.actionWork.invoke({"name": "getJobByWorkAssignFormMobile","async": async, "parameter": {"id": id, "applicationTag": application, "formTag": form}, "success": success, "failure": failure});
  75. },
  76. rerouteWork: function(success, failure, id, activityId, type, async){
  77. this.actionWork.invoke({"name": "rerouteWork","async": async, "data": null, "parameter": {"id": id, "activityId": activityId, "type": type}, "success": success, "failure": failure});
  78. },
  79. retractWork: function(success, failure, id, async){
  80. this.actionWork.invoke({"name": "retractWork","async": async, "data": null, "parameter": {"id": id}, "success": success, "failure": failure});
  81. },
  82. deleteWork: function(success, failure, id, async){
  83. this.actionWork.invoke({"name": "deleteWork","async": async, "data": null, "parameter": {"id": id}, "success": success, "failure": failure});
  84. },
  85. getJobByWorkCompleted: function(success, failure, id, async){
  86. this.actionWorkCompleted.invoke({"name": "getJobByWorkCompleted","async": async, "parameter": {"id": id}, "success": success, "failure": failure});
  87. },
  88. getJobByWorkCompletedMobile: function(success, failure, id, async){
  89. this.actionWorkCompleted.invoke({"name": "getJobByWorkCompletedMobile","async": async, "parameter": {"id": id}, "success": success, "failure": failure});
  90. },
  91. saveData: function(success, failure, id, data, async){
  92. this.actionData.invoke({"name": "saveData","async": async, "data": data, "parameter": {"id": id}, "success": success, "failure": failure});
  93. },
  94. processTask: function(success, failure, id, data, async){
  95. this.actionTask.invoke({"name": "processTask","async": async, "data": data, "parameter": {"id": id}, "success": success, "failure": failure});
  96. },
  97. resetWork: function(success, failure, id, data, async){
  98. this.actionTask.invoke({"name": "resetWork","async": async, "data": data, "parameter": {"id": id}, "success": success, "failure": failure});
  99. },
  100. uploadAttachment: function(id, success, failure, formData, file){
  101. this.actionAttachment.invoke({"name": "uploadAttachment", "parameter": {"id": id},"data": formData,"file": file,"success": success,"failure": failure});
  102. },
  103. replaceAttachment: function(id, workid, success, failure, formData, file){
  104. this.actionAttachment.invoke({"name": "replaceAttachment", "parameter": {"workid": workid, "id": id},"data": formData,"file": file,"success": success,"failure": failure});
  105. },
  106. getAttachment: function(id, workid, success, failure, async){
  107. this.actionAttachment.invoke({"name": "getAttachment","async": async, "parameter": {"id": id, "workid": workid}, "success": success, "failure": failure});
  108. },
  109. getAttachmentWorkcompleted: function(id, workCompletedId, success, failure, async){
  110. this.actionAttachment.invoke({"name": "getAttachmentWorkcompleted","async": async, "parameter": {"id": id, "workCompletedId": workCompletedId}, "success": success, "failure": failure});
  111. },
  112. deleteAttachment: function(id, workid, success, failure, async){
  113. this.actionAttachment.invoke({"name": "deleteAttachment","async": async, "parameter": {"id": id, "workid": workid}, "success": success, "failure": failure});
  114. },
  115. getView: function(id, workid, success, failure, async){
  116. this.actionDesigner.invoke({"name": "getView","async": async, "parameter": {"id": id}, "success": success, "failure": failure});
  117. },
  118. lookupView: function(id, workid, success, failure, async){
  119. this.actionView.invoke({"name": "lookupView","async": async, "parameter": {"id": id}, "success": success, "failure": failure});
  120. },
  121. getRerouteTo: function(flag, success, failure, async){
  122. this.actionProcess.invoke({"name": "getRerouteTo","async": async, "parameter": {"flag": flag}, "success": success, "failure": failure});
  123. },
  124. getAttachmentData: function(id, workid){
  125. this.actionAttachment.getActions(function(){
  126. var url = this.actionAttachment.actions.getAttachmentData.uri;
  127. url = url.replace("{id}", encodeURIComponent(id));
  128. url = url.replace("{workid}", encodeURIComponent(workid));
  129. window.open(this.actionAttachment.address+url);
  130. }.bind(this));
  131. },
  132. getWorkcompletedAttachmentData: function(id, workid){
  133. this.actionAttachment.getActions(function(){
  134. var url = this.actionAttachment.actions.getWorkcompletedAttachmentData.uri;
  135. url = url.replace("{id}", encodeURIComponent(id));
  136. url = url.replace("{workCompletedId}", encodeURIComponent(workid));
  137. window.open(this.actionAttachment.address+url);
  138. }.bind(this));
  139. },
  140. getAttachmentStream: function(id, workid){
  141. this.actionAttachment.getActions(function(){
  142. var url = this.actionAttachment.actions.getAttachmentStream.uri;
  143. url = url.replace("{id}", encodeURIComponent(id));
  144. url = url.replace("{workid}", encodeURIComponent(workid));
  145. window.open(this.actionAttachment.address+url);
  146. }.bind(this));
  147. },
  148. getWorkcompletedAttachmentStream: function(id, workid){
  149. this.actionAttachment.getActions(function(){
  150. var url = this.actionAttachment.actions.getWorkcompletedAttachmentStream.uri;
  151. url = url.replace("{id}", encodeURIComponent(id));
  152. url = url.replace("{workCompletedId}", encodeURIComponent(workid));
  153. window.open(this.actionAttachment.address+url);
  154. }.bind(this));
  155. },
  156. getAttachmentUrl: function(id, workid, callback){
  157. this.actionAttachment.getActions(function(){
  158. var url = this.actionAttachment.actions.getAttachmentData.uri;
  159. url = url.replace("{id}", encodeURIComponent(id));
  160. url = url.replace("{workid}", encodeURIComponent(workid));
  161. if (callback) callback(this.actionAttachment.address+url);
  162. }.bind(this));
  163. },
  164. getAttachmentWorkcompletedUrl: function(id, workid, callback){
  165. this.actionAttachment.getActions(function(){
  166. var url = this.actionAttachment.actions.getWorkcompletedAttachmentData.uri;
  167. url = url.replace("{id}", encodeURIComponent(id));
  168. url = url.replace("{workCompletedId}", encodeURIComponent(workid));
  169. if (callback) callback(this.actionAttachment.address+url);
  170. }.bind(this));
  171. }
  172. });