Actionbar.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. tools.each(function(tool){
  73. var flag = true;
  74. if (this.readonly){
  75. flag = tool.readShow;
  76. }else{
  77. flag = tool.editShow;
  78. }
  79. if (flag){
  80. flag = true;
  81. if (tool.control){
  82. flag = this.form.businessData.control[tool.control]
  83. }
  84. if (tool.condition){
  85. var hideFlag = this.form.Macro.exec(tool.condition, this);
  86. flag = !hideFlag;
  87. }
  88. if (flag){
  89. var actionNode = new Element("div", {
  90. "id": tool.id,
  91. "MWFnodetype": tool.type,
  92. "MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  93. "title": tool.title,
  94. "MWFButtonAction": "runCustomAction",
  95. "MWFButtonText": tool.text
  96. }).inject(node);
  97. if (tool.actionScript){
  98. actionNode.store("script", tool.actionScript);
  99. }
  100. if (tool.sub){
  101. var subNode = node.getLast();
  102. this.setCustomToolbars(tool.sub, subNode);
  103. }
  104. }
  105. }
  106. }.bind(this));
  107. },
  108. setToolbars: function(tools, node, readonly, noCondition){
  109. tools.each(function(tool){
  110. var flag = true;
  111. if (tool.control){
  112. flag = this.form.businessData.control[tool.control]
  113. }
  114. if (!noCondition) if (tool.condition){
  115. var hideFlag = this.form.Macro.exec(tool.condition, this);
  116. flag = !hideFlag;
  117. }
  118. if (tool.id == "action_processWork"){
  119. if (!this.form.businessData.task){
  120. flag = false;
  121. }
  122. }
  123. if (readonly) if (!tool.read) flag = false;
  124. if (flag){
  125. var actionNode = new Element("div", {
  126. "id": tool.id,
  127. "MWFnodetype": tool.type,
  128. "MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
  129. "title": tool.title,
  130. "MWFButtonAction": tool.action,
  131. "MWFButtonText": tool.text
  132. }).inject(node);
  133. if (tool.sub){
  134. var subNode = node.getLast();
  135. this.setToolbars(tool.sub, subNode, readonly, noCondition);
  136. }
  137. }
  138. }.bind(this));
  139. },
  140. runCustomAction: function(bt){
  141. var script = bt.node.retrieve("script");
  142. this.form.Macro.exec(script, this);
  143. },
  144. saveWork: function(){
  145. this.form.saveWork();
  146. },
  147. closeWork: function(){
  148. this.form.closeWork();
  149. },
  150. processWork: function(){
  151. this.form.processWork();
  152. },
  153. resetWork: function(){
  154. this.form.resetWork();
  155. },
  156. retractWork: function(e, ev){
  157. this.form.retractWork(e, ev);
  158. },
  159. rerouteWork: function(e, ev){
  160. this.form.rerouteWork(e, ev);
  161. },
  162. deleteWork: function(){
  163. this.form.deleteWork();
  164. },
  165. printWork: function(){
  166. this.form.printWork();
  167. },
  168. readedWork: function(b,e){
  169. this.form.readedWork(e);
  170. }
  171. });