Actionbar.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  18. this.toolbarWidget.load();
  19. }else{
  20. if (this.json.defaultTools){
  21. var o = {
  22. "type": "MWFToolBarButton",
  23. "img": "read.png",
  24. "title": "标记为已阅",
  25. "action": "readedWork",
  26. "text": "已阅",
  27. "id": "action_readed",
  28. "control": "allowReadProcessing",
  29. "condition": "",
  30. "read": false
  31. };
  32. this.json.defaultTools.push(o);
  33. this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly);
  34. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  35. this.toolbarWidget.load();
  36. }else{
  37. MWF.getJSON(this.form.path+"toolbars.json", function(json){
  38. this.setToolbars(json, this.toolbarNode, this.readonly, true);
  39. this.setCustomToolbars(this.json.tools, this.toolbarNode);
  40. this.toolbarWidget.load();
  41. }.bind(this), false);
  42. }
  43. }
  44. // if (this.readonly){
  45. // this.setToolbars(this.json.sysTools.readTools, this.toolbarNode);
  46. //// this.setToolbars(this.json.tools.readTools, this.toolbarNode);
  47. // }else{
  48. // this.setToolbars(this.json.sysTools.editTools, this.toolbarNode);
  49. //// this.setToolbars(this.json.tools.editTools, this.toolbarNode);
  50. // }
  51. // this.setCustomToolbars(this.json.tools, this.toolbarNode);
  52. //
  53. //
  54. // this.toolbarWidget.load();
  55. // var size = this.toolbarNode.getSize();
  56. // this.node.setStyle("height", ""+size.y+"px");
  57. // var nodeSize = this.toolbarNode.getSize();
  58. // this.toolbarNode.setStyles({
  59. // "width": ""+nodeSize.x+"px",
  60. //// "position": "absolute",
  61. // "z-index": 50000
  62. // });
  63. // this.toolbarNode.position({"relativeTo": this.node, "position": "upperLeft", "edge": "upperLeft"});
  64. //
  65. // this.form.node.addEvent("scroll", function(){
  66. // alert("ddd")
  67. // }.bind(this));
  68. }.bind(this));
  69. // }
  70. },
  71. setCustomToolbars: function(tools, node){
  72. debugger;
  73. tools.each(function(tool){
  74. var flag = true;
  75. if (this.readonly){
  76. flag = tool.readShow;
  77. }else{
  78. flag = tool.editShow;
  79. }
  80. if (flag){
  81. flag = true;
  82. if (tool.control){
  83. flag = this.form.businessData.control[tool.control]
  84. }
  85. if (tool.condition){
  86. var hideFlag = this.form.Macro.exec(tool.condition, this);
  87. flag = !hideFlag;
  88. }
  89. if (flag){
  90. var actionNode = new Element("div", {
  91. "id": tool.id,
  92. "MWFnodetype": tool.type,
  93. "MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  94. "title": tool.title,
  95. "MWFButtonAction": "runCustomAction",
  96. "MWFButtonText": tool.text
  97. }).inject(node);
  98. if (tool.actionScript){
  99. actionNode.store("script", tool.actionScript);
  100. }
  101. if (tool.sub){
  102. var subNode = node.getLast();
  103. this.setCustomToolbars(tool.sub, subNode);
  104. }
  105. }
  106. }
  107. }.bind(this));
  108. },
  109. setToolbars: function(tools, node, readonly, noCondition){
  110. tools.each(function(tool){
  111. var flag = true;
  112. if (tool.control){
  113. flag = this.form.businessData.control[tool.control]
  114. }
  115. if (!noCondition) if (tool.condition){
  116. var hideFlag = this.form.Macro.exec(tool.condition, this);
  117. flag = !hideFlag;
  118. }
  119. if (tool.id == "action_processWork"){
  120. if (!this.form.businessData.task){
  121. flag = false;
  122. }
  123. }
  124. if (readonly) if (!tool.read) flag = false;
  125. if (flag){
  126. var actionNode = new Element("div", {
  127. "id": tool.id,
  128. "MWFnodetype": tool.type,
  129. "MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  130. "title": tool.title,
  131. "MWFButtonAction": tool.action,
  132. "MWFButtonText": tool.text
  133. }).inject(node);
  134. if (tool.sub){
  135. var subNode = node.getLast();
  136. this.setToolbars(tool.sub, subNode, readonly, noCondition);
  137. }
  138. }
  139. }.bind(this));
  140. },
  141. runCustomAction: function(bt){
  142. var script = bt.node.retrieve("script");
  143. this.form.Macro.exec(script, this);
  144. },
  145. saveWork: function(){
  146. this.form.saveWork();
  147. },
  148. closeWork: function(){
  149. this.form.closeWork();
  150. },
  151. processWork: function(){
  152. this.form.processWork();
  153. },
  154. resetWork: function(){
  155. this.form.resetWork();
  156. },
  157. retractWork: function(e, ev){
  158. this.form.retractWork(e, ev);
  159. },
  160. rerouteWork: function(e, ev){
  161. this.form.rerouteWork(e, ev);
  162. },
  163. deleteWork: function(){
  164. this.form.deleteWork();
  165. },
  166. printWork: function(){
  167. this.form.printWork();
  168. },
  169. readedWork: function(b,e){
  170. this.form.readedWork(e);
  171. }
  172. });