Main.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. MWF.xApplication.ExeManager = MWF.xApplication.ExeManager || {};
  2. MWF.require("MWF.widget.Identity", null,false);
  3. MWF.xDesktop.requireApp("ExeManager", "Actions.RestActions", null, false);
  4. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  5. MWF.xApplication.ExeManager.options = {
  6. multitask: false,
  7. executable: true
  8. }
  9. MWF.xApplication.ExeManager.Main = new Class({
  10. Extends: MWF.xApplication.Common.Main,
  11. Implements: [Options, Events],
  12. options: {
  13. "style": "default",
  14. "name": "ExeManager",
  15. "icon": "icon1.png",
  16. "width": "1270",
  17. "height": "700",
  18. "isResize": false,
  19. "isMax": true,
  20. "title": MWF.xApplication.ExeManager.LP.main.topBartitle
  21. },
  22. onQueryLoad: function(){
  23. this.lp = MWF.xApplication.ExeManager.LP;
  24. },
  25. loadApplication: function(callback){
  26. this.restActions = new MWF.xApplication.ExeManager.Actions.RestActions();
  27. this.createContainer();
  28. this.createTopBar();
  29. //this.createMiddleContent();
  30. },
  31. createContainer : function(){
  32. if( !this.container ){
  33. this.content.setStyle("overflow", "hidden");
  34. this.container = new Element("div", {
  35. "styles": this.css.container
  36. }).inject(this.content);
  37. }
  38. },
  39. createTopBar: function(){
  40. this.currentTopBarTab = "todo";
  41. if( this.topBar ){
  42. this.topBar.empty();
  43. }else{
  44. this.topBar = new Element("div.topBar", {
  45. "styles": this.css.topBar
  46. }).inject(this.container);
  47. }
  48. this.topBarContent = new Element("div", {"styles": this.css.topBarContent}).inject(this.topBar);
  49. this.topBarTitleLi = new Element("li", {"styles": this.css.topBarTitleLi}).inject(this.topBarContent);
  50. this.topBarLog = new Element("img",{"styles": this.css.topBarLog,"src": this.path+"default/icon/okr.png"}).inject(this.topBarTitleLi);
  51. this.topBarTitleSpan = new Element("span",{ "styles": this.css.topBarTitleSpan,"text":this.lp.main.topBartitle}).inject(this.topBarTitleLi);
  52. var topList = this.lp.main.topBarList;
  53. for(var l in topList){
  54. var topBarLi = new Element("li.topBarLi",{"styles": this.css.topBarLi,"id":l}).inject(this.topBarContent);
  55. var _self = this
  56. topBarLi.addEvents({
  57. "mouseover":function(){ //alert(_self.currentTopBarTab)
  58. if(_self.currentTopBarTab!=this.get("id")){
  59. this.setStyles({"background-color":"#124c93"})
  60. }
  61. },
  62. "mouseout":function(){
  63. if(_self.currentTopBarTab!=this.get("id")){
  64. this.setStyles({"background-color":"#5c97e1"})
  65. }
  66. },
  67. "click" : function(){
  68. _self.openContent( this );
  69. }
  70. })
  71. //this.topBarTodoImg = new Element("img",{"styles": this.css.topBarTodoImg,"src": this.path+"default/icon/Outline-104.png"}).inject(this.topBarTodoLi);
  72. var topBarSpan = new Element("span",{"styles": this.css.topBarSpan,"text":topList[l]}).inject(topBarLi);
  73. }
  74. this.topBarContent.getElementById("topTodo").click()
  75. },
  76. openContent: function(obj){
  77. this.currentTopBarTab = obj.get("id");
  78. this.topBarContent.getElements("li").each(function(d){
  79. if(d.className=="topBarLi"){
  80. d.setStyles({"background-color":"#5c97e1"})
  81. }
  82. });
  83. obj.setStyles({"background-color":"#124c93"});
  84. if( !this.middleContent ){
  85. this.middleContent = new Element("div.middleContent",{
  86. "styles": this.css.middleContent
  87. }).inject(this.container)
  88. }
  89. if(this.currentTopBarTab=="topTodo"){
  90. if(this.middleContent){
  91. this.middleContent.empty()
  92. }
  93. MWF.xDesktop.requireApp("ExeManager", "TodoList", function(){
  94. var explorer = new MWF.xApplication.ExeManager.TodoList(this.middleContent, this, this.restActions, {});
  95. explorer.load();
  96. }.bind(this), true);
  97. }else if(this.currentTopBarTab=="topCenterWork"){
  98. if(this.middleContent)this.middleContent.empty();
  99. MWF.xDesktop.requireApp("ExeManager", "CenterWorkList", function(){
  100. var explorer = new MWF.xApplication.ExeManager.CenterWorkList(this.middleContent, this, this.restActions, {});
  101. explorer.load();
  102. }.bind(this) ,true);
  103. }else if(this.currentTopBarTab=="topBaseWork"){
  104. if(this.middleContent)this.middleContent.empty();
  105. MWF.xDesktop.requireApp("ExeManager", "BaseWorkList", function(){
  106. var explorer = new MWF.xApplication.ExeManager.BaseWorkList(this.middleContent, this, this.restActions, {});
  107. explorer.load();
  108. }.bind(this) ,true);
  109. }else if(this.currentTopBarTab=="topWorkReport"){
  110. if(this.middleContent)this.middleContent.empty();
  111. MWF.xDesktop.requireApp("ExeManager", "WorkReportList", function(){
  112. var explorer = new MWF.xApplication.ExeManager.WorkReportList(this.middleContent, this, this.restActions, {});
  113. explorer.load();
  114. }.bind(this) ,true);
  115. }else if(this.currentTopBarTab=="topIndentity"){
  116. if(this.middleContent)this.middleContent.empty();
  117. MWF.xDesktop.requireApp("ExeManager", "IndentityList", function(){
  118. var explorer = new MWF.xApplication.ExeManager.IndentityList(this.middleContent, this, this.restActions, {});
  119. explorer.load();
  120. }.bind(this) ,true);
  121. }
  122. },
  123. createMiddleContent: function(){
  124. if( !this.middleContent ){
  125. this.middleContent = new Element("div.middleContent",{
  126. "styles": this.css.middleContent
  127. }).inject(this.container)
  128. }
  129. },
  130. createShade: function(obj,txt){
  131. var defaultObj = this.content;
  132. var obj = obj || defaultObj;
  133. var txt = txt || "loading...";
  134. if(this.shadeDiv){ this.shadeDiv.destroy()}
  135. if(this.shadeTxtDiv) this.shadeTxtDiv.destroy();
  136. this.shadeDiv = new Element("div.shadeDiv").inject(obj);
  137. this.inforDiv = new Element("div.inforDiv",{
  138. styles:{"height":"16px","display":"inline-block","position":"absolute","background-color":"#000000","border-radius":"3px","padding":"5px 10px"}
  139. }).inject(this.shadeDiv);
  140. this.loadImg = new Element("img.loadImg",{
  141. styles:{"width":"16px","height":"16px","float":"left"},
  142. src:"/x_component_Execution/$Main/default/icon/loading.gif"
  143. }).inject(this.inforDiv);
  144. this.shadeTxtSpan = new Element("span.shadeTxtSpan").inject(this.inforDiv);
  145. this.shadeTxtSpan.set("text",txt);
  146. this.shadeDiv.setStyles({
  147. "width":"100%","height":"100%","position":"absolute","opacity":"0.6","background-color":"#cccccc","z-index":"999"
  148. });
  149. this.shadeTxtSpan.setStyles({"color":"#ffffff","font-size":"12px","display":"inline-block","line-height":"16px","padding-left":"5px"});
  150. var x = obj.getSize().x;
  151. var y = obj.getSize().y;
  152. this.shadeDiv.setStyles({
  153. "left":(obj.getLeft()-defaultObj.getLeft())+"px",
  154. "top":(obj.getTop()-defaultObj.getTop())+"px",
  155. "width":x+"px",
  156. "height":y+"px"
  157. });
  158. if(obj.getStyle("position")=="absolute"){
  159. this.shadeDiv.setStyles({
  160. "left":"0px",
  161. "top":"0px"
  162. })
  163. }
  164. this.inforDiv.setStyles({
  165. "left":(x/2)+"px",
  166. "top":(y/2)+"px"
  167. })
  168. },
  169. destroyShade : function(){
  170. if(this.shadeDiv) this.shadeDiv.destroy();
  171. //if(this.shadeDiv) this.shadeDiv.destroy()
  172. },
  173. setScrollBar: function(node, view, style, offset, callback){
  174. if (!style) style = "attachment";
  175. if (!offset){
  176. offset = {
  177. "V": {"x": 0, "y": 0},
  178. "H": {"x": 0, "y": 0}
  179. };
  180. }
  181. MWF.require("MWF.widget.ScrollBar", function(){
  182. if(this.scrollbar) delete this.scrollbar;
  183. this.scrollbar = new MWF.widget.ScrollBar(node, {
  184. "style": style,
  185. "offset": offset,
  186. "indent": false,
  187. "distance": 50,
  188. "onScroll": function (y) {
  189. var scrollSize = node.getScrollSize();
  190. var clientSize = node.getSize();
  191. var scrollHeight = scrollSize.y - clientSize.y;
  192. //var view = this.baseView || this.centerView;
  193. if (y + 200 > scrollHeight && view && view.loadElementList) {
  194. if (! view.isItemsLoaded) view.loadElementList()
  195. }
  196. }.bind(this)
  197. });
  198. if (callback) callback();
  199. });
  200. return false;
  201. },
  202. showErrorMessage:function(xhr,text,error){
  203. var errorText = error;
  204. if (xhr) errorMessage = xhr.responseText;
  205. if(errorMessage!=""){
  206. var e = JSON.parse(errorMessage);
  207. if(e.message){
  208. this.notice( e.message,"error");
  209. }else{
  210. this.notice( errorText,"error");
  211. }
  212. }else{
  213. this.notice(errorText,"error");
  214. }
  215. }
  216. });