Main.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. MWF.xApplication.cms = MWF.xApplication.cms || {};
  2. MWF.xApplication.cms.Document = MWF.xApplication.cms.Document || {};
  3. MWF.xApplication.cms.Document.options = MWF.xApplication.cms.Document.options || Object.clone(o2.xApplication.Common.options);
  4. MWF.xApplication.cms.Document.options.multitask = true;
  5. MWF.xApplication.cms.Document.Main = new Class({
  6. Extends: MWF.xApplication.Common.Main,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default",
  10. "name": "cms.Document",
  11. "icon": "icon.png",
  12. "width": "1200",
  13. "height": "680",
  14. "title": MWF.xApplication.cms.Document.LP.title,
  15. "documentId": "",
  16. "isControl": false,
  17. "readonly": true,
  18. "autoSave" : true,
  19. "saveOnClose" : true,
  20. "postPublish" : null,
  21. "postDelete" : null,
  22. "forceFormId" : null, //不管编辑还是阅读都用此表单打开,优先使用
  23. "printFormId" : null, //打印表单,不管编辑还是阅读都用此表单打开,仅此于forceFormId
  24. "readFormId" : null, //强制的阅读表单,优先于表单的readFormId
  25. "editFormId" : null //强制的编辑表单,优先于表单的formId
  26. },
  27. onQueryLoad: function(){
  28. this.lp = MWF.xApplication.cms.Document.LP;
  29. if (this.status){
  30. this.options.documentId = this.status.documentId;
  31. this.options.readonly = (this.status.readonly==="true" || this.status.readonly===true) ? true : false;
  32. this.options.autoSave = (this.status.autoSave==="true" || this.status.autoSave===true) ? true : false;
  33. this.options.saveOnClose = (this.status.saveOnClose==="true" || this.status.saveOnClose===true) ? true : false;
  34. this.options.formId = this.status.formId;
  35. this.options.formEditId = this.status.formEditId;
  36. this.options.printFormId = this.status.printFormId;
  37. this.options.forceFormId = this.status.forceFormId;
  38. this.options.readFormId = this.status.readFormId;
  39. this.options.editFormId = this.status.editFormId;
  40. }
  41. //兼容之前的 formEditId 和 formId
  42. if( this.options.formId && !this.options.readFormId )this.options.readFormId = this.options.formId;
  43. if( this.options.formEditId && !this.options.editFormId )this.options.editFormId = this.options.formEditId;
  44. if( this.options.readonly === "false" )this.options.readonly = false;
  45. if( this.options.documentId && this.options.documentId!=""){
  46. this.options.appId = "cms.Document"+this.options.documentId;
  47. }
  48. },
  49. loadApplication: function(callback){
  50. this.node = new Element("div", {"styles": this.css.content}).inject(this.content);
  51. MWF.require("MWF.widget.Mask", function(){
  52. this.mask = new MWF.widget.Mask({"style": "desktop"});
  53. this.formNode = new Element("div", {"styles": {"min-height": "100%"}}).inject(this.node);
  54. // MWF.xDesktop.requireApp("cms.Document", "Actions.RestActions", function(){
  55. this.action = MWF.Actions.get("x_cms_assemble_control"); //new MWF.xApplication.cms.Document.Actions.RestActions();
  56. if (!this.options.isRefresh){
  57. this.maxSize(function(){
  58. this.mask.loadNode(this.content);
  59. // this.loadDocument();
  60. this.loadDocumentV2();
  61. }.bind(this));
  62. }else{
  63. this.mask.loadNode(this.content);
  64. // this.loadDocument();
  65. this.loadDocumentV2();
  66. }
  67. if (callback) callback();
  68. //}.bind(this));
  69. }.bind(this));
  70. this.addEvent("queryClose", function(){
  71. this.refreshTaskCenter();
  72. }.bind(this));
  73. this.addKeyboardEvents();
  74. },
  75. refreshTaskCenter: function(){
  76. if ( this.desktop.apps && this.desktop.apps["cms.Explorer"]){
  77. if(this.desktop.apps["cms.Explorer"].content){
  78. this.desktop.apps["cms.Explorer"].content.unmask();
  79. }
  80. if( this.desktop.apps["cms.Explorer"] ){
  81. this.desktop.apps["cms.Explorer"].refreshAll();
  82. }
  83. }
  84. },
  85. addKeyboardEvents: function(){
  86. this.addEvent("keySave", function(e){
  87. this.keySave(e);
  88. }.bind(this));
  89. },
  90. keySave: function(e){
  91. if (this.appForm){
  92. if (!this.readonly){
  93. this.appForm.saveDocument();
  94. e.preventDefault();
  95. }
  96. }
  97. },
  98. reload: function(){
  99. this.formNode.empty();
  100. if (this.form){
  101. MWF.release(this.form);
  102. this.form = null;
  103. }
  104. // this.parseDocumentV2(data);
  105. // this.openDocument();
  106. this.loadDocumentV2();
  107. },
  108. loadDocumentV2 : function( callback ){
  109. debugger;
  110. this.loadFormFlag = false;
  111. this.loadDocumentFlag = false;
  112. this.loadModuleFlag = false;
  113. this.json_document = null;
  114. this.json_form = null;
  115. //只读或者匿名查看
  116. var readonly = this.options.readonly !== false || this.options.anonymousAccess;
  117. var formId = "";
  118. if( this.options.forceFormId ) { //有确定的id
  119. formId = this.options.forceFormId;
  120. }else if( this.options.printFormId ){ //有确定的id
  121. formId = this.options.printFormId;
  122. }else if( readonly && this.options.readFormId ){ //只读,并且有只读表单id
  123. formId = this.options.readFormId;
  124. }
  125. if( formId ){
  126. this.getFormV2(formId);
  127. this.getDocumentV2();
  128. }else{
  129. if( readonly ){ //只读情况,不需要判断是否有阅读权限
  130. this.lookupFormV2( true );
  131. }
  132. this.getDocumentV2();
  133. }
  134. var cl = "$all";
  135. MWF.xDesktop.requireApp("cms.Xform", cl, function(){
  136. this.loadModuleFlag = true;
  137. this.checkLoad();
  138. }.bind(this));
  139. },
  140. checkLoad : function ( toLoadForm ) {
  141. if( toLoadForm ){
  142. if( this.json_document ){
  143. this.getFormV2( this.formId );
  144. }else{
  145. this.needLoadForm = true;
  146. }
  147. }
  148. if( this.needLoadForm && !this.loadFormFlag && this.json_document ){
  149. this.needLoadForm = false;
  150. this.getFormV2( this.formId );
  151. }
  152. if( this.loadFormFlag && this.loadDocumentFlag && this.loadModuleFlag ){
  153. this.parseFormV2( this.json_form.data );
  154. if (layout.session && layout.session.user){
  155. this.openDocument();
  156. if (this.mask) this.mask.hide();
  157. }else{
  158. if (layout.sessionPromise){
  159. layout.sessionPromise.then(function(){
  160. this.openDocument();
  161. if (this.mask) this.mask.hide();
  162. }.bind(this), function(){});
  163. }
  164. }
  165. }
  166. },
  167. getDocumentV2 : function(){
  168. var id = this.options.documentId || this.options.id;
  169. var readonly = this.options.readonly !== false;
  170. var documentMethod;
  171. if( this.options.anonymousAccess ){
  172. documentMethod = "getDocumentByAnonymous"
  173. }else if( readonly && !this.options.printFormId){
  174. documentMethod = "viewDocument";
  175. }else{
  176. documentMethod = "getDocument";
  177. }
  178. var attachmentMethod = this.options.anonymousAccess ? "listAttachmentByAnonymous" : "listAttachment";
  179. o2.Actions.invokeAsync([
  180. {"action": this.action, "name": documentMethod},
  181. {"action": this.action, "name": attachmentMethod },
  182. ], {"success": function(jsonDocument, jsonAtt){
  183. if (jsonDocument ){
  184. if( jsonAtt && typeOf( jsonAtt.data ) === "array" ){
  185. jsonDocument.data.attachmentList = jsonAtt.data ;
  186. }else{
  187. jsonDocument.data.attachmentList = [];
  188. }
  189. this.json_document = jsonDocument;
  190. this.loadDocumentFlag = true;
  191. this.parseDocumentV2(this.json_document.data);
  192. //编辑状态要先获取document再判断有没有权限编辑
  193. var toLoadForm = this.options.readonly !== true && !this.options.anonymousAccess;
  194. this.checkLoad( toLoadForm )
  195. }else{
  196. this.errorLoadingV2();
  197. }
  198. }.bind(this), "failure": function(error){
  199. this.errorLoadingV2( error );
  200. }.bind(this)}, id, id);
  201. },
  202. getFormV2 : function( formId, cacheTag, ignoreFromCategory ){
  203. var formMethod;
  204. if( this.options.anonymousAccess ){
  205. formMethod = layout.mobile ? "getFormMobileAnonymousV2" : "getFormAnonymousV2";
  206. }else{
  207. formMethod = layout.mobile ? "getFormMobileV2" : "getFormV2";
  208. }
  209. this.action[formMethod](
  210. formId,
  211. cacheTag || "",
  212. function( jsonForm ){
  213. this.json_form = jsonForm;
  214. this.loadFormFlag = true;
  215. this.checkLoad();
  216. }.bind(this),
  217. function(error){
  218. //没有表单,重新获取分类表单
  219. if( !ignoreFromCategory && this.document && this.document.categoryId ){
  220. this.action.getCategory( this.document.categoryId, function(json){
  221. var d = json.data;
  222. if( this.readonly === true && d.readFormId && d.readFormId != "" ){
  223. this.formId = d.readFormId;
  224. }else{
  225. this.formId = d.formId || d.readFormId;
  226. }
  227. this.getFormV2( this.formId, null,true );
  228. }.bind(this));
  229. }else{
  230. this.errorLoadingV2( error , "form" );
  231. }
  232. }.bind(this)
  233. )
  234. },
  235. lookupFormV2 : function ( isReadonly ) {
  236. var id = this.options.documentId || this.options.id;
  237. var lookupMethod;
  238. if( this.options.anonymousAccess ){
  239. lookupMethod = layout.mobile ? "lookupFormWithDocMobileAnonymousV2" : "lookupFormWithDocAnonymousV2";
  240. }else{
  241. lookupMethod = layout.mobile ? "lookupFormWithDocMobileV2" : "lookupFormWithDocV2";
  242. }
  243. this.action[lookupMethod](id, function(json){
  244. var formId;
  245. if( isReadonly ){
  246. formId = json.data.readFormId || json.data.formId;
  247. }else{
  248. formId = json.data.formId || json.data.readFormId;
  249. }
  250. if (json.data.form){
  251. this.json_form = json;
  252. this.loadFormFlag = true;
  253. this.checkLoad();
  254. }else{
  255. var cacheTag = json.data.cacheTag || "";
  256. this.getFormV2( formId, cacheTag )
  257. }
  258. }.bind(this), function(){
  259. this.checkLoad( true );
  260. }.bind(this));
  261. },
  262. parseFormV2: function( json ){
  263. if (json.form){
  264. this.form = (json.form.data) ? JSON.decode(MWF.decodeJsonString(json.form.data)): null;
  265. this.relatedFormMap = json.relatedFormMap;
  266. this.relatedScriptMap = json.relatedScriptMap;
  267. if( json.form.data )delete json.form.data;
  268. this.formInfor = json.form;
  269. }else{
  270. if( layout.mobile ){
  271. this.form = (json.data.mobileData) ? JSON.decode(MWF.decodeJsonString(json.data.mobileData)): null;
  272. if( !this.form ){
  273. this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  274. }
  275. }else{
  276. this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  277. }
  278. if( json.data.data )delete json.data.data;
  279. if( json.data.mobileData )delete json.data.mobileData;
  280. this.formInfor = json.form;
  281. }
  282. },
  283. parseDocumentV2 : function( data ){
  284. var title = "";
  285. title = data.document.title;
  286. this.setTitle(title);
  287. data.document.subject = data.document.title;
  288. this.data = data.data;
  289. this.attachmentList = data.attachmentList || [];
  290. this.attachmentList.each(function(att){
  291. att.lastUpdateTime = att.updateTime;
  292. att.person = att.creatorUid;
  293. });
  294. this.data.isNew = this.isEmptyObject(this.data) ? true : false;
  295. this.document = data.document;
  296. var isAdmin = false;
  297. if( MWF.AC.isCMSManager() || data.isAppAdmin || data.isCategoryAdmin || data.isManager){
  298. this.options.isControl = true;
  299. this.isAdmin = true;
  300. }
  301. //文档创建人
  302. if( data.isCreator || this.desktop.session.user.distinguishedName==this.document.creatorPerson ){
  303. this.options.isControl = true;
  304. }
  305. //作者权限
  306. if( data.isEditor ){
  307. this.options.isControl = true;
  308. }
  309. if( this.options.readonly ){ //强制只读
  310. this.readonly = true;
  311. }else{
  312. if(this.options.isControl && this.document.docStatus != "archived"){ //有编辑权限并且不是归档状态
  313. this.readonly = false;
  314. }else{
  315. this.readonly = true;
  316. }
  317. }
  318. var formId;
  319. if( this.readonly === true ){
  320. formId = this.options.forceFormId || this.options.printFormId || this.options.readFormId || this.document.readFormId || this.options.editFormId || this.document.form;
  321. }else{
  322. formId = this.options.forceFormId || this.options.printFormId || this.options.editFormId || this.document.form || this.options.readFormId || this.document.readFormId;
  323. }
  324. this.formId = formId;
  325. if(this.readonly || this.document.docStatus == "published"){
  326. this.options.autoSave = false;
  327. this.options.saveOnClose = false;
  328. }
  329. var isControl = this.options.isControl;
  330. this.control = data.control || {
  331. "allowRead": true,
  332. "allowPublishDocument": isControl && this.document.docStatus == "draft",
  333. "allowSave": isControl && this.document.docStatus == "published",
  334. "allowPopularDocument": MWF.AC.isHotPictureManager() && this.document.docStatus == "published",
  335. "allowEditDocument": isControl && !this.document.wf_workId,
  336. "allowDeleteDocument": isControl && !this.document.wf_workId
  337. };
  338. },
  339. errorLoadingV2 : function( error, type ){
  340. var text;
  341. if( type === "form" ){
  342. text = this.lp.formGettedError;
  343. }else{
  344. text = this.lp.documentGettedError;
  345. }
  346. if( error )text = text + ":" + error.responseText;
  347. this.notice( text , "error");
  348. layout.sessionPromise.then(function(){
  349. if (this.mask) this.mask.hide();
  350. this.close();
  351. }.bind(this), function(){});
  352. },
  353. isEmptyObject: function( obj ) {
  354. var name;
  355. for ( name in obj ) {
  356. return false;
  357. }
  358. return true;
  359. },
  360. // getDocument : function( callback ){
  361. // var id = this.options.documentId;
  362. //
  363. // var documentMethod = "getDocument";
  364. // if( this.options.anonymousAccess ){
  365. // documentMethod = "getDocumentByAnonymous"
  366. // }else if( this.options.readonly && !this.options.printFormId){
  367. // documentMethod = "viewDocument";
  368. // }
  369. //
  370. // var attachmentMethod = "listAttachment";
  371. // if( this.options.anonymousAccess ){
  372. // attachmentMethod = "listAttachmentByAnonymous"
  373. // }
  374. //
  375. // o2.Actions.invokeAsync([
  376. // {"action": this.action, "name": documentMethod},
  377. // {"action": this.action, "name": attachmentMethod }
  378. // ], {"success": function(json_document, json_att){
  379. // if (json_document ){
  380. // if( json_att && typeOf( json_att.data ) === "array" ){
  381. // json_document.data.attachmentList = json_att.data ;
  382. // }else{
  383. // json_document.data.attachmentList = [];
  384. // }
  385. // callback(json_document)
  386. // }else{
  387. // this.notice( this.lp.documentGettedError + ":" + error.responseText , "error");
  388. // this.close();
  389. // }
  390. // }.bind(this), "failure": function(){
  391. // this.notice( this.lp.documentGettedError + ":" + error.responseText , "error");
  392. // this.close();
  393. // }.bind(this)}, id);
  394. // },
  395. // loadDocument: function(){
  396. // this.getDocument( function(json){
  397. // json.data = json.data || [];
  398. // this.parseData(json.data);
  399. // this.loadForm( this.formId );
  400. // }.bind(this) );
  401. // },
  402. // errorDocument: function(){
  403. // if (this.mask) this.mask.hide();
  404. // this.node.set("text", "openError");
  405. // },
  406. // loadForm : function( formId, flag ){
  407. // var success = function(json){
  408. // if (json.form){
  409. // this.form = (json.form.data) ? JSON.decode(MWF.decodeJsonString(json.form.data)): null;
  410. // this.relatedFormMap = json.relatedFormMap;
  411. // this.relatedScriptMap = json.relatedScriptMap;
  412. // if( json.form.data )delete json.form.data;
  413. // this.formInfor = json.form;
  414. // }else{
  415. // if( layout.mobile ){
  416. // this.form = (json.data.mobileData) ? JSON.decode(MWF.decodeJsonString(json.data.mobileData)): null;
  417. // if( !this.form ){
  418. // this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  419. // }
  420. // }else{
  421. // this.form = (json.data.data) ? JSON.decode(MWF.decodeJsonString(json.data.data)): null;
  422. // }
  423. // if( json.data.data )delete json.data.data;
  424. // if( json.data.mobileData )delete json.data.mobileData;
  425. // this.formInfor = json.form;
  426. // }
  427. // //this.listAttachment();
  428. // this.openDocument();
  429. // if (this.mask) this.mask.hide();
  430. // }.bind(this);
  431. // var failure = function(error){
  432. // //没有表单,重新获取分类表单
  433. // if( !flag ){
  434. // this.action.getCategory( this.document.categoryId, function(json){
  435. // var d = json.data;
  436. // this.formId = d.formId || d.readFormId;
  437. // if( this.readonly == true && d.readFormId && d.readFormId != "" ){
  438. // this.formId = d.readFormId;
  439. // }
  440. // this.loadForm( this.formId, true );
  441. // }.bind(this));
  442. // }else{
  443. // this.notice( this.lp.formGettedError + ":" + error.responseText , "error");
  444. // this.close();
  445. // }
  446. // }.bind(this);
  447. // if( this.options.printFormId){
  448. // this.action.getForm(this.options.printFormId, function( json ){
  449. // success(json);
  450. // }.bind(this), function(error){
  451. // failure(error)
  452. // }.bind(this));
  453. // }else{
  454. // if( this.options.anonymousAccess ){
  455. // this.action.getFormByAnonymous(formId, function( json ){
  456. // success(json);
  457. // }.bind(this), function(error){
  458. // failure(error)
  459. // }.bind(this));
  460. // }else{
  461. // this.action.getForm(formId, function( json ){
  462. // success(json);
  463. // }.bind(this), function(error){
  464. // failure(error)
  465. // }.bind(this));
  466. // }
  467. // }
  468. // },
  469. // parseData: function(data){
  470. //
  471. // var title = "";
  472. // title = data.document.title;
  473. //
  474. // this.setTitle(title);
  475. //
  476. // data.document.subject = data.document.title;
  477. //
  478. // this.data = data.data;
  479. //
  480. // this.attachmentList = data.attachmentList || [];
  481. // this.attachmentList.each(function(att){
  482. // att.lastUpdateTime = att.updateTime;
  483. // att.person = att.creatorUid;
  484. // });
  485. //
  486. // if( this.isEmptyObject(this.data) ){
  487. // this.data.isNew = true;
  488. // }else{
  489. // this.data.isNew = false;
  490. // }
  491. //
  492. // this.document = data.document;
  493. //
  494. // var isAdmin = false;
  495. //
  496. // if( MWF.AC.isCMSManager() ){
  497. // this.options.isControl = true;
  498. // isAdmin = true;
  499. // }
  500. //
  501. // if( data.isAppAdmin ){
  502. // this.options.isControl = true;
  503. // isAdmin = true;
  504. // }
  505. // if( data.isCategoryAdmin ){
  506. // this.options.isControl = true;
  507. // isAdmin = true;
  508. // }
  509. // if( data.isManager ){
  510. // this.options.isControl = true;
  511. // isAdmin = true;
  512. // }
  513. // this.isAdmin = isAdmin;
  514. //
  515. // //文档创建人
  516. // if( data.isCreator || this.desktop.session.user.distinguishedName==this.document.creatorPerson ){
  517. // this.options.isControl = true;
  518. // }
  519. //
  520. // if( data.isEditor ){ //作者权限
  521. // this.options.isControl = true;
  522. // }
  523. //
  524. // if( this.options.readonly ){ //强制只读
  525. // this.readonly = true;
  526. // }else{
  527. // this.readonly = true;
  528. // if(this.options.isControl && this.document.docStatus != "archived"){
  529. // this.readonly = false;
  530. // }
  531. // }
  532. //
  533. // this.formId = this.document.form || this.document.readFormId;
  534. // if( this.readonly == true && this.document.readFormId && this.document.readFormId != "" ){
  535. // this.formId = this.document.readFormId;
  536. // if(this.options.formId){
  537. // this.formId = this.options.formId
  538. // }
  539. // }else {
  540. // if(this.options.formEditId){
  541. // this.formId = this.options.formEditId
  542. // }
  543. // }
  544. //
  545. // if(this.readonly || this.document.docStatus == "published"){
  546. // this.options.autoSave = false;
  547. // this.options.saveOnClose = false;
  548. // }
  549. //
  550. // //this.attachmentList = data.attachmentList;
  551. //
  552. // //this.inheritedAttachmentList = data.inheritedAttachmentList;
  553. // var isControl = this.options.isControl;
  554. // this.control = data.control || {
  555. // "allowRead": true,
  556. // "allowPublishDocument": isControl && this.document.docStatus == "draft",
  557. // "allowSave": isControl && this.document.docStatus == "published",
  558. // "allowPopularDocument": MWF.AC.isHotPictureManager() && this.document.docStatus == "published",
  559. // "allowEditDocument": isControl && !this.document.wf_workId,
  560. // "allowDeleteDocument": isControl && !this.document.wf_workId
  561. // };
  562. // },
  563. setPopularDocument: function(){
  564. MWF.xDesktop.requireApp("cms.Document", "HotLinkForm", null, false);
  565. var form = new MWF.xApplication.cms.Document.HotLinkForm(this, this.document, {
  566. documentId : this.options.documentId,
  567. summary : this.data.explain || "",
  568. onPostOk : function( id ){
  569. }.bind(this)
  570. },{
  571. app : this, lp : this.lp, css : this.css, actions : this.action
  572. });
  573. form.create();
  574. },
  575. openDocument: function(){
  576. if (this.form){
  577. // MWF.xDesktop.requireApp("cms.Xform", "Form", function(){
  578. MWF.xDesktop.requireApp("cms.Xform", "$all", function(){
  579. this.appForm = new MWF.CMSForm(this.formNode, this.form, {
  580. "readonly": this.readonly,
  581. "autoSave" : this.options.autoSave,
  582. "saveOnClose" : this.options.saveOnClose,
  583. "onPostPublish" : this.options.postPublish,
  584. "onAfterPublish" : this.options.afterPublish,
  585. "onPostDelete" : this.options.postDelete
  586. });
  587. this.appForm.businessData = {
  588. "data": this.data,
  589. "document": this.document,
  590. "control": this.control,
  591. "attachmentList": this.attachmentList,
  592. "status": {
  593. //"readonly": (this.options.readonly) ? true : false
  594. "readonly": this.readonly
  595. }
  596. };
  597. this.appForm.documentAction = this.action;
  598. this.appForm.app = this;
  599. this.appForm.load();
  600. }.bind(this));
  601. }
  602. },
  603. //errorDocument: function(){
  604. //
  605. //},
  606. recordStatus: function(){
  607. var status ={
  608. "documentId": this.options.documentId,
  609. "readonly": this.options.readonly,
  610. "autoSave" : this.options.autoSave,
  611. "saveOnClose" : this.options.saveOnClose
  612. };
  613. if( this.options.readFormId )status.readFormId = this.options.readFormId;
  614. if( this.options.editFormId )status.editFormId = this.options.editFormId;
  615. if( this.options.printFormId )status.printFormId = this.options.printFormId;
  616. if( this.options.forceFormId )status.forceFormId = this.options.forceFormId;
  617. if(this.options.appId && this.options.appId!="")status.appId = this.options.appId;
  618. return status;
  619. },
  620. onPostClose: function(){
  621. if (this.appForm){
  622. this.appForm.modules.each(function(module){
  623. MWF.release(module);
  624. });
  625. MWF.release(this.appForm);
  626. }
  627. }
  628. });