Message.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  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.xDesktop.requireApp("Template", "Explorer", null,false);
  5. MWF.require("MWF.widget.Identity", null,false);
  6. MWF.xApplication.CRM.Message = new Class({
  7. Extends: MWF.widget.Common,
  8. Implements: [Options, Events],
  9. options: {
  10. "style": "default"
  11. },
  12. initialize: function (node, app, actions, options) {
  13. this.setOptions(options);
  14. this.app = app;
  15. this.lp = app.lp.customer;
  16. this.path = "../x_component_CRM/$Message/";
  17. this.loadCss();
  18. this.actions = actions;
  19. this.node = $(node);
  20. debugger
  21. },
  22. loadCss: function () {
  23. this.cssPath = "../x_component_CRM/$Message/" + this.options.style + "/css.wcss";
  24. this._loadCss();
  25. },
  26. load: function () {
  27. if(this.formContentArr)this.formContentArr.empty();
  28. this.formContentArr = [];
  29. if(this.formMarkArr)this.formMarkArr.empty();
  30. this.formMarkArr = [];
  31. this.rightContentDiv = this.app.rightContentDiv;
  32. this.createHeadContent();
  33. this.createCustomerContent();
  34. this.resizeWindow();
  35. this.app.addEvent("resize", function(){
  36. this.resizeWindow();
  37. }.bind(this));
  38. },
  39. reload:function(){
  40. this.createCustomerContent();
  41. this.resizeWindow();
  42. },
  43. createHeadContent:function(){
  44. debugger
  45. if(this.headContentDiv) this.headContentDiv.destroy();
  46. this.headContentDiv = new Element("div.headContentDiv",{"styles":this.css.headContentDiv}).inject(this.rightContentDiv);
  47. this.headTitleDiv = new Element("div.headTitleDiv",{
  48. "styles":this.css.headTitleDiv,
  49. "text":"待办信息"
  50. }).inject(this.headContentDiv);
  51. },
  52. createToolBarContent:function(){
  53. },
  54. createCustomerContent:function(){
  55. _self = this;
  56. if(this.contentListDiv) this.contentListDiv.destroy();
  57. this.contentListDiv = new Element("div.contentListDiv",{"styles":this.css.contentListDiv}).inject(this.rightContentDiv);
  58. if(this.contentLeftDiv) this.contentLeftDiv.destroy();
  59. this.contentLeftDiv = new Element("div.contentLeftDiv",{"styles":this.css.contentLeftDiv}).inject(this.contentListDiv);
  60. if(this.contentLeftInDiv) this.contentLeftInDiv.destroy();
  61. this.contentLeftInDiv = new Element("div.contentLeftInDiv",{
  62. "styles":this.css.contentLeftInDiv
  63. }).inject(this.contentLeftDiv);
  64. if(this.contentLeftItemDiv) this.contentLeftItemDiv.destroy();
  65. this.contentLeftItemDiv = new Element("div.contentLeftItemDiv",{
  66. "styles":this.css.contentLeftInDiv,
  67. "text":"今日需联系客户"
  68. }).inject(this.contentLeftInDiv);
  69. if(this.contentLeftItemDiv2) this.contentLeftItemDiv2.destroy();
  70. this.contentLeftItemDiv2 = new Element("div.contentLeftItemDiv",{
  71. "styles":this.css.contentLeftInDiv,
  72. "text":"分配给我的线索"
  73. }).inject(this.contentLeftInDiv);
  74. if(this.contentLeftItemDiv3) this.contentLeftItemDiv3.destroy();
  75. this.contentLeftItemDiv3 = new Element("div.contentLeftItemDiv",{
  76. "styles":this.css.contentLeftInDiv,
  77. "text":"分配给我的客户"
  78. }).inject(this.contentLeftInDiv);
  79. if(this.contentLeftItemDiv4) this.contentLeftItemDiv4.destroy();
  80. this.contentLeftItemDiv4 = new Element("div.contentLeftItemDiv",{
  81. "styles":this.css.contentLeftInDiv,
  82. "text":"待进入公海的客户"
  83. }).inject(this.contentLeftInDiv);
  84. if(this.contentListInDiv) this.contentListInDiv.destroy();
  85. this.contentListInDiv = new Element("div.contentListInDiv",{"styles":this.css.contentListInDiv}).inject(this.contentListDiv);
  86. var size = this.rightContentDiv.getSize();
  87. if(this.contentListDiv)this.contentListDiv.setStyles({"height":(size.y-this.headContentDiv.getHeight()-8)+"px"});
  88. if(this.contentListInDiv)this.contentListInDiv.setStyles({"height":this.contentListDiv.getHeight()+"px"});
  89. if(this.contentLeftDiv)this.contentLeftDiv.setStyles({"height":(this.contentListDiv.getHeight()-80)+"px"});
  90. //jQuery(that.contentLeftInDiv).children(":first").attr("class","contentLeftItemSelectd");
  91. jQuery(_self.contentLeftInDiv).find("div").click(function(){
  92. jQuery(this).attr("class","contentLeftItemSelectd");
  93. var category = jQuery(this).text();
  94. jQuery(this).siblings().attr("class","contentLeftItemDiv");
  95. var templateUrl = _self.path+"messageView.json";
  96. var filter = {};
  97. switch (category) {
  98. case "今日需联系客户":
  99. if(_self.customerView) delete _self.customerView;
  100. jQuery(".contentListInDiv").empty();
  101. _self.customerView = new MWF.xApplication.CRM.Message.CustomerView(
  102. _self.contentListInDiv,
  103. _self.openDiv,
  104. _self.app,
  105. _self,
  106. { templateUrl : templateUrl,filterData:filter},
  107. {
  108. lp:_self.app.lp.customerView,
  109. isAdmin:_self.options.isAdmin
  110. }
  111. );
  112. _self.customerView.load();
  113. break;
  114. case "分配给我的线索":
  115. if(_self.clueView) delete _self.clueView;
  116. _self.clueView = new MWF.xApplication.CRM.Index.ClueView(
  117. _self.contentListInDiv,
  118. _self.openDiv,
  119. _self.app,
  120. _self,
  121. { templateUrl : templateUrl,filterData:filter},
  122. {
  123. lp:_self.app.lp.clueView,
  124. isAdmin:_self.options.isAdmin
  125. }
  126. );
  127. _self.clueView.load();
  128. break;
  129. case "分配给我的客户":
  130. if(_self.allotCustomerView) delete _self.allotCustomerView;
  131. jQuery(".contentListInDiv").empty();
  132. _self.allotCustomerView = new MWF.xApplication.CRM.Message.AllotCustomerView(
  133. _self.contentListInDiv,
  134. _self.openDiv,
  135. _self.app,
  136. _self,
  137. { templateUrl : templateUrl,filterData:filter},
  138. {
  139. lp:_self.app.lp.customerView,
  140. isAdmin:_self.options.isAdmin
  141. }
  142. );
  143. _self.allotCustomerView.load();
  144. break;
  145. case "待进入公海的客户":
  146. if(_self.seaCustomerView) delete _self.seaCustomerView;
  147. jQuery(".contentListInDiv").empty();
  148. _self.seaCustomerView = new MWF.xApplication.CRM.Message.SeaCustomerView(
  149. _self.contentListInDiv,
  150. _self.openDiv,
  151. _self.app,
  152. _self,
  153. { templateUrl : templateUrl,filterData:filter},
  154. {
  155. lp:_self.app.lp.customerView,
  156. isAdmin:_self.options.isAdmin
  157. }
  158. );
  159. _self.seaCustomerView.load();
  160. break;
  161. }
  162. });
  163. jQuery(_self.contentLeftInDiv).children(":first").click();
  164. },
  165. resizeWindow:function(){
  166. var size = this.rightContentDiv.getSize();
  167. if(this.contentListDiv)this.contentListDiv.setStyles({"height":(size.y-this.headContentDiv.getHeight()-8)+"px"});
  168. if(this.contentListInDiv)this.contentListInDiv.setStyles({"height":(this.contentListDiv.getHeight())+"px"});
  169. if(this.contentLeftDiv)this.contentLeftDiv.setStyles({"height":(this.contentListDiv.getHeight()-80)+"px"});
  170. }
  171. });
  172. MWF.xApplication.CRM.Message.CustomerView = new Class({
  173. Extends: MWF.xApplication.CRM.Template.ComplexView,
  174. _createDocument: function(data){
  175. return new MWF.xApplication.CRM.Clue.Document(this.viewNode, data, this.explorer, this);
  176. },
  177. _getCurrentPageData: function(callback, count, page, searchText,searchType){
  178. if (!count)count = 15;
  179. if (!page)page = 1;
  180. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  181. var dt = this.formatDate(new Date());
  182. var filter = this.options.filterData || {};
  183. filter = {
  184. begintime:dt+" 00:00:00",
  185. endtime:dt+" 23:59:59"
  186. };
  187. debugger
  188. this.actions.listNextTimePaginLike(page, count, filter, function (json) {
  189. if (callback)callback(json);
  190. }.bind(this));
  191. },
  192. _create: function(){
  193. },
  194. _openDocument: function(openId ,openName){
  195. MWF.xDesktop.requireApp("CRM", "CustomerOpen", function(){
  196. this.explorer = new MWF.xApplication.CRM.CustomerOpen(this, this.actions,{},{
  197. "openId":openId,
  198. "openName":openName,
  199. "openType":"single",
  200. "onReloadView" : function( ){
  201. //alert(JSON.stringify(data))
  202. this.reload();
  203. }.bind(this)
  204. });
  205. this.explorer.load();
  206. }.bind(this))
  207. },
  208. _queryCreateViewNode: function(){
  209. },
  210. _postCreateViewNode: function( viewNode ){
  211. },
  212. _queryCreateViewHead:function(){
  213. },
  214. _postCreateViewHead: function( headNode ){
  215. }
  216. });
  217. MWF.xApplication.CRM.Index.ClueView = new Class({
  218. Extends: MWF.xApplication.CRM.Template.ComplexView,
  219. _createDocument: function(data){
  220. return new MWF.xApplication.CRM.Clue.Document(this.viewNode, data, this.explorer, this);
  221. },
  222. _getCurrentPageData: function(callback, count, page, searchText){
  223. var category = this.category = this.options.category;
  224. if (!count)count = 15;
  225. if (!page)page = 1;
  226. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  227. //if(id=="(0)")this.app.createShade();
  228. var filter = this.options.filterData || {};
  229. if(searchText){
  230. filter = {
  231. key:searchText
  232. };
  233. }
  234. this.actions.getClueListPage(page, count, filter, function (json) {
  235. debugger
  236. if (callback)callback(json);
  237. }.bind(this));
  238. },
  239. _create: function(){
  240. },
  241. _openDocument: function(openId ,openName){
  242. /*MWF.xDesktop.requireApp("CRM", "ClueEdit", function(){
  243. this.explorer = new MWF.xApplication.CRM.ClueEdit(this, this.actions,{},{
  244. "clueId":clueId,
  245. "onReloadView" : function( ){
  246. //alert(JSON.stringify(data))
  247. this.reload();
  248. }.bind(this)
  249. });
  250. this.explorer.load();
  251. }.bind(this))*/
  252. MWF.xDesktop.requireApp("CRM", "ContactsOpen", function(){
  253. this.explorer = new MWF.xApplication.CRM.ContactsOpen(this, this.actions,{},{
  254. "openId":openId,
  255. "openName":openName,
  256. "onReloadView" : function( ){
  257. //alert(JSON.stringify(data))
  258. this.reload();
  259. }.bind(this)
  260. });
  261. this.explorer.load();
  262. }.bind(this))
  263. },
  264. _openOtherDocument: function(openId ,openName){
  265. MWF.xDesktop.requireApp("CRM", "CustomerOpen", function(){
  266. this.explorer = new MWF.xApplication.CRM.CustomerOpen(this, this.actions,{},{
  267. "openId":openId,
  268. "openName":openName,
  269. "onReloadView" : function( ){
  270. //alert(JSON.stringify(data))
  271. this.reload();
  272. }.bind(this)
  273. });
  274. this.explorer.load();
  275. }.bind(this))
  276. },
  277. _queryCreateViewNode: function(){
  278. },
  279. _postCreateViewNode: function( viewNode ){
  280. },
  281. _queryCreateViewHead:function(){
  282. },
  283. _postCreateViewHead: function( headNode ){
  284. }
  285. });
  286. MWF.xApplication.CRM.Message.AllotCustomerView = new Class({
  287. Extends: MWF.xApplication.CRM.Template.ComplexView,
  288. _createDocument: function(data){
  289. return new MWF.xApplication.CRM.Clue.Document(this.viewNode, data, this.explorer, this);
  290. },
  291. _getCurrentPageData: function(callback, count, page, searchText,searchType){
  292. if (!count)count = 15;
  293. if (!page)page = 1;
  294. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  295. //if(id=="(0)")this.app.createShade();
  296. var filter = this.options.filterData || {};
  297. filter={key: searchText?searchText.trim():"",
  298. orderFieldName: "updateTime",
  299. orderType: "desc"
  300. };
  301. this.actions.getCustomerListPage(page, count, filter, function (json) {
  302. if (callback)callback(json);
  303. }.bind(this));
  304. },
  305. _create: function(){
  306. },
  307. _openDocument: function(openId ,openName){
  308. MWF.xDesktop.requireApp("CRM", "CustomerOpen", function(){
  309. this.explorer = new MWF.xApplication.CRM.CustomerOpen(this, this.actions,{},{
  310. "openId":openId,
  311. "openName":openName,
  312. "openType":"single",
  313. "onReloadView" : function( ){
  314. //alert(JSON.stringify(data))
  315. this.reload();
  316. }.bind(this)
  317. });
  318. this.explorer.load();
  319. }.bind(this))
  320. },
  321. _queryCreateViewNode: function(){
  322. },
  323. _postCreateViewNode: function( viewNode ){
  324. },
  325. _queryCreateViewHead:function(){
  326. },
  327. _postCreateViewHead: function( headNode ){
  328. }
  329. });
  330. MWF.xApplication.CRM.Message.SeaCustomerView = new Class({
  331. Extends: MWF.xApplication.CRM.Template.ComplexView,
  332. _createDocument: function(data){
  333. return new MWF.xApplication.CRM.Clue.Document(this.viewNode, data, this.explorer, this);
  334. },
  335. _getCurrentPageData: function(callback, count, page, searchText,searchType){
  336. if (!count)count = 15;
  337. if (!page)page = 1;
  338. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  339. //if(id=="(0)")this.app.createShade();
  340. var filter = this.options.filterData || {};
  341. filter={key: searchText?searchText.trim():"",
  342. orderFieldName: "updateTime",
  343. orderType: "desc"
  344. };
  345. this.actions.getCustomerListPage(page, count, filter, function (json) {
  346. if (callback)callback(json);
  347. }.bind(this));
  348. },
  349. _create: function(){
  350. },
  351. _openDocument: function(openId ,openName){
  352. MWF.xDesktop.requireApp("CRM", "CustomerOpen", function(){
  353. this.explorer = new MWF.xApplication.CRM.CustomerOpen(this, this.actions,{},{
  354. "openId":openId,
  355. "openName":openName,
  356. "openType":"single",
  357. "onReloadView" : function( ){
  358. //alert(JSON.stringify(data))
  359. this.reload();
  360. }.bind(this)
  361. });
  362. this.explorer.load();
  363. }.bind(this))
  364. },
  365. _queryCreateViewNode: function(){
  366. },
  367. _postCreateViewNode: function( viewNode ){
  368. },
  369. _queryCreateViewHead:function(){
  370. },
  371. _postCreateViewHead: function( headNode ){
  372. }
  373. });
  374. MWF.xApplication.CRM.Customer.Document = new Class({
  375. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  376. _queryCreateDocumentNode:function( itemData ){
  377. },
  378. _postCreateDocumentNode: function( itemNode, itemData ){
  379. this.view.template.items.each(function (item,i) {
  380. if(item.head.width){
  381. itemNode.getElements("td")[i].set("width",item.head.width);
  382. }
  383. if(i == itemNode.getElements("td").length-1){
  384. itemNode.getElements("td")[i].set("width",this.view.lastTdWidth);
  385. }
  386. }.bind(this));
  387. },
  388. open: function (e) {
  389. this.view._openDocument(this.data, this.index);
  390. },
  391. edit : function(){
  392. var appId = "ForumDocument"+this.data.id;
  393. if (this.app.desktop.apps[appId]){
  394. this.app.desktop.apps[appId].setCurrent();
  395. }else {
  396. this.app.desktop.openApplication(null, "ForumDocument", {
  397. "sectionId" : this.data.sectionId,
  398. "id" : this.data.id,
  399. "appId": appId,
  400. "isEdited" : true,
  401. "isNew" : false,
  402. "index" : this.index
  403. });
  404. }
  405. }
  406. })