CustomerRead.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. MWF.xApplication.CRM = MWF.xApplication.CRM || {};
  2. MWF.xDesktop.requireApp("CRM", "Template", null,false);
  3. MWF.require("MWF.widget.Identity", null,false);
  4. MWF.xApplication.CRM.CustomerRead = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "width": 500,
  10. "height": 800,
  11. "top": 0,
  12. "left": 0,
  13. "hasTop": false,
  14. "hasTopIcon" : false,
  15. "hasTopContent" : false,
  16. "hasIcon": true,
  17. "hasScroll" : true,
  18. "hasBottom": true,
  19. "hasMark" : true,
  20. "marked": true,
  21. "title": "",
  22. "draggable": false,
  23. "maxAction" : "false",
  24. "closeAction": true,
  25. "relativeToApp" : true,
  26. "sizeRelateTo" : "app" //desktop
  27. },
  28. initialize: function (node,app,explorer, actions, options) {
  29. this.setOptions(options);
  30. this.app = app;
  31. this.explorer = explorer;
  32. this.lp = app.lp.customer.customerRead;
  33. this.path = "/x_component_CRM/$CustomerRead/";
  34. this.loadCss();
  35. this.actions = actions;
  36. this.node = $(node);
  37. },
  38. loadCss: function () {
  39. this.cssPath = "/x_component_CRM/$CustomerRead/" + this.options.style + "/css.wcss";
  40. this._loadCss();
  41. },
  42. load: function (data) {
  43. this.data = data;
  44. var _self = this;
  45. var injectFor = this.explorer.formContentArr.length?this.node:this.app.content;
  46. if( this.options.hasMark ){
  47. this.formMarkNode = new Element("div.formMarkNode", {
  48. "styles": this.css.formMarkNode,
  49. "id":"formmark"+_self.explorer.formContentArr.length,
  50. "events": {
  51. "mouseover": function (e) {
  52. e.stopPropagation();
  53. },
  54. "mouseout": function (e) {
  55. e.stopPropagation();
  56. },
  57. "click": function () {
  58. this.destroyForm();
  59. }.bind(this)
  60. }
  61. }).inject(injectFor);
  62. }
  63. this.createForm();
  64. this.createTop();
  65. this.createContent();
  66. this.resizeWindow();
  67. this.app.addEvent("resize", function(){
  68. this.resizeWindow();
  69. }.bind(this));
  70. },
  71. destroyForm:function(){
  72. this.explorer.formMarkArr[this.explorer.formMarkArr.length-1].destroy(); //删除 遮罩
  73. var el = this.explorer.formContentArr[this.explorer.formContentArr.length-1].formContent;
  74. var myFx = new Fx.Tween(el);
  75. myFx.start("width",el.getWidth(),0).chain(function(){
  76. el.destroy(); //删除内容
  77. });
  78. this.explorer.formContentArr.splice(this.explorer.formContentArr.length-1,1);//去掉遮罩对象
  79. this.explorer.formMarkArr.splice(this.explorer.formMarkArr.length-1,1);//去掉内容对象
  80. },
  81. createForm:function(){
  82. if(this.formContent){
  83. //this.formContent.destroy();
  84. this.formContent.tween('width', this.options.width);
  85. } else{
  86. this.formContent = new Element("div.formContent",{
  87. "styles": this.css.formContent
  88. }).inject(this.node);
  89. this.formContent.tween('width', this.options.width);
  90. this.formContent.setStyles({"border-left":"1px solid #ffffff"});
  91. }
  92. var zindex = this.explorer.formContentArr.length?parseInt(this.node.getStyle("z-index"))+1:1;
  93. this.formContent.setStyles({"z-index":zindex});
  94. //this.formContent.set("text",this.data.customername);
  95. //this.testdiv = new Element("div.testdiv").inject(this.formContent);
  96. //this.testdiv.setStyles({
  97. // "width":"200px",
  98. // "height":"400px",
  99. // "top":"400px",
  100. // "left":"200px",
  101. // "background-color":"#ff0",
  102. // "position":"absolute"
  103. //
  104. //});
  105. //this.testdiv.addEvents({
  106. // "click":function(){
  107. // this.customerRead = new MWF.xApplication.CRM.CustomerRead(this.formContent,this.app,this.explorer, this.actions,{
  108. // "hasMark" : true,
  109. // "width":this.formContent.getWidth()-100,
  110. // "marked":true
  111. // } );
  112. // this.customerRead.load({customername:"新窗口"});
  113. // this.explorer.formContentArr.push(this.customerRead);
  114. // this.explorer.formMarkArr.push(this.customerRead.formMarkNode);
  115. //
  116. // }.bind(this)
  117. //})
  118. },
  119. createTop:function(){
  120. this.topDiv = new Element("div.topDiv",{"styles":this.css.topDiv}).inject(this.formContent);
  121. this.topCloseDiv = new Element("div.topCloseDiv",{"styles":this.css.topCloseDiv}).inject(this.topDiv);
  122. this.topCloseDiv.addEvents({
  123. "mouseenter":function(){
  124. this.setStyles({
  125. "opacity":"1",
  126. "filter":"alpha(opacity=100)"
  127. })
  128. },
  129. "mouseleave":function(){
  130. this.topCloseDiv.setStyles(this.css.topCloseDiv);
  131. }.bind(this),
  132. "click":function(){
  133. this.destroyForm();
  134. }.bind(this)
  135. });
  136. },
  137. createContent:function(){
  138. if(this.contentDiv) this.contentDiv.destroy();
  139. this.contentDiv = new Element("div.contentDiv",{"styles":this.css.contentDiv}).inject(this.formContent);
  140. this.contentDiv.setStyles({
  141. "height":(this.formContent.getHeight()-this.topDiv.getHeight())+"px"
  142. });
  143. this.slideContentDiv = new Element("div.slideContentDiv",{"styles":this.css.slideContentDiv}).inject(this.contentDiv);
  144. this.app.setScrollBar(this.slideContentDiv);
  145. this.actions.getCustomerInfo(this.data.id,function(json){
  146. this.customerData = json.data;
  147. this.createHeadContent();
  148. this.createNaviContent();
  149. this.createContentInfo();
  150. }.bind(this));
  151. },
  152. createHeadContent:function(){
  153. this.headContentDiv = new Element("div.headContentDiv",{"styles":this.css.headContentDiv}).inject(this.slideContentDiv);
  154. this.customerNameDiv = new Element("div.customerNameDiv",{"styles":this.css.customerNameDiv}).inject(this.headContentDiv);
  155. this.customerNameSpan = new Element("span.customerNameSpan",{
  156. "styles":this.css.customerNameSpan,
  157. "text":this.customerData.customername
  158. }).inject(this.customerNameDiv);
  159. this.customerMapA = new Element("a.customerMapA",{"styles":this.css.customerMapA,"text":this.lp.mapLocation}).inject(this.customerNameDiv);
  160. this.customerMapA.addEvents({
  161. "click":function(){
  162. MWF.xDesktop.requireApp("CRM", "BaiduMap", function(){
  163. this.map = new MWF.xApplication.CRM.BaiduMap(this.app.content,this.app, this.explorer, this.actions );
  164. this.map.loadMax({
  165. "longitude":this.data.addresslongitude,
  166. "latitude":this.data.addresslatitude
  167. });
  168. }.bind(this));
  169. }.bind(this)
  170. });
  171. this.customerStatusDiv = new Element("div.customerStatusDiv",{"styles":this.css.customerStatusDiv}).inject(this.headContentDiv); //float:left
  172. this.customerOperationDiv = new Element("div.customerOperationDiv").inject(this.headContentDiv); //float:right
  173. },
  174. createNaviContent:function(){
  175. },
  176. createContentInfo:function(){
  177. },
  178. resizeWindow:function(){
  179. var size = this.formContent.getSize();
  180. if(this.contentDiv)this.contentDiv.setStyles({"height":(size.y-this.topDiv.getHeight())+"px"});
  181. }
  182. });