Main.min.js 8.8 KB

1
  1. MWF.xApplication.CRM=MWF.xApplication.CRM||{};MWF.require("MWF.widget.Identity",null,false);MWF.xDesktop.requireApp("CRM","Actions.RestActions",null,false);MWF.xApplication.CRM.options={multitask:false,executable:true};MWF.xApplication.CRM.Main=new Class({Extends:MWF.xApplication.Common.Main,Implements:[Options,Events],options:{style:"default",name:"CRM",icon:"icon.png",width:"1400",height:"700",isResize:true,isMax:false,title:MWF.xApplication.CRM.LP.title},onQueryLoad:function(){this.lp=MWF.xApplication.CRM.LP},onPostLoad:function(){this.resizeWindow()},loadApplication:function(t){this.user=layout.desktop.session.user.name;this.userGender=layout.desktop.session.user.genderType;this.actions=new MWF.xApplication.CRM.Actions.RestActions;if(!this.container){this.content.setStyle("overflow","hidden");this.container=new Element("div.container",{styles:this.css.container}).inject(this.content)}this.createTopContent();this.createMiddleContent();this.resizeWindow();this.addEvent("resize",function(){this.resizeWindow()}.bind(this));MWF.xDesktop.requireApp("CRM","BaiduMap",function(){window.BMap_loadScriptTime=(new Date).getTime();var t="http://api.map.baidu.com/getscript?v=2.0&ak=Qac4WmBvHXiC87z3HjtRrbotCE3sC9Zg&services=&t=20161219171637";if(!window.BDMapApiLoaded){COMMON.AjaxModule.loadDom(t,function(){window.BDMapApiLoaded=true;if(!window.BDMarkerToolLoaded){COMMON.AjaxModule.load("/x_component_CRM/BDMarkerTool.js",function(){window.BDMarkerToolLoaded=true})}else{}})}}.bind(this));if(t)t()},reload:function(){this.createMiddleContent();this.resizeWindow()},createMiddleContent:function(){if(this.middleContentDiv)this.middleContentDiv.destroy();this.middleContentDiv=new Element("div.middleContentDiv",{styles:this.css.middleContentDiv}).inject(this.container);this.createLeftContent();this.createRightContent()},createTopContent:function(){if(this.topContentDiv)this.topContentDiv.destroy();this.topContentDiv=new Element("div.topContentDiv",{styles:this.css.topContentDiv}).inject(this.container);this.logoDiv=new Element("div.logoDiv",{styles:this.css.logoDiv}).inject(this.topContentDiv);this.logoImg=new Element("img.logoImg",{styles:this.css.logoImg,src:this.path+"default/icons/crm.png"}).inject(this.logoDiv);this.logoTitleDiv=new Element("div.logoTitleDiv",{styles:this.css.logoTitleDiv,text:this.lp.main.title}).inject(this.logoDiv);this.topLeftDiv=new Element("div.topLeftDiv",{styles:this.css.topLeftDiv}).inject(this.topContentDiv);var t=new Element("li.topLeftLi",{styles:this.css.topLeftLi}).inject(this.topLeftDiv);var e=new Element("div.topLeftLiDiv",{styles:this.css.topLeftLiDiv,text:this.user}).inject(t);var i=new Element("img.topLeftLiImg",{styles:this.css.topLeftLiImg,src:this.path+"default/icons/arrow.png"}).inject(t)},createLeftContent:function(){this.leftContentDiv=new Element("div.leftContentDiv",{styles:this.css.leftContentDiv}).inject(this.middleContentDiv);this.quickStartDiv=new Element("div.quickStartDiv",{styles:this.css.quickStartDiv}).inject(this.leftContentDiv);this.quickStartImg=new Element("img.quickStartImg",{styles:this.css.quickStartImg,src:this.path+"default/icons/add.png"}).inject(this.quickStartDiv);this.quickStartTextDiv=new Element("div.quickStartTextDiv",{styles:this.css.quickStartTextDiv,text:this.lp.main.quickStart}).inject(this.quickStartDiv);this.quickStartDiv.addEvents({click:function(){}.bind(this)});this.createNavi()},createNavi:function(){var t=this;this.naviDiv=new Element("div.naviDiv",{styles:this.css.naviDiv}).inject(this.leftContentDiv);var e=this.path+"navi.json";MWF.getJSON(e,function(e){e.each(function(e){if(e.type=="menu"){var i=new Element("div.naviMenuLi",{styles:this.css.naviMenuLi}).inject(this.naviDiv);var n=new Element("img.naviMenuImg",{styles:this.css.naviMenuImg,src:this.path+e.icon}).inject(i);var s=new Element("div.naviMenuTxtDiv",{styles:this.css.naviMenuTxtDiv,text:e.title}).inject(i);e.items.each(function(e){var i=new Element("div.naviItemLi",{styles:this.css.naviItemLi,id:e.action,action:e.action}).inject(this.naviDiv);var n=new Element("img.naviItemImg",{styles:this.css.naviItemImg,src:this.path+e.icon,df:e.icon,dfFill:e.iconFill}).inject(i);var s=new Element("div.naviItemTxtDiv",{styles:this.css.naviItemTxtDiv,text:e.title}).inject(i);i.addEvents({mouseover:function(){if(this.get("action")!=t.curModule){this.setStyles({color:"#ff8e31"});var e=this.getElement("img");if(e)e.set("src",t.path+e.get("dfFill"))}},mouseout:function(){if(this.get("action")!=t.curModule){this.setStyles({color:"#ffffff"});var e=this.getElement("img");if(e)e.set("src",t.path+e.get("df"))}},click:function(){if(t.curModule!=this.get("action")){t.curModule=this.get("action");var e=t.naviDiv.getElements(".naviItemLi");e.setStyles({color:"#ffffff"});e.getElement("img").each(function(e){e.set("src",t.path+e.get("df"))});this.setStyles({color:"#ff8e31"});var i=this.getElement("img");if(i)i.set("src",t.path+i.get("dfFill"));t.openModule(this.get("action"))}}})}.bind(this))}}.bind(this))}.bind(this),false);this.naviDiv.getElements(".naviItemLi").each(function(e){if(e.get("action")=="homePage"){t.curModule="homePage";e.setStyles({color:"#ff8e31"});var i=e.getElement("img");if(i)i.set("src",t.path+i.get("dfFill"))}})},openModule:function(t){if(t=="homePage"){this.openHomePage()}else if(t=="message"){this.openMessage()}else if(t=="clue"){this.openClue()}else if(t=="customer"){this.openCustomer()}else if(t=="contact"){this.openContact()}else if(t=="chance"){this.openChance()}else if(t=="stat"){this.openStat()}},openHomePage:function(){this.reload()},openMessage:function(){},openClue:function(){if(this.rightContentDiv)this.rightContentDiv.empty();if(this.clueModule)delete this.clueModule;MWF.xDesktop.requireApp("CRM","Clue",function(){this.clueModule=new MWF.xApplication.CRM.Clue(this.rightContentDiv,this,this.actions);this.clueModule.load()}.bind(this))},openCustomer:function(){if(this.rightContentDiv)this.rightContentDiv.empty();if(this.customerModule)delete this.customerModule;MWF.xDesktop.requireApp("CRM","Customer",function(){this.customerModule=new MWF.xApplication.CRM.Customer(this.rightContentDiv,this,this.actions,{});this.customerModule.load()}.bind(this))},openContact:function(){},openChance:function(){},openStat:function(){},createRightContent:function(){if(this.rightContentDiv)this.rightContentDiv.destroy();this.rightContentDiv=new Element("div.rightContentDiv",{styles:this.css.rightContentDiv}).inject(this.middleContentDiv)},resizeWindow:function(){var t=this.content.getSize();this.middleContentDiv.setStyles({height:t.y-this.topContentDiv.getSize().y+"px"});var e=this.middleContentDiv.getSize();if(this.leftContentDiv)this.leftContentDiv.setStyles({height:e.y+"px"});if(this.rightContentDiv)this.rightContentDiv.setStyles({height:e.y+"px",width:e.x-this.leftContentDiv.getSize().x+"px","margin-left":this.leftContentDiv.getSize().x+"px"})},recordStatus:function(){var t;t={identity:this.identity};return t},createShade:function(t,e){var i=this.content;var t=t||i;var n;n=e||"loading...";if(this.shadeDiv){this.shadeDiv.destroy()}if(this.shadeTxtDiv)this.shadeTxtDiv.destroy();this.shadeDiv=new Element("div.shadeDiv").inject(t);this.inforDiv=new Element("div.inforDiv",{styles:{height:"16px",display:"inline-block",position:"absolute","background-color":"#336699","border-radius":"3px",padding:"5px 10px"}}).inject(this.shadeDiv);this.loadImg=new Element("img.loadImg",{styles:{width:"16px",height:"16px",float:"left"},src:"/x_component_CRM/$Main/default/icons/loading.gif"}).inject(this.inforDiv);this.shadeTxtSpan=new Element("span.shadeTxtSpan").inject(this.inforDiv);this.shadeTxtSpan.set("text",n);this.shadeDiv.setStyles({width:"100%",height:"100%",position:"absolute",opacity:"0.7","background-color":"#cccccc","z-index":"999"});this.shadeTxtSpan.setStyles({color:"#ffffff","font-size":"12px",display:"inline-block","line-height":"16px","padding-left":"5px"});var s=t.getSize().x;var o=t.getSize().y;this.shadeDiv.setStyles({left:t.getLeft()-i.getLeft()+"px",top:t.getTop()-i.getTop()+"px",width:s+"px",height:o+"px"});if(t.getStyle("position")=="absolute"){this.shadeDiv.setStyles({left:"0px",top:"0px"})}this.inforDiv.setStyles({left:s/2+"px",top:o/2+"px"})},destroyShade:function(){if(this.shadeDiv)this.shadeDiv.destroy()},setScrollBar:function(t,e,i,n,s){if(!i)i="default";if(!n){n={V:{x:0,y:0},H:{x:0,y:0}}}MWF.require("MWF.widget.ScrollBar",function(){if(this.scrollbar&&this.scrollbar.scrollVAreaNode){this.scrollbar.scrollVAreaNode.destroy();delete this.scrollbar}this.scrollbar=new MWF.widget.ScrollBar(t,{style:i||"default",offset:n,indent:false,distance:50,onScroll:function(i){var n=t.getScrollSize();var s=t.getSize();var o=n.y-s.y;if(i+20>o&&e&&e.loadElementList){if(!e.isItemsLoaded)e.loadElementList()}}.bind(this)});if(s)s()}.bind(this));return false},showErrorMessage:function(t,e,i){var n=i;if(t)errorMessage=t.responseText;if(errorMessage!=""){var s=JSON.parse(errorMessage);if(s.message){this.notice(s.message,"error")}else{this.notice(n,"error")}}else{this.notice(n,"error")}}});