Actionbar.js 8.2 KB

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