ProcessActionbar.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. MWF.xDesktop.requireApp("process.Xform", "Actionbar", null, false);
  2. MWF.xApplication.cms.Xform.ProcessActionbar = MWF.CMSProcessActionbar = new Class({
  3. Extends: MWF.APPActionbar,
  4. reload : function(){
  5. this._loadUserInterface();
  6. },
  7. _loadUserInterface: function(){
  8. this.toolbarNode = this.node.getFirst("div");
  9. if(!this.toolbarNode)return;
  10. this.toolbarNode.empty();
  11. MWF.require("MWF.widget.Toolbar", function(){
  12. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {
  13. "style": this.json.style,
  14. "onPostLoad" : function(){
  15. this.fireEvent("afterLoad");
  16. }.bind(this)
  17. }, this);
  18. if (this.json.actionStyles) this.toolbarWidget.css = this.json.actionStyles;
  19. //alert(this.readonly)
  20. var CMSActions = [
  21. {
  22. "type": "MWFToolBarButton",
  23. "img": "close.png",
  24. "title": MWF.xApplication.cms.Xform.LP.closeTitle,
  25. "action": "closeDocument",
  26. "text": MWF.xApplication.cms.Xform.LP.close,
  27. "id": "action_close",
  28. "read": true,
  29. "edit" : true
  30. }
  31. // {
  32. // "type": "MWFToolBarButton",
  33. // "img": "edit.png",
  34. // "title": MWF.xApplication.cms.Xform.LP.editTitle,
  35. // "action": "editDocument",
  36. // "id": "action_edit",
  37. // "text": MWF.xApplication.cms.Xform.LP.edit,
  38. // "control": "allowEditDocument",
  39. // "read": true,
  40. // "edit" : false
  41. // },
  42. // {
  43. // "type": "MWFToolBarButton",
  44. // "img": "save.png",
  45. // "title": MWF.xApplication.cms.Xform.LP.saveTitle,
  46. // "action": "saveDocument",
  47. // "text": MWF.xApplication.cms.Xform.LP.save,
  48. // "id": "action_saveData",
  49. // "control": "allowSave",
  50. // "condition": "",
  51. // "read": false,
  52. // "edit" : true
  53. // }
  54. ];
  55. if (!this.json.hideSystemTools){
  56. this.setToolbars(CMSActions, this.toolbarNode, this.readonly);
  57. }
  58. if( this.json.multiTools ){ //自定义操作和系统操作混合的情况,用 system : true 来区分系统和自定义
  59. var jsonStr = JSON.stringify(this.json.multiTools);
  60. jsonStr = o2.bindJson(jsonStr, {"lp": MWF.xApplication.process.Xform.LP.form});
  61. this.json.multiTools = JSON.parse(jsonStr);
  62. this.json.multiTools.each( function (tool) {
  63. if( tool.system ){
  64. }else{
  65. this.setCustomToolbars([tool], this.toolbarNode);
  66. }
  67. }.bind(this));
  68. this.toolbarWidget.load();
  69. }else{
  70. this.setCustomToolbars(this.json.tools || [], this.toolbarNode);
  71. this.toolbarWidget.load();
  72. }
  73. }.bind(this));
  74. // }
  75. },
  76. setToolbars: function(tools, node, readonly, noCondition){
  77. tools.each(function(tool){
  78. var flag = true;
  79. if (tool.control){
  80. flag = this.form.businessData.control[tool.control];
  81. }
  82. if (!noCondition) if (tool.condition){
  83. var hideFlag = this.form.Macro.exec(tool.condition, this);
  84. flag = flag && (!hideFlag);
  85. }
  86. if (readonly){
  87. if (!tool.read) flag = false;
  88. }else{
  89. if (!tool.edit) flag = false;
  90. }
  91. if (flag){
  92. var actionNode = new Element("div", {
  93. "id": tool.id,
  94. "MWFnodetype": tool.type,
  95. "MWFButtonImage": "../x_component_process_FormDesigner/Module/Actionbar/"+(this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
  96. "title": tool.title,
  97. "MWFButtonAction": tool.action,
  98. "MWFButtonText": tool.text
  99. }).inject(node);
  100. if (tool.sub){
  101. var subNode = node.getLast();
  102. this.setToolbars(tool.sub, subNode);
  103. }
  104. }
  105. }.bind(this));
  106. },
  107. runCustomAction: function(bt){
  108. var script = bt.node.retrieve("script");
  109. this.form.Macro.exec(script, this);
  110. },
  111. saveDocument: function(){
  112. this.form.saveDocument();
  113. },
  114. saveDraftDocument: function(){
  115. this.form.saveDocument();
  116. },
  117. closeDocument: function(){
  118. this.form.closeDocument();
  119. },
  120. publishDocument: function(){
  121. this.form.publishDocument();
  122. },
  123. publishDocumentDelayed: function(){
  124. this.form.publishDocumentDelayed();
  125. },
  126. archiveDocument: function(){
  127. this.form.archiveDocument();
  128. },
  129. redraftDocument: function(){
  130. this.form.redraftDocument();
  131. },
  132. deleteDocument: function(){
  133. this.form.deleteDocument();
  134. },
  135. editDocument: function(){
  136. this.form.editDocument();
  137. },
  138. setPopularDocument: function(){
  139. this.form.setPopularDocument();
  140. },
  141. printDocument: function(){
  142. this.form.printDocument();
  143. },
  144. setTop: function(){
  145. this.form.setTop();
  146. },
  147. cancelTop: function(){
  148. this.form.cancelTop();
  149. }
  150. });