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. 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. debugger;
  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. debugger;
  147. this.form.saveWork();
  148. },
  149. closeWork: function(){
  150. this.form.closeWork();
  151. },
  152. processWork: function(){
  153. this.form.processWork();
  154. },
  155. resetWork: function(){
  156. this.form.resetWork();
  157. },
  158. retractWork: function(e, ev){
  159. this.form.retractWork(e, ev);
  160. },
  161. rerouteWork: function(e, ev){
  162. this.form.rerouteWork(e, ev);
  163. },
  164. deleteWork: function(){
  165. this.form.deleteWork();
  166. },
  167. printWork: function(){
  168. this.form.printWork();
  169. },
  170. readedWork: function(b,e){
  171. this.form.readedWork(e);
  172. }
  173. });