Actionbar.js 8.1 KB

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