Customer.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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.Customer = 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 = app.lp.customer;
  15. this.path = "/x_component_CRM/$Customer/";
  16. this.loadCss();
  17. this.actions = actions;
  18. this.node = $(node);
  19. },
  20. loadCss: function () {
  21. this.cssPath = "/x_component_CRM/$Customer/" + this.options.style + "/css.wcss";
  22. this._loadCss();
  23. },
  24. load: function () {
  25. if(this.formContentArr)this.formContentArr.empty();
  26. this.formContentArr = new Array();
  27. if(this.formMarkArr)this.formMarkArr.empty();
  28. this.formMarkArr = new Array();
  29. this.rightContentDiv = this.app.rightContentDiv;
  30. this.createHeadContent();
  31. this.createToolBarContent();
  32. this.createCustomerContent();
  33. this.resizeWindow();
  34. this.app.addEvent("resize", function(){
  35. this.resizeWindow();
  36. }.bind(this));
  37. //if(this.customerView.customerRead) delete this.customerView.customerRead;
  38. //if(this.app.customerModule.hasMark) delete this.app.customerModule.hasMark;
  39. //if(this.formContentArr.length) this.formContentArr.empty();
  40. //this.customerView.formMarkNode.addEvents({
  41. // "click": function (e) {
  42. // alert(this.app.formContentArr.length)
  43. // if(this.app.formContentArr.length){
  44. // this.app.formContentArr[this.app.formContentArr.length-1].formContent.destroy();
  45. //
  46. // this.app.formContentArr.splice(this.app.formContentArr.length-1,1);
  47. // }
  48. //
  49. // if(this.app.formContentArr.length==1){
  50. // this.app.customerModule.hasMark = false;
  51. // this.app.content.getElements(".formMarkNode").destroy();
  52. //
  53. // }
  54. // if(this.app.formContentArr.length==0){
  55. // delete this.customerView.customerRead;
  56. // }
  57. // e.stopPropagation();
  58. // //alert(this.app.formContentArr.length);
  59. // //delete this.app.customerModule.currentFormContent;
  60. // //
  61. // //var obj = $(e.target);
  62. // //var targetObj;
  63. // //while(obj){
  64. // // if(obj.get("class")=="formContent"){
  65. // // targetObj = obj;
  66. // // break;
  67. // // }else{
  68. // // obj = obj.getParent();
  69. // // }
  70. // //}
  71. // //
  72. // //if(!targetObj){
  73. // // if(this.app.content.getElements(".formContent")){
  74. // // this.app.content.getElements(".formContent").tween("width","0px");
  75. // // }
  76. // // //alert(this.app.content.getElements(".formMarkNode").length)
  77. // // if(this.app.content.getElements(".formMarkNode")){ //alert("destroy mark")
  78. // // this.app.content.getElements(".formMarkNode").destroy();
  79. // // this.app.customerModule.hasMark = false;
  80. // // }
  81. // //}else{
  82. // // //alert("in")
  83. // //}
  84. // }.bind(this)
  85. //});
  86. },
  87. reload:function(){
  88. this.createCustomerContent();
  89. this.resizeWindow();
  90. },
  91. createHeadContent:function(){
  92. if(this.headContentDiv) this.headContentDiv.destroy();
  93. this.headContentDiv = new Element("div.headContentDiv",{"styles":this.css.headContentDiv}).inject(this.rightContentDiv);
  94. this.headTitleDiv = new Element("div.headTitleDiv",{
  95. "styles":this.css.headTitleDiv,
  96. "text":this.lp.head.headTitle
  97. }).inject(this.headContentDiv);
  98. //search
  99. this.headSearchDiv = new Element("div.headSearchDiv",{"styles":this.css.headSearchDiv}).inject(this.headContentDiv);
  100. this.headSearchTextDiv = new Element("div.headSearchTextDiv",{"styles":this.css.headSearchTextDiv}).inject(this.headSearchDiv);
  101. this.headSearchImg = new Element("img.headSearchImg",{
  102. "styles":this.css.headSearchImg,
  103. "src": this.path+"default/icons/search.png"
  104. }).inject(this.headSearchTextDiv);
  105. this.headSearchInput = new Element("input.headSearchInput",{
  106. "styles":this.css.headSearchInput,
  107. "placeholder":this.lp.head.searchText
  108. }).inject(this.headSearchTextDiv);
  109. this.headSearchInput.addEvents({
  110. "keyup":function(){
  111. if(this.headSearchInput.get("value")!=""){
  112. this.headSearchRemoveImg.setStyles({"display":"inline-block"})
  113. }
  114. }.bind(this)
  115. });
  116. this.headSearchRemoveImg = new Element("img.headSearchRemoveImg",{
  117. "styles":this.css.headSearchRemoveImg,
  118. "src": this.path+"default/icons/remove.png"
  119. }).inject(this.headSearchTextDiv);
  120. this.headSearchRemoveImg.addEvents({
  121. "click":function(){
  122. this.headSearchInput.set("value","")
  123. }.bind(this)
  124. });
  125. this.headSearchBottonDiv = new Element("div.headSearchBottonDiv",{
  126. "styles":this.css.headSearchBottonDiv,
  127. "text":this.lp.head.search
  128. }).inject(this.headSearchDiv);
  129. this.headBottonDiv = new Element("div.headBottonDiv",{"styles":this.css.headBottonDiv}).inject(this.headContentDiv);
  130. this.headNewBottonDiv = new Element("div.headNewBottonDiv",{
  131. "styles":this.css.headNewBottonDiv,
  132. "text" :this.lp.head.create
  133. }).inject(this.headBottonDiv);
  134. this.headNewBottonDiv.addEvents({
  135. "click":function(){
  136. this.explorer = new MWF.xApplication.CRM.Customer.CustomerForm(this, this.actions,{},{
  137. "isEdited":true,
  138. "isNew":true,
  139. "onReloadView" : function( ){
  140. //alert(JSON.stringify(data))
  141. this.reload();
  142. }.bind(this)
  143. });
  144. this.explorer.load();
  145. }.bind(this)
  146. });
  147. this.headMoreBottonDiv = new Element("div.headMoreBottonDiv",{
  148. "styles":this.css.headMoreBottonDiv,
  149. "text" :this.lp.head.moreAction
  150. }).inject(this.headBottonDiv);
  151. this.headMoreImg = new Element("img.headMoreImg",{
  152. "styles": this.css.headMoreImg,
  153. "src" : this.path+"default/icons/arrow.png"
  154. }).inject(this.headMoreBottonDiv);
  155. },
  156. createToolBarContent:function(){
  157. },
  158. createCustomerContent:function(){
  159. if(this.contentListDiv) this.contentListDiv.destroy();
  160. this.contentListDiv = new Element("div.contentListDiv",{"styles":this.css.contentListDiv}).inject(this.rightContentDiv);
  161. if(this.contentListInDiv) this.contentListInDiv.destroy();
  162. this.contentListInDiv = new Element("div.contentListInDiv",{"styles":this.css.contentListInDiv}).inject(this.contentListDiv);
  163. if(this.customerView) delete this.customerView;
  164. var templateUrl = this.path+"customerView.json";
  165. var filter = {};
  166. //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} );
  167. this.customerView = new MWF.xApplication.CRM.Customer.View(
  168. this.contentListInDiv,
  169. this.app,
  170. this,
  171. { templateUrl : templateUrl,filterData:filter},
  172. {
  173. lp:this.app.lp.curtomerView
  174. }
  175. );
  176. this.customerView.load();
  177. this.app.setScrollBar(this.contentListInDiv,this.customerView,"crm");
  178. },
  179. resizeWindow:function(){
  180. var size = this.rightContentDiv.getSize();
  181. var rSize = this.headTitleDiv.getSize();
  182. var lSize = this.headBottonDiv.getSize();
  183. if(this.headSearchDiv){
  184. var x = this.headSearchDiv.getSize().x;
  185. this.headSearchDiv.setStyles({"margin-left":(size.x-rSize.x-lSize.x)/2-(x/2)+"px"});
  186. }
  187. //alert(JSON.stringify(size))
  188. if(this.contentListDiv)this.contentListDiv.setStyles({"height":(size.y-this.headContentDiv.getHeight()-8)+"px","width":(size.x)+"px"});
  189. if(this.contentListInDiv)this.contentListInDiv.setStyles({"height":this.contentListDiv.getHeight()+"px","width":(this.contentListDiv.getWidth()-8)+"px"});
  190. }
  191. });
  192. MWF.xApplication.CRM.Customer.View = new Class({
  193. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  194. _createDocument: function(data){
  195. return new MWF.xApplication.CRM.Customer.Document(this.viewNode, data, this.explorer, this);
  196. },
  197. _getCurrentPageData: function(callback, count){
  198. var category = this.category = this.options.category;
  199. if (!count)count = 20;
  200. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  201. if(id=="(0)")this.app.createShade();
  202. var filter = this.options.filterData || {};
  203. this.actions.getCustomerListNext(id, count, filter, function (json) {
  204. if (callback)callback(json);
  205. this.app.destroyShade();
  206. }.bind(this));
  207. },
  208. _create: function(){
  209. },
  210. _openDocument: function( documentData ){
  211. //if(this.customerRead){
  212. // this.customerRead.load(documentData)
  213. //}else{
  214. MWF.xDesktop.requireApp("CRM", "CustomerRead", function(){
  215. this.customerRead = new MWF.xApplication.CRM.CustomerRead(this.explorer.contentListDiv,this.app, this.explorer,this.actions,{
  216. "width":1000
  217. } );
  218. this.customerRead.load(documentData);
  219. this.explorer.formContentArr.push(this.customerRead);
  220. this.explorer.formMarkArr.push(this.customerRead.formMarkNode);
  221. }.bind(this));
  222. //}
  223. },
  224. _queryCreateViewNode: function(){
  225. },
  226. _postCreateViewNode: function( viewNode ){
  227. },
  228. _queryCreateViewHead:function(){
  229. },
  230. _postCreateViewHead: function( headNode ){
  231. }
  232. });
  233. MWF.xApplication.CRM.Customer.Document = new Class({
  234. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  235. "viewActionReturn":function(){
  236. return false
  237. }
  238. });
  239. MWF.xApplication.CRM.Customer.CustomerForm = new Class({
  240. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  241. Implements: [Options, Events],
  242. options: {
  243. "style": "default",
  244. "width": "800",
  245. "height": "100%",
  246. "top" : 0,
  247. "left" : 0,
  248. "hasTop": true,
  249. "hasIcon": false,
  250. "hasBottom": true,
  251. "title": "",
  252. "draggable": false,
  253. "closeAction": true
  254. },
  255. createFormNode: function () { //为了修改滚动条样式 "default"
  256. var _self = this;
  257. this.formNode = new Element("div.formNode", {
  258. "styles": this.css.formNode
  259. }).inject(this.formAreaNode);
  260. if (this.options.hasTop) {
  261. this.createTopNode();
  262. }
  263. if (this.options.hasIcon) {
  264. this.formIconNode = new Element("div.formIconNode", {
  265. "styles": this.isNew ? this.css.formNewNode : this.css.formIconNode
  266. }).inject(this.formNode);
  267. }
  268. this.createContent();
  269. //formContentNode.set("html", html);
  270. if (this.options.hasBottom) {
  271. this.createBottomNode();
  272. }
  273. this._setCustom();
  274. if( this.options.hasScroll ){
  275. //this.setScrollBar(this.formTableContainer)
  276. MWF.require("MWF.widget.ScrollBar", function () {
  277. new MWF.widget.ScrollBar(this.formTableContainer, {
  278. "indent": false,
  279. "style": "default",
  280. "where": "before",
  281. "distance": 30,
  282. "friction": 4,
  283. "axis": {"x": false, "y": true},
  284. "onScroll": function (y) {
  285. //var scrollSize = _self.viewContainerNode.getScrollSize();
  286. //var clientSize = _self.viewContainerNode.getSize();
  287. //var scrollHeight = scrollSize.y - clientSize.y;
  288. //if (y + 200 > scrollHeight && _self.view && _self.view.loadElementList) {
  289. // if (!_self.view.isItemsLoaded) _self.view.loadElementList();
  290. //}
  291. }
  292. });
  293. }.bind(this));
  294. }
  295. },
  296. initialize: function (explorer, actions, data, options) {
  297. this.setOptions(options);
  298. this.explorer = explorer;
  299. this.app = explorer.app;
  300. this.lp = this.app.lp.customer.customerForm;
  301. this.path = "/x_component_CRM/$Customer/";
  302. this.cssPath = this.path + this.options.style + "/customerForm.wcss";
  303. this._loadCss();
  304. this.options.title = this.lp.title;
  305. this.data = data || {};
  306. this.actions = actions;
  307. },
  308. load: function () {
  309. var Ttype = "customer";
  310. this.actions.getProfiles(Ttype,function(json){
  311. this.profileData = json.data;
  312. this.profileData.customerType = {
  313. "name":"客户类型",
  314. "childNodes":[
  315. {
  316. "configname":"客户"
  317. },
  318. {
  319. "configname":"合作伙伴"
  320. }
  321. ]
  322. };
  323. this.allArrowArr = [];
  324. if (this.options.isNew) {
  325. this.create();
  326. } else if (this.options.isEdited) {
  327. this.edit();
  328. } else {
  329. this.open();
  330. }
  331. this.formContentNode.addEvents({
  332. "click": function () {
  333. if(this.listContentDiv){
  334. this.listContentDiv.destroy();
  335. }
  336. if(this.allArrowArr.length>0){
  337. this.allArrowArr.each(function(d){
  338. d.setStyles({
  339. "background":"url(/x_component_CRM/$Template/default/icons/arrow.png) no-repeat center"
  340. });
  341. }.bind(this))
  342. }
  343. }.bind(this)
  344. });
  345. }.bind(this));
  346. },
  347. getProfiles:function(){
  348. },
  349. createTopNode: function () {
  350. if (!this.formTopNode) {
  351. this.formTopNode = new Element("div.formTopNode", {
  352. "styles": this.css.formTopNode
  353. }).inject(this.formNode);
  354. this.formTopIconNode = new Element("div", {
  355. "styles": this.css.formTopIconNode
  356. }).inject(this.formTopNode);
  357. this.formTopTextNode = new Element("div", {
  358. "styles": this.css.formTopTextNode,
  359. "text": this.options.title + ( this.data.title ? ("-" + this.data.title ) : "" )
  360. }).inject(this.formTopNode);
  361. if (this.options.closeAction) {
  362. this.formTopCloseActionNode = new Element("div", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  363. this.formTopCloseActionNode.addEvent("click", function () {
  364. this.close();
  365. }.bind(this))
  366. }
  367. this.formTopContentNode = new Element("div", {
  368. "styles": this.css.formTopContentNode
  369. }).inject(this.formTopNode);
  370. this._createTopContent();
  371. }
  372. },
  373. _createTopContent: function () {
  374. },
  375. _createTableContent: function () {
  376. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  377. "<tr>" +
  378. " <td styles='formTableTitle'><span lable='TCustomerName'></span><span style='color:#f00'>*</span></td>" +
  379. " <td styles='formTableValue' item='TCustomerName'></td>" +
  380. "</tr><tr>" +
  381. " <td styles='formTableTitle' lable='TCustomerType'></td>" +
  382. " <td styles='formTableValue'><div id='TCustomerType'></div></td>" +
  383. "</tr><tr>" +
  384. " <td styles='formTableTitle' lable='TCustomerLevel'></td>" +
  385. " <td styles='formTableValue'><div id='TCustomerLevel'></div></td>" +
  386. "</tr><tr>" +
  387. " <td styles='formTableTitle' lable='TSource'></td>" +
  388. " <td styles='formTableValue'><div id='TSource'></div></td>" +
  389. "</tr><tr>" +
  390. " <td styles='formTableTitle' lable='TIndustryFirst'></td>" +
  391. " <td styles='formTableValue'><div id='TIndustryFirst'></div><div id='TIndustrySecond'></div></td>" +
  392. "</tr><tr>" +
  393. " <td styles='formTableTitle' lable='TDistrict'></td>" +
  394. " <td styles='formTableValue'><div id='TProvince'></div><div id='TCity'></div><div id='TArea'></div></td>" +
  395. "</tr><tr>" +
  396. " <td styles='formTableTitle' lable='TStreet'></td>" +
  397. " <td styles='formTableValue' item='TStreet'></td>" +
  398. "</tr><tr>" +
  399. " <td styles='formTableTitle' lable='TLocation'></td>" +
  400. " <td styles='formTableValue'><div style='width:100%;height:30px;'><input type='text' placeholder='"+this.lp.TLocationNotice+"' id='mapLocation' disabled/></div></td>" +
  401. "</tr><tr>" +
  402. " <td styles='formTableTitle'></td>" +
  403. " <td styles='formTableValue'><div id='mapDiv' styles='mapDiv'></div></td>" +
  404. "</tr><tr>" +
  405. " <td styles='formTableTitle' lable='TTelphone'></td>" +
  406. " <td styles='formTableValue' item='TTelphone'></td>" +
  407. "</tr><tr>" +
  408. " <td styles='formTableTitle' lable='TFax'></td>" +
  409. " <td styles='formTableValue' item='TFax'></td>" +
  410. "</tr><tr>" +
  411. " <td styles='formTableTitle' lable='TRemark'></td>" +
  412. " <td styles='formTableValue' item='TRemark'></td>" +
  413. "</tr><tr>" +
  414. " <td styles='formTableTitle' lable='TWebSite'></td>" +
  415. " <td styles='formTableValue' item='TWebSite'></td>" +
  416. "</tr><tr>" +
  417. " <td styles='formTableTitle' lable='TEmail'></td>" +
  418. " <td styles='formTableValue' item='TEmail'></td>" +
  419. "</tr><tr>" +
  420. " <td styles='formTableTitle' lable='TCustomerStatus'></td>" +
  421. " <td styles='formTableValue'><div id='TCustomerStatus'></div></td>" +
  422. "</tr><tr>" +
  423. " <td styles='formTableTitle' lable='TCustomerGrade'></td>" +
  424. " <td styles='formTableValue'><div id='TCustomerGrade'></div></td>" +
  425. "</tr>" +
  426. "</table>"
  427. this.formTableArea.set("html", html);
  428. this.loadForm();
  429. this.TCustomerType = this.formTableArea.getElement("#TCustomerType");
  430. this.TCustomerLevel = this.formTableArea.getElement("#TCustomerLevel");
  431. this.TSource = this.formTableArea.getElement("#TSource");
  432. this.TIndustryFirst = this.formTableArea.getElement("#TIndustryFirst");
  433. this.TIndustrySecond = this.formTableArea.getElement("#TIndustrySecond");
  434. this.TProvince = this.formTableArea.getElement("#TProvince");
  435. this.TCity = this.formTableArea.getElement("#TCity");
  436. this.TArea = this.formTableArea.getElement("#TArea");
  437. this.TCustomerStatus = this.formTableArea.getElement("#TCustomerStatus");
  438. this.TCustomerGrade = this.formTableArea.getElement("#TCustomerGrade");
  439. var size = {"width":230,"height":30};
  440. this.TIndustryFirst.setStyles({"float":"left"});
  441. this.TIndustrySecond.setStyles({"float":"left","margin-left":"10px"});
  442. this.TCustomerTypeSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerType,this, this.actions, size);
  443. this.TCustomerTypeSelector.load(this.profileData.customerType);
  444. this.TCustomerLevelSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerLevel,this, this.actions, size);
  445. this.TCustomerLevelSelector.load(this.profileData.customerType);
  446. this.TSourceSelector = new MWF.xApplication.CRM.Template.Select(this.TSource,this, this.actions, size);
  447. this.TSourceSelector.load(this.profileData.customerType);
  448. this.TIndustryFirstSelector = new MWF.xApplication.CRM.Template.Select(this.TIndustryFirst,this, this.actions, {"width":150,"height":30});
  449. this.TIndustryFirstSelector.load(this.profileData.customerType,function(){
  450. if(this.TIndustryFirst.get("value") == this.lp.defaultSelect){
  451. this.TIndustrySecondSelector.load();
  452. }else{
  453. this.TIndustrySecondSelector.setList(this.profileData.customerType);
  454. }
  455. }.bind(this));
  456. this.TIndustrySecondSelector = new MWF.xApplication.CRM.Template.Select(this.TIndustrySecond,this, this.actions, {"width":150,"height":30,"available":false});
  457. this.TIndustrySecondSelector.load();
  458. this.TProvinceSelector = new MWF.xApplication.CRM.Template.Select(this.TProvince,this, this.actions, {"width":100,"height":30});
  459. this.TProvinceSelector.load(this.profileData.customerType,function(){
  460. }.bind(this));
  461. this.TCitySelector = new MWF.xApplication.CRM.Template.Select(this.TCity,this, this.actions, {"width":100,"height":30});
  462. this.TCitySelector.load(this.profileData.customerType,function(){
  463. }.bind(this));
  464. this.TAreaSelector = new MWF.xApplication.CRM.Template.Select(this.TArea,this, this.actions, {"width":100,"height":30});
  465. this.TAreaSelector.load(this.profileData.customerType,function(){
  466. }.bind(this));
  467. this.TProvince.setStyles({"float":"left"});
  468. this.TCity.setStyles({"float":"left","margin-left":"10px"});
  469. this.TArea.setStyles({"float":"left","margin-left":"10px"});
  470. this.TCustomerStatusSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerStatus,this, this.actions, size);
  471. this.TCustomerStatusSelector.load(this.profileData.customerType);
  472. this.TCustomerGradeSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerGrade,this, this.actions, size);
  473. this.TCustomerGradeSelector.load(this.profileData.customerType);
  474. this.TMap = this.formTableArea.getElement("#mapDiv");
  475. this.TMap.addEvents({
  476. "mousewheel":function(e){
  477. e.stopPropagation();
  478. }
  479. });
  480. this.mapLocation = this.formTableArea.getElement("#mapLocation");
  481. this.mapLocation.setStyles({
  482. "width": "99%",
  483. "text-indent":"5px",
  484. "border":"1px solid #999",
  485. "background-color":"#eee",
  486. "border-radius": "3px",
  487. "box-shadow": "0px 0px 6px #eee",
  488. "height": "26px"
  489. });
  490. MWF.xDesktop.requireApp("CRM", "BaiduMap", function(){
  491. this.bMap = new MWF.xApplication.CRM.BaiduMap(this.TMap,this.app,this,this.actions,{"from":"newCustomer"});
  492. this.bMap.load();
  493. }.bind(this));
  494. },
  495. loadForm: function(){
  496. this.form = new MForm(this.formTableArea, this.data, {
  497. style: "default",
  498. isEdited: this.isEdited || this.isNew,
  499. itemTemplate: this.getItemTemplate(this.lp )
  500. },this.app,this.css);
  501. this.form.load();
  502. this.formTableArea.getElements("textarea").setStyles({"height":"100px","overflow":"auto"})
  503. },
  504. getItemTemplate: function( lp ){
  505. _self = this;
  506. return {
  507. TCustomerName: {
  508. text: lp.TCustomerName,
  509. type: "text",
  510. attr : {placeholder:lp.TCustomerName},
  511. notEmpty:true
  512. },
  513. TCustomerType:{
  514. text: lp.TCustomerType
  515. },
  516. TCustomerLevel: {
  517. text: lp.TCustomerLevel
  518. },
  519. TSource: {
  520. text: lp.TSource
  521. },
  522. TIndustryFirst:{
  523. text: lp.TIndustryFirst
  524. },
  525. TIndustrySecond:{
  526. },
  527. TDistrict:{
  528. text: lp.TDistrict
  529. },
  530. TStreet: {
  531. text: lp.TStreet,
  532. type: "text"
  533. },
  534. TLocation:{
  535. text: lp.TLocation,
  536. type : "text",
  537. attr : {"id":"mapLocation","disabled":true}
  538. },
  539. TTelphone: {
  540. text: lp.TTelphone,
  541. type: "text"
  542. },
  543. TFax: {
  544. text: lp.TFax,
  545. type: "text"
  546. },
  547. TRemark: {
  548. text: lp.TRemark,
  549. name:"TRemark",
  550. type: "textarea"
  551. },
  552. TWebSite: {
  553. text: lp.TWebSite,
  554. type: "text"
  555. },
  556. TEmail: {
  557. text: lp.TEmail,
  558. type: "text"
  559. },
  560. TCustomerStatus: {
  561. text: lp.TCustomerStatus
  562. },
  563. TCustomerGrade: {
  564. text: lp.TCustomerGrade
  565. }
  566. }
  567. },
  568. _createBottomContent: function () {
  569. this.cancelActionNode = new Element("div.formCancelActionNode", {
  570. "styles": this.css.formCancelActionNode,
  571. "text": this.lp.actionCancel
  572. }).inject(this.formBottomNode);
  573. this.cancelActionNode.addEvent("click", function (e) {
  574. this.cancel(e);
  575. }.bind(this));
  576. this.okActionNode = new Element("div.formOkActionNode", {
  577. "styles": this.css.formOkActionNode,
  578. "text": this.lp.actionConfirm
  579. }).inject(this.formBottomNode);
  580. this.okActionNode.addEvent("click", function (e) {
  581. this.ok(e);
  582. }.bind(this));
  583. },
  584. _ok: function (data, callback) {
  585. var name = this.data.TCustomerName;
  586. var customertype = this.formTableArea.getElement("#TCustomerTypeValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TCustomerTypeValue").get("text");
  587. var level = this.formTableArea.getElement("#TCustomerTypeValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TCustomerTypeValue").get("text");
  588. var source = this.formTableArea.getElement("#TSourceValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TSourceValue").get("text");
  589. var industryfirst = this.formTableArea.getElement("#TIndustryFirstValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TIndustryFirstValue").get("text");
  590. var industrysecond = this.formTableArea.getElement("#TIndustrySecond").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TIndustrySecond").get("text");
  591. var province = this.formTableArea.getElement("#TProvinceValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TProvinceValue").get("text");
  592. var city = this.formTableArea.getElement("#TCityValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TCityValue").get("text");
  593. var county = this.formTableArea.getElement("#TAreaValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TAreaValue").get("text");
  594. var houseno = this.data.TStreet;
  595. var addresslongitude = this.data.lng;
  596. var addresslatitude = this.data.lat;
  597. var telno = this.data.TTelphone;
  598. var url = this.data.TWebSite;
  599. var email = this.data.TEmail;
  600. var state = this.formTableArea.getElement("#TCustomerStatusValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TCustomerStatusValue").get("text");
  601. var rank = this.formTableArea.getElement("#TCustomerGradeValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TCustomerGradeValue").get("text");
  602. var customerfax = this.data.TFax;
  603. var remark = this.data.TRemark;
  604. var qqno = "";
  605. var webchat = "";
  606. var saveData = {
  607. "customername":name,
  608. "customertype":customertype,
  609. "level":level,
  610. "source":source,
  611. "industryfirst":industryfirst,
  612. "industrysecond":industrysecond,
  613. "province":province,
  614. "city":city,
  615. "county":county,
  616. "houseno":houseno,
  617. "addresslongitude":addresslongitude,
  618. "addresslatitude":addresslatitude,
  619. "customerfax":customerfax,
  620. "telno":telno,
  621. "url":url,
  622. "remark":remark,
  623. "email":email,
  624. "state":state,
  625. "rank":rank,
  626. "qqno":qqno,
  627. "webchat":webchat
  628. };
  629. //alert(JSON.stringify(saveData))
  630. this.app.createShade();
  631. this.actions.saveCustomer(saveData,function(json){
  632. this.app.destroyShade();
  633. this.app.notice(this.lp.saveSuccess,"success");
  634. this.close();
  635. this.fireEvent("reloadView",json);
  636. }.bind(this),function(xhr,text,error){
  637. this.app.showErrorMessage(xhr,text,error);
  638. this.app.destroyShade();
  639. }.bind(this))
  640. }
  641. });