Clue.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. MWF.xApplication.CRM = MWF.xApplication.CRM || {};
  2. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  3. MWF.xDesktop.requireApp("CRM", "Template", null,false);
  4. MWF.require("MWF.widget.Identity", null,false);
  5. MWF.xApplication.CRM.Clue = new Class({
  6. Extends: MWF.widget.Common,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default"
  10. },
  11. initialize: function (node, app, actions, options) {
  12. this.setOptions(options);
  13. this.app = app;
  14. this.lp = this.app.lp.clue;
  15. this.path = "/x_component_CRM/$Clue/";
  16. this.loadCss();
  17. this.actions = actions;
  18. this.node = $(node);
  19. },
  20. loadCss: function () {
  21. this.cssPath = "/x_component_CRM/$Clue/" + this.options.style + "/css.wcss";
  22. this._loadCss();
  23. },
  24. load: function () {
  25. if(this.formContentArr)this.formContentArr.empty();
  26. this.formContentArr = [];
  27. if(this.formMarkArr)this.formMarkArr.empty();
  28. this.formMarkArr = [];
  29. this.rightContentDiv = this.app.rightContentDiv;
  30. this.createHeadContent();
  31. this.createToolBarContent();
  32. this.createClueContent();
  33. this.resizeWindow();
  34. this.app.addEvent("resize", function(){
  35. this.resizeWindow();
  36. }.bind(this));
  37. },
  38. reload:function(){
  39. this.createClueContent();
  40. this.resizeWindow();
  41. },
  42. createHeadContent:function(){
  43. if(this.headContentDiv) this.headContentDiv.destroy();
  44. this.headContentDiv = new Element("div.headContentDiv",{"styles":this.css.headContentDiv}).inject(this.rightContentDiv);
  45. this.headTitleDiv = new Element("div.headTitleDiv",{
  46. "styles":this.css.headTitleDiv,
  47. "text":this.lp.head.headTitle
  48. }).inject(this.headContentDiv);
  49. //search
  50. this.headSearchDiv = new Element("div.headSearchDiv",{"styles":this.css.headSearchDiv}).inject(this.headContentDiv);
  51. this.headSearchTextDiv = new Element("div.headSearchTextDiv",{"styles":this.css.headSearchTextDiv}).inject(this.headSearchDiv);
  52. this.headSearchImg = new Element("img.headSearchImg",{
  53. "styles":this.css.headSearchImg,
  54. "src": this.path+"default/icons/search.png"
  55. }).inject(this.headSearchTextDiv);
  56. this.headSearchInput = new Element("input.headSearchInput",{
  57. "styles":this.css.headSearchInput,
  58. "placeholder":this.lp.head.searchText
  59. }).inject(this.headSearchTextDiv);
  60. this.headSearchInput.addEvents({
  61. "keyup":function(){
  62. if(this.headSearchInput.get("value")!=""){
  63. this.headSearchRemoveImg.setStyles({"display":"inline-block"})
  64. }
  65. }.bind(this)
  66. });
  67. this.headSearchRemoveImg = new Element("img.headSearchRemoveImg",{
  68. "styles":this.css.headSearchRemoveImg,
  69. "src": this.path+"default/icons/remove.png"
  70. }).inject(this.headSearchTextDiv);
  71. this.headSearchRemoveImg.addEvents({
  72. "click":function(){
  73. this.headSearchInput.set("value","")
  74. }.bind(this)
  75. });
  76. this.headSearchBottonDiv = new Element("div.headSearchBottonDiv",{
  77. "styles":this.css.headSearchBottonDiv,
  78. "text":this.lp.head.search
  79. }).inject(this.headSearchDiv);
  80. this.headBottonDiv = new Element("div.headBottonDiv",{"styles":this.css.headBottonDiv}).inject(this.headContentDiv);
  81. this.headNewBottonDiv = new Element("div.headNewBottonDiv",{
  82. "styles":this.css.headNewBottonDiv,
  83. "text" :this.lp.head.create
  84. }).inject(this.headBottonDiv);
  85. this.headNewBottonDiv.addEvents({
  86. "click":function(){
  87. MWF.xDesktop.requireApp("CRM", "CustomerEdit", function(){
  88. this.explorer = new MWF.xApplication.CRM.CustomerEdit(this, this.actions,{},{
  89. "isEdited":true,
  90. "isNew":true,
  91. "onReloadView" : function( ){
  92. //alert(JSON.stringify(data))
  93. this.reload();
  94. }.bind(this)
  95. });
  96. this.explorer.load();
  97. }.bind(this))
  98. }.bind(this)
  99. });
  100. this.headMoreBottonDiv = new Element("div.headMoreBottonDiv",{
  101. "styles":this.css.headMoreBottonDiv,
  102. "text" :this.lp.head.moreAction
  103. }).inject(this.headBottonDiv);
  104. this.headMoreImg = new Element("img.headMoreImg",{
  105. "styles": this.css.headMoreImg,
  106. "src" : this.path+"default/icons/arrow.png"
  107. }).inject(this.headMoreBottonDiv);
  108. },
  109. createToolBarContent:function(){
  110. },
  111. createClueContent:function(){
  112. if(this.contentListDiv) this.contentListDiv.destroy();
  113. this.contentListDiv = new Element("div.contentListDiv",{"styles":this.css.contentListDiv}).inject(this.rightContentDiv);
  114. if(this.contentListInDiv) this.contentListInDiv.destroy();
  115. this.contentListInDiv = new Element("div.contentListInDiv",{"styles":this.css.contentListInDiv}).inject(this.contentListDiv);
  116. var size = this.rightContentDiv.getSize();
  117. if(this.contentListDiv)this.contentListDiv.setStyles({"height":(size.y-this.headContentDiv.getHeight()-8)+"px","width":(size.x)+"px"});
  118. if(this.contentListInDiv)this.contentListInDiv.setStyles({"height":this.contentListDiv.getHeight()+"px","width":(this.contentListDiv.getWidth())+"px"});
  119. if(this.clueView) delete this.clueView;
  120. var templateUrl = this.path+"customerView.json";
  121. var filter = {};
  122. ////this.customerView = new MWF.xApplication.CRM.Customer.View(this.contentListInDiv, this.app, {lp : this.app.lp.curtomerView, css : this.css, actions : this.actions }, { templateUrl : templateUrl,filterData:filter} );
  123. this.customerView = new MWF.xApplication.CRM.Clue.View(
  124. this.contentListInDiv,
  125. this.app,
  126. this,
  127. { templateUrl : templateUrl,filterData:filter},
  128. {
  129. lp:this.app.lp.curtomerView
  130. }
  131. );
  132. this.customerView.load();
  133. //this.app.setScrollBar(this.contentListInDiv.getElement(".contentTableNode"),this.customerView,"crm");
  134. },
  135. resizeWindow:function(){
  136. var size = this.rightContentDiv.getSize();
  137. var rSize = this.headTitleDiv.getSize();
  138. var lSize = this.headBottonDiv.getSize();
  139. if(this.headSearchDiv){
  140. var x = this.headSearchDiv.getSize().x;
  141. this.headSearchDiv.setStyles({"margin-left":(size.x-rSize.x-lSize.x)/2-(x/2)+"px"});
  142. }
  143. //alert(JSON.stringify(size))
  144. if(this.contentListDiv)this.contentListDiv.setStyles({"height":(size.y-this.headContentDiv.getHeight()-8)+"px","width":(size.x)+"px"});
  145. if(this.contentListInDiv)this.contentListInDiv.setStyles({"height":this.contentListDiv.getHeight()+"px","width":(this.contentListDiv.getWidth())+"px"});
  146. }
  147. });
  148. MWF.xApplication.CRM.Clue.View = new Class({
  149. Extends: MWF.xApplication.CRM.Template.ComplexView,
  150. _createDocument: function(data){
  151. return new MWF.xApplication.CRM.Clue.Document(this.viewNode, data, this.explorer, this);
  152. },
  153. _getCurrentPageData: function(callback, count){
  154. var category = this.category = this.options.category;
  155. if (!count)count = 20;
  156. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  157. if(id=="(0)")this.app.createShade();
  158. var filter = this.options.filterData || {};
  159. this.actions.getCustomerListNext(id, count, filter, function (json) {
  160. if (callback)callback(json);
  161. this.app.destroyShade();
  162. }.bind(this));
  163. },
  164. _create: function(){
  165. },
  166. _openDocument: function( documentData ){
  167. //if(this.customerRead){
  168. // this.customerRead.load(documentData)
  169. //}else{
  170. MWF.xDesktop.requireApp("CRM", "CustomerRead", function(){
  171. this.customerRead = new MWF.xApplication.CRM.CustomerRead(this.explorer.contentListDiv,this.app, this.explorer,this.actions,{
  172. "width":1000
  173. } );
  174. this.customerRead.load(documentData);
  175. this.explorer.formContentArr.push(this.customerRead);
  176. this.explorer.formMarkArr.push(this.customerRead.formMaskNode);
  177. }.bind(this));
  178. //}
  179. },
  180. _queryCreateViewNode: function(){
  181. },
  182. _postCreateViewNode: function( viewNode ){
  183. },
  184. _queryCreateViewHead:function(){
  185. },
  186. _postCreateViewHead: function( headNode ){
  187. }
  188. });
  189. MWF.xApplication.CRM.Clue.Document = new Class({
  190. Extends: MWF.xApplication.CRM.Template.ComplexDocument,
  191. "viewActionReturn":function(){
  192. return false
  193. }
  194. });