Clue.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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.openDiv) this.openDiv.destroy();
  44. this.openDiv = new Element("div.modal").inject(this.rightContentDiv);
  45. this.openDiv.setStyles({"display":"none"});*/
  46. if(this.headContentDiv) this.headContentDiv.destroy();
  47. this.headContentDiv = new Element("div.headContentDiv",{"styles":this.css.headContentDiv}).inject(this.rightContentDiv);
  48. this.headTitleDiv = new Element("div.headTitleDiv",{
  49. "styles":this.css.headTitleDiv,
  50. "text":this.lp.head.headTitle
  51. }).inject(this.headContentDiv);
  52. //search
  53. this.headSearchDiv = new Element("div.headSearchDiv",{"styles":this.css.headSearchDiv}).inject(this.headContentDiv);
  54. this.headSearchTextDiv = new Element("div.headSearchTextDiv",{"styles":this.css.headSearchTextDiv}).inject(this.headSearchDiv);
  55. this.headSearchImg = new Element("img.headSearchImg",{
  56. "styles":this.css.headSearchImg,
  57. "src": this.path+"default/icons/search.png"
  58. }).inject(this.headSearchTextDiv);
  59. this.headSearchInput = new Element("input.headSearchInput",{
  60. "styles":this.css.headSearchInput,
  61. "placeholder":this.lp.head.searchText
  62. }).inject(this.headSearchTextDiv);
  63. this.headSearchInput.addEvents({
  64. "keyup":function(){
  65. if(this.headSearchInput.get("value")!=""){
  66. this.headSearchRemoveImg.setStyles({"display":"inline-block"})
  67. }
  68. }.bind(this)
  69. });
  70. this.headSearchRemoveImg = new Element("img.headSearchRemoveImg",{
  71. "styles":this.css.headSearchRemoveImg,
  72. "src": this.path+"default/icons/remove.png"
  73. }).inject(this.headSearchTextDiv);
  74. this.headSearchRemoveImg.addEvents({
  75. "click":function(){
  76. this.headSearchInput.set("value","")
  77. }.bind(this)
  78. });
  79. this.headSearchBottonDiv = new Element("div.headSearchBottonDiv",{
  80. "styles":this.css.headSearchBottonDiv,
  81. "text":this.lp.head.search
  82. }).inject(this.headSearchDiv);
  83. this.headBottonDiv = new Element("div.headBottonDiv",{"styles":this.css.headBottonDiv}).inject(this.headContentDiv);
  84. this.headNewBottonDiv = new Element("div.headNewBottonDiv",{
  85. "styles":this.css.headNewBottonDiv,
  86. "text" :this.lp.head.create
  87. }).inject(this.headBottonDiv);
  88. this.headNewBottonDiv.addEvents({
  89. "click":function(){
  90. MWF.xDesktop.requireApp("CRM", "ClueEdit", function(){
  91. this.explorer = new MWF.xApplication.CRM.ClueEdit(this, this.actions,{},{
  92. "isEdited":true,
  93. "isNew":true,
  94. "onReloadView" : function( ){
  95. //alert(JSON.stringify(data))
  96. this.reload();
  97. }.bind(this)
  98. });
  99. this.explorer.load();
  100. }.bind(this))
  101. }.bind(this)
  102. });
  103. this.headMoreBottonDiv = new Element("div.headMoreBottonDiv",{
  104. "styles":this.css.headMoreBottonDiv,
  105. "text" :this.lp.head.moreAction
  106. }).inject(this.headBottonDiv);
  107. this.headMoreImg = new Element("img.headMoreImg",{
  108. "styles": this.css.headMoreImg,
  109. "src" : this.path+"default/icons/arrow.png"
  110. }).inject(this.headMoreBottonDiv);
  111. },
  112. createToolBarContent:function(){
  113. },
  114. createClueContent:function(){
  115. if(this.contentListDiv) this.contentListDiv.destroy();
  116. this.contentListDiv = new Element("div.contentListDiv",{"styles":this.css.contentListDiv}).inject(this.rightContentDiv);
  117. if(this.contentListInDiv) this.contentListInDiv.destroy();
  118. this.contentListInDiv = new Element("div.contentListInDiv",{"styles":this.css.contentListInDiv}).inject(this.contentListDiv);
  119. var size = this.rightContentDiv.getSize();
  120. if(this.contentListDiv)this.contentListDiv.setStyles({"height":(size.y-this.headContentDiv.getHeight()-8)+"px"});
  121. if(this.contentListInDiv)this.contentListInDiv.setStyles({"height":this.contentListDiv.getHeight()+"px","width":"100%"});
  122. if(this.clueView) delete this.clueView;
  123. var templateUrl = this.path+"clueView.json";
  124. var filter = {};
  125. ////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} );
  126. this.clueView = new MWF.xApplication.CRM.Clue.View(
  127. this.contentListInDiv,
  128. this.openDiv,
  129. this.app,
  130. this,
  131. { templateUrl : templateUrl,filterData:filter},
  132. {
  133. lp:this.app.lp.clueView,
  134. isAdmin:this.options.isAdmin
  135. }
  136. );
  137. this.clueView.load();
  138. //this.app.setScrollBar(this.contentListInDiv.getElement(".contentTableNode"),this.customerView,"crm");
  139. },
  140. resizeWindow:function(){
  141. var size = this.rightContentDiv.getSize();
  142. var rSize = this.headTitleDiv.getSize();
  143. var lSize = this.headBottonDiv.getSize();
  144. if(this.headSearchDiv){
  145. var x = this.headSearchDiv.getSize().x;
  146. this.headSearchDiv.setStyles({"margin-left":(size.x-rSize.x-lSize.x)/2-(x/2)+"px"});
  147. }
  148. //alert(JSON.stringify(size))
  149. if(this.contentListDiv)this.contentListDiv.setStyles({"height":(size.y-this.headContentDiv.getHeight()-8)+"px"});
  150. if(this.contentListInDiv)this.contentListInDiv.setStyles({"height":this.contentListDiv.getHeight()+"px"});
  151. }
  152. });
  153. MWF.xApplication.CRM.Clue.View = new Class({
  154. Extends: MWF.xApplication.CRM.Template.ComplexView,
  155. _createDocument: function(data){
  156. return new MWF.xApplication.CRM.Clue.Document(this.viewNode, data, this.explorer, this);
  157. },
  158. _getCurrentPageData: function(callback, count, page, searchText,searchType){
  159. var category = this.category = this.options.category;
  160. if (!count)count = 15;
  161. if (!page)page = 1;
  162. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  163. var filter = this.options.filterData || {};
  164. /*if(searchText && searchText.trim()!=""){
  165. filter = {
  166. key:searchText
  167. };
  168. }*/
  169. filter={key: searchText?searchText.trim():"",
  170. orderFieldName: "updateTime",
  171. orderType: "desc"
  172. };
  173. debugger
  174. if (!searchType)searchType = "全部线索";
  175. if(!this.isAdmin){
  176. debugger
  177. if(searchType=="下属的线索"){
  178. this.actions.ListNestedSubPerson(page, count, filter, function (json) {
  179. if (callback)callback(json);
  180. }.bind(this));
  181. }
  182. if(searchType=="我负责的线索"){
  183. this.actions.ListMyDuty(page, count, filter, function (json) {
  184. if (callback)callback(json);
  185. }.bind(this));
  186. }
  187. if(searchType=="已转化的线索"){
  188. this.actions.ListTransfer(page, count, filter, function (json) {
  189. if (callback)callback(json);
  190. }.bind(this));
  191. }
  192. if(searchType=="全部线索"){
  193. debugger
  194. this.actions.ListAllMy(page, count, filter, function (json) {
  195. debugger
  196. if (callback)callback(json);
  197. }.bind(this));
  198. }
  199. }else{
  200. this.actions.getClueListPage(page, count, filter, function (json) {
  201. if (callback)callback(json);
  202. }.bind(this));
  203. }
  204. },
  205. _create: function(){
  206. },
  207. _openDocument: function(clueId ,clueName){
  208. /*MWF.xDesktop.requireApp("CRM", "ClueEdit", function(){
  209. this.explorer = new MWF.xApplication.CRM.ClueEdit(this, this.actions,{},{
  210. "clueId":clueId,
  211. "onReloadView" : function( ){
  212. //alert(JSON.stringify(data))
  213. this.reload();
  214. }.bind(this)
  215. });
  216. this.explorer.load();
  217. }.bind(this))*/
  218. MWF.xDesktop.requireApp("CRM", "ClueOpen", function(){
  219. this.explorer = new MWF.xApplication.CRM.ClueOpen(this, this.actions,{},{
  220. "clueId":clueId,
  221. "clueName":clueName,
  222. "openType":"single",
  223. "onReloadView" : function( ){
  224. //alert(JSON.stringify(data))
  225. this.reload();
  226. }.bind(this)
  227. });
  228. this.explorer.load();
  229. }.bind(this))
  230. },
  231. _queryCreateViewNode: function(){
  232. },
  233. _postCreateViewNode: function( viewNode ){
  234. },
  235. _queryCreateViewHead:function(){
  236. },
  237. _postCreateViewHead: function( headNode ){
  238. }
  239. });
  240. MWF.xApplication.CRM.Clue.Document = new Class({
  241. /*Extends: MWF.xApplication.CRM.Template.ComplexDocument,
  242. "viewActionReturn":function(){
  243. return false
  244. }*/
  245. });