Actionbar.js 7.5 KB

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