Actionbar.js 8.4 KB

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