Actionbar.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. MWF.require("MWF.widget.Tree", null, false);
  3. MWF.xApplication.process.Xform.Actionbar = MWF.APPActionbar = new Class({
  4. Extends: MWF.APP$Module,
  5. _loadUserInterface: function(){
  6. // if (this.form.json.mode == "Mobile"){
  7. // this.node.empty();
  8. // }else if (COMMON.Browser.Platform.isMobile){
  9. // this.node.empty();
  10. // }else{
  11. this.toolbarNode = this.node.getFirst("div");
  12. this.toolbarNode.empty();
  13. MWF.require("MWF.widget.Toolbar", function(){
  14. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  15. //alert(this.readonly)
  16. if (this.json.hideSystemTools){
  17. his.setCustomToolbars(this.json.tools, this.toolbarNode);
  18. this.toolbarWidget.load();
  19. }else{
  20. debugger;
  21. if (this.json.defaultTools){
  22. this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly);
  23. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  24. this.toolbarWidget.load();
  25. }else{
  26. MWF.getJSON(this.form.path+"toolbars.json", function(json){
  27. this.setToolbars(json, this.toolbarNode, this.readonly, true);
  28. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  29. this.toolbarWidget.load();
  30. }.bind(this), false);
  31. }
  32. }
  33. // if (this.readonly){
  34. // this.setToolbars(this.json.sysTools.readTools, this.toolbarNode);
  35. //// this.setToolbars(this.json.tools.readTools, this.toolbarNode);
  36. // }else{
  37. // this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  38. //// this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  39. // }
  40. // this.setCustomToolbars(this.json.tools, this.toolbarNode);
  41. //
  42. //
  43. // this.toolbarWidget.load();
  44. // var size = this.toolbarNode.getSize();
  45. // this.node.setStyle("height", ""+size.y+"px");
  46. // var nodeSize = this.toolbarNode.getSize();
  47. // this.toolbarNode.setStyles({
  48. // "width": ""+nodeSize.x+"px",
  49. //// "position": "absolute",
  50. // "z-index": 50000
  51. // });
  52. // this.toolbarNode.position({"relativeTo": this.node, "position": "upperLeft", "edge": "upperLeft"});
  53. //
  54. // this.form.node.addEvent("scroll", function(){
  55. // alert("ddd")
  56. // }.bind(this));
  57. }.bind(this));
  58. // }
  59. },
  60. setCustomToolbars: function(tools, node){
  61. tools.each(function(tool){
  62. var flag = true;
  63. if (this.readonly){
  64. flag = tool.readShow;
  65. }else{
  66. flag = tool.editShow;
  67. }
  68. if (flag){
  69. flag = true;
  70. if (tool.control){
  71. flag = this.form.businessData.control[tool.control]
  72. }
  73. if (tool.condition){
  74. var hideFlag = this.form.Macro.exec(tool.condition, this);
  75. flag = !hideFlag;
  76. }
  77. if (flag){
  78. var actionNode = new Element("div", {
  79. "id": tool.id,
  80. "MWFnodetype": tool.type,
  81. "MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  82. "title": tool.title,
  83. "MWFButtonAction": "runCustomAction",
  84. "MWFButtonText": tool.text
  85. }).inject(node);
  86. if (tool.actionScript){
  87. actionNode.store("script", tool.actionScript);
  88. }
  89. if (tool.sub){
  90. var subNode = node.getLast();
  91. this.setCustomToolbars(tool.sub, subNode);
  92. }
  93. }
  94. }
  95. }.bind(this));
  96. },
  97. setToolbars: function(tools, node, readonly, noCondition){
  98. debugger;
  99. tools.each(function(tool){
  100. var flag = true;
  101. if (tool.control){
  102. flag = this.form.businessData.control[tool.control]
  103. }
  104. if (!noCondition) if (tool.condition){
  105. var hideFlag = this.form.Macro.exec(tool.condition, this);
  106. flag = !hideFlag;
  107. }
  108. if (tool.id == "action_processWork"){
  109. if (!this.form.businessData.task){
  110. flag = false;
  111. }
  112. }
  113. if (readonly) if (!tool.read) flag = false;
  114. if (flag){
  115. var actionNode = new Element("div", {
  116. "id": tool.id,
  117. "MWFnodetype": tool.type,
  118. "MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  119. "title": tool.title,
  120. "MWFButtonAction": tool.action,
  121. "MWFButtonText": tool.text
  122. }).inject(node);
  123. if (tool.sub){
  124. var subNode = node.getLast();
  125. this.setToolbars(tool.sub, subNode, readonly, noCondition);
  126. }
  127. }
  128. }.bind(this));
  129. },
  130. runCustomAction: function(bt){
  131. var script = bt.node.retrieve("script");
  132. this.form.Macro.exec(script, this);
  133. },
  134. saveWork: function(){
  135. debugger;
  136. this.form.saveWork();
  137. },
  138. closeWork: function(){
  139. this.form.closeWork();
  140. },
  141. processWork: function(){
  142. this.form.processWork();
  143. },
  144. resetWork: function(){
  145. this.form.resetWork();
  146. },
  147. retractWork: function(e, ev){
  148. this.form.retractWork(e, ev);
  149. },
  150. rerouteWork: function(e, ev){
  151. this.form.rerouteWork(e, ev);
  152. },
  153. deleteWork: function(){
  154. this.form.deleteWork();
  155. },
  156. printWork: function(){
  157. this.form.printWork();
  158. }
  159. });