Subform.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.xApplication.process.Xform.Subform = MWF.APPSubform = new Class({
  3. Extends: MWF.APP$Module,
  4. _loadUserInterface: function(){
  5. this.node.empty();
  6. debugger;
  7. this.getSubform(function(){
  8. if (this.subformData){
  9. this.loadSubform();
  10. }
  11. }.bind(this));
  12. },
  13. loadSubform: function(){
  14. if (this.subformData){
  15. //this.form.addEvent("postLoad", function(){
  16. this.node.set("html", this.subformData.html);
  17. debugger;
  18. Object.each(this.subformData.json.moduleList, function(module, key){
  19. var formKey = key;
  20. if (this.form.json.moduleList[key]){
  21. formKey = this.json.id+"_"+key;
  22. var moduleNode = this.node.getElement("#"+key);
  23. if (moduleNode) moduleNode.set("id", formKey);
  24. module.id = formKey;
  25. }
  26. this.form.json.moduleList[formKey] = module;
  27. }.bind(this));
  28. var moduleNodes = this.form._getModuleNodes(this.node);
  29. moduleNodes.each(function(node){
  30. if (node.get("MWFtype")!=="form"){
  31. var json = this.form._getDomjson(node);
  32. var module = this.form._loadModule(json, node);
  33. this.form.modules.push(module);
  34. }
  35. }.bind(this));
  36. //}.bind(this));
  37. }
  38. },
  39. getSubform: function(callback){
  40. debugger;
  41. if (this.json.subformType==="script"){
  42. if (this.json.subformScript.code){
  43. var formNome = this.form.Macro.exec(this.json.subformScript.code, this);
  44. if (formNome){
  45. MWF.Actions.get("x_processplatform_assemble_surface").getForm(formNome, this.form.businessData.work.application, function(json){
  46. this.getSubformData(json.data);
  47. if (callback) callback();
  48. }.bind(this));
  49. }
  50. }
  51. }else{
  52. if (this.json.subformSelected && this.json.subformSelected!=="none"){
  53. MWF.Actions.get("x_processplatform_assemble_surface").getForm(this.json.subformSelected, this.form.businessData.work.application, function(json){
  54. this.getSubformData(json.data);
  55. if (callback) callback();
  56. }.bind(this));
  57. }else{
  58. if (callback) callback();
  59. }
  60. }
  61. },
  62. getSubformData: function(data){
  63. var subformDataStr = null;
  64. if (this.form.options.mode !== "Mobile"){
  65. subformDataStr = data.data;
  66. }else{
  67. subformDataStr = data.mobileData;
  68. }
  69. this.subformData = null;
  70. if (subformDataStr){
  71. this.subformData = JSON.decode(MWF.decodeJsonString(subformDataStr));
  72. this.subformData.updateTime = data.updateTime;
  73. }
  74. }
  75. });