Main.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. MWF.xApplication.process.Work.options = Object.clone(o2.xApplication.Common.options);
  2. MWF.xApplication.process.Work.options.multitask = true;
  3. MWF.xApplication.process.Work.Main = new Class({
  4. Extends: MWF.xApplication.Common.Main,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "name": "process.Work",
  9. "icon": "icon.png",
  10. "width": "1200",
  11. "height": "800",
  12. "title": MWF.xApplication.process.Work.LP.title,
  13. "workId": "",
  14. "draftId": "",
  15. "draft": null,
  16. "workCompletedId": "",
  17. "taskId": "",
  18. "jobId": "",
  19. "form": null,
  20. "priorityWork": "",
  21. "isControl": false,
  22. "taskObject": null,
  23. "readonly": false,
  24. "worklogType": "record" //record, worklog
  25. },
  26. onQueryLoad: function(){
  27. debugger;
  28. this.lp = MWF.xApplication.process.Work.LP;
  29. if (!this.status) {
  30. } else {
  31. this.options.workId = this.status.workId;
  32. this.options.workCompletedId = this.status.workCompletedId;
  33. this.options.jobId = this.status.jobId;
  34. this.options.draftId = this.status.draftId;
  35. this.options.priorityWork = this.status.priorityWork;
  36. this.options.readonly = (this.status.readonly === "true");
  37. }
  38. this.action = MWF.Actions.get("x_processplatform_assemble_surface");
  39. },
  40. loadWorkApplication: function(callback, mask){
  41. debugger;
  42. var maskStyle = (Browser.name=="firefox") ? "work_firefox" : "desktop";
  43. //alert(maskStyle);
  44. if (mask) this.mask = new MWF.widget.Mask({"style": maskStyle, "loading": mask});
  45. this.formNode = new Element("div", {"styles": this.css.formNode}).inject(this.node);
  46. if (!this.options.isRefresh){
  47. this.maxSize(function(){
  48. if (mask) this.mask.loadNode(this.content);
  49. this.loadWork();
  50. }.bind(this));
  51. }else{
  52. if (mask) this.mask.loadNode(this.content);
  53. this.loadWork();
  54. }
  55. if (callback) callback();
  56. },
  57. loadApplication: function(callback){
  58. this.node = new Element("div", {"styles": this.css.content}).inject(this.content);
  59. if (layout.mobile){
  60. this.loadWorkApplication(callback, false)
  61. }else{
  62. if (layout.viewMode=="Default"){
  63. MWF.require("MWF.widget.Mask", function(){
  64. this.loadWorkApplication(callback, true);
  65. }.bind(this));
  66. }else{
  67. this.loadWorkApplication(callback, false);
  68. }
  69. }
  70. this.addEvent("postClose", function(){
  71. //this.refreshTaskCenter();
  72. }.bind(this));
  73. this.addKeyboardEvents();
  74. },
  75. refreshTaskCenter: function(){
  76. if (this.desktop.apps){
  77. if (this.desktop.apps["TaskCenter"]){
  78. if(this.desktop.apps["TaskCenter"].content){
  79. this.desktop.apps["TaskCenter"].content.unmask();
  80. }
  81. if(this.desktop.apps["TaskCenter"].refreshAll){
  82. this.desktop.apps["TaskCenter"].refreshAll();
  83. }
  84. }
  85. }
  86. },
  87. addKeyboardEvents: function(){
  88. this.addEvent("keySave", function(e){
  89. this.keySave(e);
  90. }.bind(this));
  91. },
  92. keySave: function(e){
  93. if (this.appForm){
  94. if (!this.options.readonly){
  95. this.appForm.saveWork();
  96. e.preventDefault();
  97. }
  98. }
  99. },
  100. reload: function(data){
  101. if (this.form){
  102. this.formNode.empty();
  103. MWF.release(this.form);
  104. this.form = null;
  105. }
  106. if (data){
  107. this.parseData(data);
  108. this.openWork();
  109. }else{
  110. this.loadWork();
  111. }
  112. },
  113. loadWork: function(){
  114. var id = this.options.workCompletedId || this.options.workId || this.options.workid || this.options.workcompletedid;
  115. // var methods = {
  116. // "loadWork": false,
  117. // "getWorkControl": false,
  118. // "getForm": false
  119. // };
  120. if (id){
  121. this.loadWorkByWork(id);
  122. // }.bind(this), "failure": function(){}}, [id, true, true, true], id);
  123. }else if (this.options.draftId || this.options.draftid){
  124. var draftId = this.options.draftId || this.options.draftid;
  125. MWF.Actions.get("x_processplatform_assemble_surface").getDraft(draftId, function(json){
  126. this.loadWorkByDraft(json.data.work, json.data.data);
  127. }.bind(this));
  128. }else if (this.options.draft){
  129. this.loadWorkByDraft(this.options.draft);
  130. }else if (this.options.jobId || this.options.jobid || this.options.job){
  131. var jobId = this.options.jobId || this.options.jobid || this.options.job;
  132. delete this.options.jobId;
  133. delete this.options.jobid;
  134. delete this.options.job;
  135. this.loadWorkByJob(jobId);
  136. }
  137. },
  138. loadWorkByWork: function(id){
  139. //var getWorkLogMothed = "getWorkLog"; //以前使用worklog,现在改成record了
  140. var getWorkLogMothed = (this.options.worklogType.toLowerCase()==="worklog") ? "getWorkLog" : "getRecordLog";
  141. if (this.options.form && this.options.form.id && this.options.form.app){
  142. o2.Actions.invokeAsync([
  143. {"action": this.action, "name": "getForm"},
  144. {"action": this.action, "name": "loadWork"},
  145. {"action": this.action, "name": "getWorkControl"},
  146. {"action": this.action, "name": "getWorkLog"},
  147. {"action": this.action, "name": "getRecordLog"},
  148. {"action": this.action, "name": "listAttachments"}
  149. ], {"success": function(json_form, json_work, json_control, json_log, json_record, json_att){
  150. if (json_work && json_control && json_form && json_log && json_att){
  151. this.parseData(json_work.data, json_control.data, json_form.data, json_log.data, json_record.data, json_att.data);
  152. if (this.mask) this.mask.hide();
  153. //if (layout.mobile) this.loadMobileActions();
  154. this.openWork();
  155. this.unLoading();
  156. } else{
  157. if (this.options.jobId || this.options.jobid || this.options.job){
  158. delete this.options.workCompletedId;
  159. delete this.options.workId;
  160. delete this.options.workid;
  161. delete this.options.workcompletedid;
  162. this.loadWork();
  163. }else{
  164. this.close();
  165. }
  166. }
  167. }.bind(this), "failure": function(){
  168. //this.close();
  169. }.bind(this)}, [this.options.form.id, this.options.form.app], id);
  170. }else{
  171. o2.Actions.invokeAsync([
  172. {"action": this.action, "name": (layout.mobile) ? "getWorkFormMobile": "getWorkForm"},
  173. {"action": this.action, "name": "loadWork"},
  174. {"action": this.action, "name": "getWorkControl"},
  175. {"action": this.action, "name": "getWorkLog"},
  176. {"action": this.action, "name": "getRecordLog"},
  177. {"action": this.action, "name": "listAttachments"}
  178. ], {"success": function(json_form, json_work, json_control, json_log, json_record, json_att){
  179. if (json_work && json_control && json_form && json_log && json_att){
  180. this.parseData(json_work.data, json_control.data, json_form.data, json_log.data, json_record.data, json_att.data);
  181. if (this.mask) this.mask.hide();
  182. //if (layout.mobile) this.loadMobileActions();
  183. this.openWork();
  184. this.unLoading();
  185. } else{
  186. if (this.options.jobId || this.options.jobid || this.options.job){
  187. delete this.options.workCompletedId;
  188. delete this.options.workId;
  189. delete this.options.workid;
  190. delete this.options.workcompletedid;
  191. this.loadWork();
  192. }else{
  193. this.close();
  194. }
  195. }
  196. }.bind(this), "failure": function(){
  197. //this.close();
  198. }.bind(this)}, id);
  199. }
  200. },
  201. loadWorkByJob: function(jobId){
  202. MWF.Actions.get("x_processplatform_assemble_surface").listWorkByJob(jobId, function(json){
  203. var workCompletedCount = json.data.workCompletedList.length;
  204. var workCount = json.data.workList.length;
  205. var count = workCount+workCompletedCount;
  206. if (count===1){
  207. this.options.workId = (json.data.workList.length) ? json.data.workList[0].id : json.data.workCompletedList[0].id;
  208. this.loadWork();
  209. }else if (count>1){
  210. var id = this.filterId(json.data.workList, json.data.workCompletedList, this.options.priorityWork);
  211. if (id) {
  212. this.options.workId = id;
  213. this.loadWork();
  214. }else{
  215. if (this.options.choice){
  216. var worksAreaNode = this.createWorksArea();
  217. // for (var x=0;x<3;x++){
  218. json.data.workList.each(function(work){
  219. this.createWorkNode(work, worksAreaNode);
  220. }.bind(this));
  221. json.data.workCompletedList.each(function(work){
  222. this.createWorkCompletedNode(work, worksAreaNode);
  223. }.bind(this));
  224. // }
  225. if (this.mask) this.mask.hide();
  226. this.formNode.setStyles(this.css.formNode_bg);
  227. }else{
  228. if (json.data.workList.length){
  229. this.options.workId = json.data.workList[0].id;
  230. }else{
  231. this.options.workId = json.data.workCompletedList[0].id;
  232. }
  233. this.loadWork();
  234. }
  235. }
  236. }else{
  237. this.close();
  238. }
  239. }.bind(this), function(){
  240. this.close();
  241. }.bind(this));
  242. },
  243. loadWorkByDraft: function(work, data){
  244. debugger;
  245. o2.Actions.invokeAsync([
  246. {"action": this.action, "name": (layout.mobile) ? "getFormMobile": "getForm"}
  247. ], {"success": function(json_form){
  248. if (json_form){
  249. var workData = {
  250. "activity": {},
  251. "data": data || {},
  252. "taskList": [],
  253. "work": work
  254. };
  255. var control = {
  256. "allowVisit": true,
  257. "allowProcessing": true,
  258. "allowSave": true,
  259. "allowDelete": true
  260. };
  261. this.parseData(workData, control, json_form.data, [], [], []);
  262. if (this.mask) this.mask.hide();
  263. //if (layout.mobile) this.loadMobileActions();
  264. this.openWork();
  265. this.unLoading();
  266. }
  267. }.bind(this), "failure": function(){}}, [work.form, work.application]);
  268. },
  269. createWorkNode: function(work, node, completed){
  270. var contentNode = node.getLast();
  271. var workNode = new Element("div", {"styles": this.css.workItemNode}).inject(contentNode);
  272. var titleNode = new Element("div", {"styles": this.css.workItemTitleNode}).inject(workNode);
  273. titleNode.set("text", work.title);
  274. var inforNode = new Element("div", {"styles": this.css.workItemInforNode}).inject(workNode);
  275. if (completed){
  276. inforNode.set("text", this.lp.completedWork);
  277. }else{
  278. var activityTitleNode = new Element("div", {"styles": this.css.workItemInforTitleNode, "text": this.lp.currentActivity}).inject(inforNode);
  279. var activityContentNode = new Element("div", {"styles": this.css.workItemInforContentNode, "text": work.activityName}).inject(inforNode);
  280. var userTitleNode = new Element("div", {"styles": this.css.workItemInforTitleNode, "text": this.lp.currentUsers}).inject(inforNode);
  281. var taskUsers = [];
  282. MWF.Actions.get("x_processplatform_assemble_surface").listTaskByWork(work.id, function(json){
  283. json.data.each(function(task){
  284. taskUsers.push(MWF.name.cn(task.person));
  285. }.bind(this));
  286. var activityContentNode = new Element("div", {"styles": this.css.workItemInforContentNode, "text": taskUsers.join(", ")}).inject(inforNode);
  287. }.bind(this));
  288. }
  289. var _self = this;
  290. workNode.store("workId", work.id);
  291. workNode.addEvents({
  292. "mouseover": function(){
  293. this.addClass("mainColor_border");
  294. this.setStyles(_self.css.workItemNode_over);
  295. },
  296. "mouseout": function(){
  297. this.removeClass("mainColor_border");
  298. this.setStyles(_self.css.workItemNode);
  299. },
  300. "click": function(){
  301. var id = this.retrieve("workId");
  302. if (id){
  303. _self.options.workId = id;
  304. _self.loadWork();
  305. }
  306. },
  307. });
  308. },
  309. createWorksArea: function(){
  310. var node = new Element("div", {"styles": this.css.workListArea}).inject(this.formNode);
  311. var titleNode = new Element("div", {"styles": this.css.workListAreaTitle, "text": this.lp.selectWork}).inject(node);
  312. var contentNode = new Element("div", {"styles": this.css.workListContent}).inject(node);
  313. return node;
  314. },
  315. filterId: function(list, completedList, id){
  316. if (!id) return "";
  317. if (!list.length && !completedList.length) return "";
  318. if (list.length){
  319. var o = list.filter(function(work){
  320. return work.id == id;
  321. }.bind(this));
  322. if (o.length) return o[0].id;
  323. }
  324. if (completedList.length) {
  325. o = completedList.filter(function(work){
  326. return work.id == id;
  327. }.bind(this));
  328. return (o.length) ? o[0].id : "";
  329. }
  330. return "";
  331. },
  332. parseData: function(workData, controlData, formData, logData, recordData, attData){
  333. debugger;
  334. var title = workData.work.title;
  335. //this.setTitle(this.options.title+"-"+title);
  336. this.setTitle(title || this.options.title);
  337. //routeList 等字段放在 properties 中了,这段代码是兼容以前的脚本
  338. //( workData.taskList || [] ).each(function(task){
  339. // if( task.properties && typeOf( task.properties ) === "object"){
  340. // if( !task.routeList )task.routeList = task.properties.routeList;
  341. // if( !task.routeNameList )task.routeNameList = task.properties.routeNameList;
  342. // if( !task.routeOpinionList )task.routeOpinionList = task.properties.routeOpinionList;
  343. // if( !task.routeDecisionOpinionList )task.routeDecisionOpinionList = task.properties.routeDecisionOpinionList;
  344. // }
  345. //});
  346. this.activity = workData.activity;
  347. this.data = workData.data;
  348. this.taskList = workData.taskList;
  349. this.currentTask = this.getCurrentTaskData(workData);
  350. this.taskList = workData.taskList;
  351. this.readList = workData.readList;
  352. this.work = workData.work;
  353. this.workCompleted = (workData.work.completedTime) ? workData.work : null;
  354. this.workLogList = logData;
  355. this.recordList = recordData;
  356. this.attachmentList = attData;
  357. //this.inheritedAttachmentList = data.inheritedAttachmentList;
  358. this.control = controlData;
  359. if (formData){
  360. if (formData.form){
  361. this.form = (formData.form.data) ? JSON.decode(MWF.decodeJsonString(formData.form.data)): null;
  362. //
  363. // var rex = /mwftype="subform"/gi;
  364. //
  365. //
  366. // debugger;
  367. this.relatedFormMap = formData.relatedFormMap;
  368. this.relatedScriptMap = formData.relatedScriptMap;
  369. delete formData.form.data;
  370. this.formInfor = formData.form;
  371. }else{
  372. this.form = (formData.data) ? JSON.decode(MWF.decodeJsonString(formData.data)): null;
  373. delete formData.data;
  374. this.formInfor = formData;
  375. }
  376. }
  377. },
  378. // loadWork2: function(){
  379. // var method = "";
  380. // var id = "";
  381. //
  382. // if (this.options.workCompletedId){
  383. // method = (layout.mobile) ? "getJobByWorkCompletedMobile" : "getJobByWorkCompleted";
  384. // id = this.options.workCompletedId;
  385. // }else if (this.options.workId) {
  386. // method = (layout.mobile) ? "getJobByWorkMobile" : "getJobByWork";
  387. // id = this.options.workId;
  388. // }
  389. // if (method && id){
  390. // this.action[method](function(json){
  391. // if (this.mask) this.mask.hide();
  392. // this.parseData(json.data);
  393. // if (layout.mobile) this.loadMobileActions();
  394. // this.openWork();
  395. // }.bind(this), function(){
  396. // this.close();
  397. // }.bind(this), id);
  398. // }
  399. // },
  400. loadMobileActions: function(){
  401. if( this.control.allowSave || this.control.allowProcessing ){
  402. this.mobileActionBarNode = new Element("div", {"styles": this.css.mobileActionBarNode}).inject(this.node, "after");
  403. var size = this.content.getSize();
  404. var y = size.y-40;
  405. this.node.setStyles({
  406. "height": ""+y+"px",
  407. "min-height": ""+y+"px",
  408. "overflow": "auto",
  409. "padding-bottom": "40px"
  410. });
  411. //this.node.set("id", "formNode111111111");
  412. }
  413. if( this.control.allowSave ){
  414. this.mobileSaveActionNode = new Element("div", {"styles": this.css.mobileSaveActionNode, "text": this.lp.save}).inject(this.mobileActionBarNode);
  415. this.mobileSaveActionNode.addEvents({
  416. "click": function(){
  417. this.appForm.saveWork();
  418. }.bind(this),
  419. "touchstart": function(){
  420. this.setStyle("background-color", "#EEEEEE");
  421. },
  422. "touchcancel": function(){
  423. this.setStyle("background-color", "#ffffff");
  424. },
  425. "touchend": function(){
  426. this.setStyle("background-color", "#ffffff");
  427. }
  428. });
  429. if (this.control.allowProcessing){
  430. this.mobileSaveActionNode.setStyles({
  431. "width": "49%",
  432. "float": "left"
  433. });
  434. }
  435. }
  436. if( this.control.allowProcessing ){
  437. this.mobileProcessActionNode = new Element("div", {"styles": this.css.mobileSaveActionNode, "text": this.lp.process}).inject(this.mobileActionBarNode);
  438. this.mobileProcessActionNode.addEvents({
  439. "click": function(){
  440. this.appForm.processWork();
  441. }.bind(this),
  442. "touchstart": function(){
  443. this.setStyle("background-color", "#EEEEEE");
  444. },
  445. "touchcancel": function(){
  446. this.setStyle("background-color", "#ffffff");
  447. },
  448. "touchend": function(){
  449. this.setStyle("background-color", "#ffffff");
  450. }
  451. });
  452. if (this.control.allowSave){
  453. this.mobileProcessActionNode.setStyles({
  454. "width": "49%",
  455. "float": "right"
  456. });
  457. }
  458. }
  459. },
  460. errorWork: function(){
  461. if (this.mask) this.mask.hide();
  462. this.node.set("text", "openError");
  463. },
  464. getCurrentTaskData: function(data){
  465. if ((data.currentTaskIndex || data.currentTaskIndex===0) && data.currentTaskIndex != -1){
  466. this.options.taskId = this.taskList[data.currentTaskIndex].id;
  467. return this.taskList[data.currentTaskIndex];
  468. }
  469. //if (this.taskList){
  470. // if (this.taskList.length==1){
  471. // this.options.taskId = this.taskList[0].id;
  472. // return this.taskList[0];
  473. // }
  474. //}
  475. return null;
  476. },
  477. // parseData: function(data){
  478. // var title = "";
  479. // if (this.options.taskId){
  480. // title = data.work.title;
  481. // this.options.workId = data.work.id;
  482. // }else if (this.options.workCompletedId){
  483. // title = data.workCompleted.title;
  484. // this.options.workCompleted = data.workCompleted.id;
  485. // }else if (this.options.workId) {
  486. // title = data.work.title;
  487. // this.options.workId = data.work.id;
  488. // }
  489. //
  490. // this.setTitle(this.options.title+"-"+title);
  491. //
  492. // this.activity = data.activity;
  493. // this.data = data.data;
  494. // this.taskList = data.taskList;
  495. // this.currentTask = this.getCurrentTaskData(data);
  496. // this.taskList = data.taskList;
  497. // this.readList = data.readList;
  498. // this.work = data.work;
  499. // this.workCompleted = data.workCompleted;
  500. // this.workLogList = data.workLogList;
  501. // this.attachmentList = data.attachmentList;
  502. // this.inheritedAttachmentList = data.inheritedAttachmentList;
  503. // this.control = data.control;
  504. // this.form = (data.form) ? JSON.decode(MWF.decodeJsonString(data.form.data)): null;
  505. // this.formInfor = data.form;
  506. // },
  507. openWork: function(){
  508. if (this.form){
  509. //this.readonly = true;
  510. //if (this.currentTask) {
  511. // this.readonly = false;
  512. //}else if(this.options.isControl && this.work){
  513. // this.readonly = false;
  514. //}
  515. // MWF.xDesktop.requireApp("process.Xform", "Package", function(){
  516. // MWF.xApplication.process.Xform.require(function(){
  517. // this.appForm = new MWF.APPForm(this.formNode, this.form, {});
  518. // this.appForm.businessData = {
  519. // "data": this.data,
  520. // "taskList": this.taskList,
  521. // "readList": this.readList,
  522. // "work": this.work,
  523. // "workCompleted": this.workCompleted,
  524. // "control": this.control,
  525. // "activity": this.activity,
  526. // "task": this.currentTask,
  527. // "workLogList": this.workLogList,
  528. // "attachmentList": this.attachmentList,
  529. // "inheritedAttachmentList": this.inheritedAttachmentList,
  530. // "formInfor": this.formInfor,
  531. // "status": {
  532. // //"readonly": (this.options.readonly) ? true : false
  533. // "readonly": this.readonly
  534. // }
  535. // };
  536. // this.appForm.workAction = this.action;
  537. // this.appForm.app = this;
  538. // this.appForm.load();
  539. // }.bind(this));
  540. // }.bind(this));
  541. this.formNode.empty();
  542. this.formNode.setStyles(this.css.formNode);
  543. var uri = window.location.href;
  544. //var cl = (uri.indexOf("$all")!=-1) ? "$all" : "Form";
  545. var cl = "$all";
  546. MWF.xDesktop.requireApp("process.Xform", cl, function(){
  547. //MWF.xDesktop.requireApp("process.Xform", "Form", function(){
  548. this.appForm = new MWF.APPForm(this.formNode, this.form, {});
  549. this.appForm.businessData = {
  550. "data": this.data,
  551. "originalData" : Object.clone( this.data ),
  552. "taskList": this.taskList,
  553. "readList": this.readList,
  554. "work": this.work,
  555. "workCompleted": this.workCompleted,
  556. "control": this.control,
  557. "activity": this.activity,
  558. "task": this.currentTask,
  559. "workLogList": this.workLogList,
  560. "recordList": this.recordList,
  561. "attachmentList": this.attachmentList,
  562. "inheritedAttachmentList": this.inheritedAttachmentList,
  563. "formInfor": this.formInfor,
  564. "status": {
  565. //"readonly": (this.options.readonly) ? true : false
  566. "readonly": this.readonly
  567. }
  568. };
  569. this.appForm.workAction = this.action;
  570. this.appForm.app = this;
  571. if( this.$events && this.$events.queryLoadForm ){
  572. this.appForm.addEvent( "queryLoad", function () {
  573. this.fireEvent("queryLoadForm");
  574. }.bind(this));
  575. }
  576. this.appForm.load(function(){
  577. if (this.mask) this.mask.hide();
  578. if (window.o2android && window.o2android.appFormLoaded){
  579. layout.appForm = this.appForm;
  580. window.o2android.appFormLoaded(JSON.stringify(this.appForm.mobileTools));
  581. }
  582. if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.appFormLoaded){
  583. layout.appForm = this.appForm;
  584. window.webkit.messageHandlers.appFormLoaded.postMessage(JSON.stringify(this.appForm.mobileTools));
  585. }
  586. debugger;
  587. if (this.options.action=="processTask"){
  588. this.appForm.processWork();
  589. this.options.action = "";
  590. }
  591. this.fireEvent("postLoadForm");
  592. }.bind(this));
  593. }.bind(this));
  594. }
  595. },
  596. //errorWork: function(){
  597. //
  598. //},
  599. recordStatus: function(){
  600. debugger;
  601. return {"workId": this.options.workId, "workCompletedId": this.options.workCompletedId, "jobId": this.options.jobId, "draftId": this.options.draftId, "priorityWork": this.options.priorityWork, "readonly": this.readonly};
  602. },
  603. onPostClose: function(){
  604. if (this.appForm){
  605. this.appForm.modules.each(function(module){
  606. MWF.release(module);
  607. });
  608. MWF.release(this.appForm);
  609. }
  610. }
  611. });