Main.js 7.9 KB

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