CustomerEdit.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. MWF.xApplication.CRM.CustomerEdit = new Class({
  2. Extends: MWF.xApplication.CRM.Template.PopupForm,
  3. Implements: [Options, Events],
  4. options: {
  5. "style": "default",
  6. "width": "800",
  7. "height": "100%",
  8. "top" : 0,
  9. "left" : 0,
  10. "hasTop": true,
  11. "hasIcon": false,
  12. "hasBottom": true,
  13. "title": "",
  14. "draggable": false,
  15. "closeAction": true
  16. },
  17. initialize: function (explorer, actions, data, options) {
  18. this.setOptions(options);
  19. this.explorer = explorer;
  20. this.app = explorer.app;
  21. this.lp = this.app.lp.customer.customerEdit;
  22. this.path = "/x_component_CRM/$CustomerEdit/";
  23. this.cssPath = this.path + this.options.style + "/css.wcss";
  24. this._loadCss();
  25. this.options.title = this.lp.title;
  26. this.data = data || {};
  27. this.actions = actions;
  28. },
  29. load: function () {
  30. this.createForm();
  31. },
  32. createForm:function(){
  33. this.allArrowArr = [];
  34. if (this.options.isNew) {
  35. this.create();
  36. } else if (this.options.isEdited) {
  37. this.edit();
  38. } else {
  39. this.open();
  40. }
  41. this.formContentNode.addEvents({
  42. "click": function () {
  43. if(this.listContentDiv){
  44. this.listContentDiv.destroy();
  45. }
  46. if(this.allArrowArr.length>0){
  47. this.allArrowArr.each(function(d){
  48. d.setStyles({
  49. "background":"url(/x_component_CRM/$Template/default/icons/arrow.png) no-repeat center"
  50. });
  51. }.bind(this))
  52. }
  53. }.bind(this)
  54. });
  55. },
  56. createTopNode: function () {
  57. if (!this.formTopNode) {
  58. this.formTopNode = new Element("div.formTopNode", {
  59. "styles": this.css.formTopNode
  60. }).inject(this.formNode);
  61. this.formTopIconNode = new Element("div", {
  62. "styles": this.css.formTopIconNode
  63. }).inject(this.formTopNode);
  64. this.formTopTextNode = new Element("div", {
  65. "styles": this.css.formTopTextNode,
  66. "text": this.options.title + ( this.data.title ? ("-" + this.data.title ) : "" )
  67. }).inject(this.formTopNode);
  68. if (this.options.closeAction) {
  69. this.formTopCloseActionNode = new Element("div", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  70. this.formTopCloseActionNode.addEvent("click", function () {
  71. this.close();
  72. }.bind(this))
  73. }
  74. this.formTopContentNode = new Element("div", {
  75. "styles": this.css.formTopContentNode
  76. }).inject(this.formTopNode);
  77. this._createTopContent();
  78. }
  79. },
  80. _createTopContent: function () {
  81. },
  82. _createTableContent: function () {
  83. //this.loadFormData();
  84. var Ttype = "customer";
  85. this.actions.getProfiles(Ttype,function(json){
  86. this.profileData = json.data;
  87. if(this.data.id){
  88. this.actions.getCustomerInfo(this.data.id,function(json){
  89. this.customerData = json.data;
  90. this.loadFormData();
  91. this.createCustomBottom();
  92. }.bind(this));
  93. }else{
  94. this.loadFormData();
  95. this.createCustomBottom();
  96. }
  97. }.bind(this));
  98. },
  99. loadFormData:function(){
  100. var tmpData={};
  101. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  102. "<tr>" +
  103. " <td styles='formTableTitle'><span lable='TCustomerName'></span><span style='color:#f00'>*</span></td>" +
  104. " <td styles='formTableValue' item='TCustomerName'></td>" +
  105. "</tr><tr>" +
  106. " <td styles='formTableTitle' lable='TCustomerType'></td>" +
  107. " <td styles='formTableValue'><div id='TCustomerType'></div></td>" +
  108. "</tr><tr>" +
  109. " <td styles='formTableTitle' lable='TCustomerLevel'></td>" +
  110. " <td styles='formTableValue'><div id='TCustomerLevel'></div></td>" +
  111. "</tr><tr>" +
  112. " <td styles='formTableTitle' lable='TSource'></td>" +
  113. " <td styles='formTableValue'><div id='TSource'></div></td>" +
  114. "</tr><tr>" +
  115. " <td styles='formTableTitle' lable='TIndustryFirst'></td>" +
  116. " <td styles='formTableValue'><div id='TIndustryFirst'></div><div id='TIndustrySecond'></div></td>" +
  117. "</tr><tr>" +
  118. " <td styles='formTableTitle' lable='TDistrict'></td>" +
  119. " <td styles='formTableValue'><div id='TProvince'></div><div id='TCity'></div><div id='TArea'></div></td>" +
  120. "</tr><tr>" +
  121. " <td styles='formTableTitle' lable='TStreet'></td>" +
  122. " <td styles='formTableValue' item='TStreet'></td>" +
  123. "</tr><tr>" +
  124. " <td styles='formTableTitle' lable='TLocation'></td>" +
  125. " <td styles='formTableValue'><div style='width:100%;height:30px;'><input type='text' placeholder='"+this.lp.TLocationNotice+"' id='mapLocation' disabled/></div></td>" +
  126. "</tr><tr>" +
  127. " <td styles='formTableTitle'></td>" +
  128. " <td styles='formTableValue'><div id='mapDiv' styles='mapDiv'></div></td>" +
  129. "</tr><tr>" +
  130. " <td styles='formTableTitle' lable='TTelphone'></td>" +
  131. " <td styles='formTableValue' item='TTelphone'></td>" +
  132. "</tr><tr>" +
  133. " <td styles='formTableTitle' lable='TFax'></td>" +
  134. " <td styles='formTableValue' item='TFax'></td>" +
  135. "</tr><tr>" +
  136. " <td styles='formTableTitle' lable='TRemark'></td>" +
  137. " <td styles='formTableValue' item='TRemark'></td>" +
  138. "</tr><tr>" +
  139. " <td styles='formTableTitle' lable='TWebSite'></td>" +
  140. " <td styles='formTableValue' item='TWebSite'></td>" +
  141. "</tr><tr>" +
  142. " <td styles='formTableTitle' lable='TEmail'></td>" +
  143. " <td styles='formTableValue' item='TEmail'></td>" +
  144. "</tr><tr>" +
  145. " <td styles='formTableTitle' lable='TCustomerStatus'></td>" +
  146. " <td styles='formTableValue'><div id='TCustomerStatus'></div></td>" +
  147. "</tr><tr>" +
  148. " <td styles='formTableTitle' lable='TCustomerGrade'></td>" +
  149. " <td styles='formTableValue'><div id='TCustomerGrade'></div></td>" +
  150. "</tr>" +
  151. "</table>"
  152. this.formTableArea.set("html", html);
  153. this.loadForm();
  154. this.TCustomerType = this.formTableArea.getElement("#TCustomerType");
  155. this.TCustomerLevel = this.formTableArea.getElement("#TCustomerLevel");
  156. this.TSource = this.formTableArea.getElement("#TSource");
  157. this.TIndustryFirst = this.formTableArea.getElement("#TIndustryFirst");
  158. this.TIndustrySecond = this.formTableArea.getElement("#TIndustrySecond");
  159. this.TProvince = this.formTableArea.getElement("#TProvince");
  160. this.TCity = this.formTableArea.getElement("#TCity");
  161. this.TArea = this.formTableArea.getElement("#TArea");
  162. this.TCustomerStatus = this.formTableArea.getElement("#TCustomerStatus");
  163. this.TCustomerGrade = this.formTableArea.getElement("#TCustomerGrade");
  164. var size = {"width":230,"height":30};
  165. this.TIndustryFirst.setStyles({"float":"left"});
  166. this.TIndustrySecond.setStyles({"float":"left","margin-left":"10px"});
  167. //客户类型
  168. this.TCustomerTypeSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerType,this, this.actions, size);
  169. this.TCustomerTypeSelector.load();
  170. alert(JSON.stringify(this.profileData.customertype_config))
  171. this.TCustomerTypeSelector.setList(this.profileData.customertype_config);
  172. if(this.customerData && this.customerData.customertype){
  173. this.TCustomerTypeSelector.selectValueDiv.set({"text":this.customerData.customertype});
  174. this.TCustomerTypeSelector.node.set("value",this.customerData.customertype);
  175. }
  176. //客户级别
  177. this.TCustomerLevelSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerLevel,this, this.actions, size);
  178. this.TCustomerLevelSelector.load();
  179. this.TCustomerLevelSelector.setList(this.profileData.level_config);
  180. if(this.customerData && this.customerData.level){
  181. this.TCustomerLevelSelector.selectValueDiv.set({"text":this.customerData.level});
  182. this.TCustomerLevelSelector.node.set("value",this.customerData.level);
  183. }
  184. //来源
  185. this.TSourceSelector = new MWF.xApplication.CRM.Template.Select(this.TSource,this, this.actions, size);
  186. this.TSourceSelector.load();
  187. this.TSourceSelector.setList(this.profileData.source_config);
  188. if(this.customerData && this.customerData.source){
  189. this.TSourceSelector.selectValueDiv.set({"text":this.customerData.source});
  190. this.TSourceSelector.node.set("value",this.customerData.source);
  191. }
  192. //行业
  193. this.TIndustryFirstSelector = new MWF.xApplication.CRM.Template.Select(this.TIndustryFirst,this, this.actions, {"width":230,"height":30});
  194. this.TIndustrySecondSelector = new MWF.xApplication.CRM.Template.Select(this.TIndustrySecond,this, this.actions, {"width":230,"height":30,"available":"no"});
  195. this.TIndustrySecondSelector.load();
  196. this.TIndustryFirstSelector.load();
  197. if(this.customerData && this.customerData.industryfirst){
  198. this.TIndustryFirstSelector.selectValueDiv.set({"text":this.customerData.industryfirst});
  199. this.TIndustryFirstSelector.node.set("value",this.customerData.industryfirst);
  200. this.profileData.industry_config.childNodes.each(function(d){
  201. if(d.configname == this.customerData.industryfirst){
  202. tmpData = d;
  203. }
  204. }.bind(this));
  205. this.TIndustrySecondSelector.setList(tmpData);
  206. this.TIndustrySecond.set("available","yes");
  207. this.TIndustrySecond.setStyles({"background-color":""});
  208. }
  209. if(this.customerData && this.customerData.industrysecond){
  210. this.TIndustrySecondSelector.selectValueDiv.set({"text":this.customerData.industrysecond});
  211. this.TIndustrySecondSelector.node.set("value",this.customerData.industrysecond);
  212. this.profileData.industry_config.childNodes.each(function(d){
  213. if(d.configname == this.customerData.industryfirst){
  214. tmpData = d;
  215. }
  216. }.bind(this));
  217. this.TIndustrySecondSelector.setList(tmpData);
  218. this.TIndustrySecond.set("available","yes");
  219. this.TIndustrySecond.setStyles({"background-color":""});
  220. }
  221. this.TIndustryFirstSelector.setList(this.profileData.industry_config,function(d){
  222. if(this.TIndustryFirst.get("value") == this.lp.defaultSelect){
  223. this.TIndustrySecondSelector.createDefault();
  224. this.TIndustrySecondSelector.setList();
  225. this.TIndustrySecond.set("available","no");
  226. this.TIndustrySecond.setStyles({"background-color":"#eeeeee"})
  227. }else{
  228. this.TIndustrySecondSelector.createDefault();
  229. this.TIndustrySecondSelector.setList(d);
  230. this.TIndustrySecond.set("available","yes");
  231. this.TIndustrySecond.setStyles({"background-color":""});
  232. }
  233. }.bind(this));
  234. //省、市、区
  235. this.TProvinceSelector = new MWF.xApplication.CRM.Template.Select(this.TProvince,this, this.actions, {"width":150,"height":30});
  236. this.TProvinceSelector.load({},function(){
  237. this.actions.getProvinceList(function(json){
  238. this.TProvinceSelector.setAddress(json.data,function(d){
  239. //city
  240. if(this.TProvince.get("value") == this.lp.defaultSelect){
  241. this.TCitySelector.createDefault();
  242. this.TCitySelector.setAddress();
  243. this.TCity.set("available","no");
  244. this.TCity.setStyles({"background-color":"#eeeeee"});
  245. }else{
  246. this.actions.getCityList({pid: d.cityid},function(json){
  247. this.TCitySelector.createDefault();
  248. this.TCitySelector.setAddress(json.data,function(dd){
  249. //area
  250. if(this.TCity.get("value") == this.lp.defaultSelect){
  251. this.TAreaSelector.createDefault();
  252. this.TAreaSelector.setAddress();
  253. this.TArea.set("available","no");
  254. this.TArea.setStyles({"background-color":"#eeeeee"});
  255. }else{
  256. this.actions.getAreaList({pid:dd.cityid},function(json){
  257. this.TAreaSelector.createDefault();
  258. this.TAreaSelector.setAddress(json.data);
  259. this.TArea.set("available","yes");
  260. this.TArea.setStyles({"background-color":""});
  261. }.bind(this));
  262. }
  263. }.bind(this));
  264. this.TCity.set("available","yes");
  265. this.TCity.setStyles({"background-color":""});
  266. }.bind(this));
  267. }
  268. this.TAreaSelector.createDefault();
  269. this.TAreaSelector.setAddress();
  270. this.TArea.set("available","no");
  271. this.TArea.setStyles({"background-color":"#eeeeee"});
  272. }.bind(this))
  273. }.bind(this))
  274. }.bind(this));
  275. this.TCitySelector = new MWF.xApplication.CRM.Template.Select(this.TCity,this, this.actions, {"width":150,"height":30,"available":"no"});
  276. this.TCitySelector.load();
  277. this.TAreaSelector = new MWF.xApplication.CRM.Template.Select(this.TArea,this, this.actions, {"width":150,"height":30,"available":"no"});
  278. this.TAreaSelector.load();
  279. if(this.customerData && this.customerData.province){ //省
  280. this.TProvinceSelector.selectValueDiv.set({"text":this.customerData.province});
  281. this.TProvinceSelector.node.set("value",this.customerData.province);
  282. }
  283. if(this.customerData && this.customerData.city){ //市
  284. if(this.customerData && this.customerData.province){
  285. this.actions.getCityListByName({"regionname":this.customerData.province},
  286. function(json){
  287. this.TCitySelector.setAddress(json.data,function(dd){
  288. //area
  289. if(this.TCity.get("value") == this.lp.defaultSelect){
  290. this.TAreaSelector.createDefault();
  291. this.TAreaSelector.setAddress();
  292. this.TArea.set("available","no");
  293. this.TArea.setStyles({"background-color":"#eeeeee"});
  294. }else{
  295. this.actions.getAreaList({pid:dd.cityid},function(json){
  296. this.TAreaSelector.createDefault();
  297. this.TAreaSelector.setAddress(json.data);
  298. this.TArea.set("available","yes");
  299. this.TArea.setStyles({"background-color":""});
  300. }.bind(this));
  301. }
  302. }.bind(this));
  303. }.bind(this));
  304. }
  305. this.TCitySelector.selectValueDiv.set({"text":this.customerData.city});
  306. this.TCitySelector.node.set("value",this.customerData.city);
  307. this.TCity.set("available","yes");
  308. this.TCity.setStyles({"background-color":""});
  309. }
  310. if(this.customerData && this.customerData.county){ //区
  311. if(this.customerData && this.customerData.city){
  312. this.actions.getAreaListByName({"regionname":this.customerData.city},
  313. function(json){
  314. this.TAreaSelector.setAddress(json.data);
  315. }.bind(this));
  316. }
  317. this.TAreaSelector.selectValueDiv.set({"text":this.customerData.county});
  318. this.TAreaSelector.node.set("value",this.customerData.county);
  319. this.TArea.set("available","yes");
  320. this.TArea.setStyles({"background-color":""});
  321. }
  322. this.TProvince.setStyles({"float":"left"});
  323. this.TCity.setStyles({"float":"left","margin-left":"10px"});
  324. this.TArea.setStyles({"float":"left","margin-left":"10px"});
  325. this.TCustomerStatusSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerStatus,this, this.actions, size);
  326. this.TCustomerStatusSelector.load();
  327. this.TCustomerStatusSelector.setList(this.profileData.state_config);
  328. if(this.customerData && this.customerData.state){
  329. this.TCustomerStatusSelector.selectValueDiv.set({"text":this.customerData.state});
  330. this.TCustomerStatusSelector.node.set("value",this.customerData.state);
  331. }
  332. this.TCustomerGradeSelector = new MWF.xApplication.CRM.Template.Select(this.TCustomerGrade,this, this.actions, size);
  333. this.TCustomerGradeSelector.load();
  334. this.TCustomerGradeSelector.setList(this.profileData.customerrank_config);
  335. this.TMap = this.formTableArea.getElement("#mapDiv");
  336. this.TMap.addEvents({
  337. "mousewheel":function(e){
  338. e.stopPropagation();
  339. }
  340. });
  341. this.mapLocation = this.formTableArea.getElement("#mapLocation");
  342. this.mapLocation.setStyles({
  343. "width": "99%",
  344. "text-indent":"5px",
  345. "border":"1px solid #999",
  346. "background-color":"#eee",
  347. "border-radius": "3px",
  348. "box-shadow": "0px 0px 6px #eee",
  349. "height": "26px"
  350. });
  351. MWF.xDesktop.requireApp("CRM", "BaiduMap", function(){
  352. this.bMap = new MWF.xApplication.CRM.BaiduMap(this.TMap,this.app,this,this.actions,{"from":"newCustomer"});
  353. var mapData = {};
  354. if(this.customerData && this.customerData.addresslatitude){
  355. mapData.latitude = this.customerData.addresslatitude
  356. }
  357. if(this.customerData && this.customerData.addresslongitude){
  358. mapData.longitude = this.customerData.addresslongitude
  359. }
  360. this.bMap.load(mapData);
  361. }.bind(this));
  362. },
  363. loadForm: function(){
  364. this.form = new MForm(this.formTableArea, this.data, {
  365. style: "default",
  366. isEdited: this.isEdited || this.isNew,
  367. itemTemplate: this.getItemTemplate(this.lp )
  368. },this.app,this.css);
  369. this.form.load();
  370. this.formTableArea.getElements("textarea").setStyles({"height":"100px","overflow":"auto","color":"#666666"});
  371. this.formTableArea.getElements("input").setStyles({"color":"#666666"});
  372. },
  373. getItemTemplate: function( lp ){
  374. _self = this;
  375. return {
  376. TCustomerName: {
  377. text: lp.TCustomerName,
  378. type: "text",
  379. attr : {placeholder:lp.TCustomerName},
  380. notEmpty:true,
  381. value:this.customerData && this.customerData.customername?this.customerData.customername:""
  382. },
  383. TCustomerType:{
  384. text: lp.TCustomerType
  385. },
  386. TCustomerLevel: {
  387. text: lp.TCustomerLevel
  388. },
  389. TSource: {
  390. text: lp.TSource
  391. },
  392. TIndustryFirst:{
  393. text: lp.TIndustryFirst
  394. },
  395. TIndustrySecond:{
  396. },
  397. TDistrict:{
  398. text: lp.TDistrict
  399. },
  400. TStreet: {
  401. text: lp.TStreet,
  402. type: "text",
  403. value:this.customerData && this.customerData.houseno?this.customerData.houseno:""
  404. },
  405. TLocation:{
  406. text: lp.TLocation,
  407. type : "text",
  408. attr : {"id":"mapLocation","disabled":true},
  409. value:this.customerData && this.customerData.houseno?this.customerData.houseno:""
  410. },
  411. TTelphone: {
  412. text: lp.TTelphone,
  413. type: "text",
  414. value:this.customerData && this.customerData.telno?this.customerData.telno:""
  415. },
  416. TFax: {
  417. text: lp.TFax,
  418. type: "text",
  419. value:this.customerData && this.customerData.customerfax?this.customerData.customerfax:""
  420. },
  421. TRemark: {
  422. text: lp.TRemark,
  423. name:"TRemark",
  424. type: "textarea",
  425. value:this.customerData && this.customerData.remark?this.customerData.remark:""
  426. },
  427. TWebSite: {
  428. text: lp.TWebSite,
  429. type: "text",
  430. value:this.customerData && this.customerData.url?this.customerData.url:""
  431. },
  432. TEmail: {
  433. text: lp.TEmail,
  434. type: "text",
  435. value:this.customerData && this.customerData.email?this.customerData.email:""
  436. },
  437. TCustomerStatus: {
  438. text: lp.TCustomerStatus
  439. },
  440. TCustomerGrade: {
  441. text: lp.TCustomerGrade
  442. }
  443. }
  444. },
  445. createCustomBottom:function(){
  446. this.okActionNode = new Element("div.formOkActionNode", {
  447. "styles": this.css.formOkActionNode,
  448. "text": this.lp.actionConfirm
  449. }).inject(this.formBottomNode);
  450. this.okActionNode.addEvent("click", function (e) {
  451. this.ok(e);
  452. }.bind(this));
  453. },
  454. //_createBottomContent: function () {
  455. //
  456. // this.cancelActionNode = new Element("div.formCancelActionNode", {
  457. // "styles": this.css.formCancelActionNode,
  458. // "text": this.lp.actionCancel
  459. // }).inject(this.formBottomNode);
  460. // this.cancelActionNode.addEvent("click", function (e) {
  461. // this.cancel(e);
  462. // }.bind(this));
  463. //
  464. // this.okActionNode = new Element("div.formOkActionNode", {
  465. // "styles": this.css.formOkActionNode,
  466. // "text": this.lp.actionConfirm
  467. // }).inject(this.formBottomNode);
  468. //
  469. // this.okActionNode.addEvent("click", function (e) {
  470. // this.ok(e);
  471. // }.bind(this));
  472. //
  473. //},
  474. _ok: function (data, callback) {
  475. var name = this.data.TCustomerName;
  476. var customertype = this.formTableArea.getElement("#TCustomerTypeValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TCustomerTypeValue").get("text");
  477. var level = this.formTableArea.getElement("#TCustomerLevel").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TCustomerLevel").get("text");
  478. var source = this.formTableArea.getElement("#TSourceValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TSourceValue").get("text");
  479. var industryfirst = this.formTableArea.getElement("#TIndustryFirstValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TIndustryFirstValue").get("text");
  480. var industrysecond = this.formTableArea.getElement("#TIndustrySecond").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TIndustrySecond").get("text");
  481. var province = this.formTableArea.getElement("#TProvinceValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TProvinceValue").get("text");
  482. var city = this.formTableArea.getElement("#TCityValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TCityValue").get("text");
  483. var county = this.formTableArea.getElement("#TAreaValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TAreaValue").get("text");
  484. var houseno = this.data.TStreet;
  485. var addresslongitude = this.data.lng;
  486. var addresslatitude = this.data.lat;
  487. var telno = this.data.TTelphone;
  488. var url = this.data.TWebSite;
  489. var email = this.data.TEmail;
  490. var state = this.formTableArea.getElement("#TCustomerStatusValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TCustomerStatusValue").get("text");
  491. var rank = this.formTableArea.getElement("#TCustomerGradeValue").get("text") == this.lp.defaultSelect ? "":this.formTableArea.getElement("#TCustomerGradeValue").get("text");
  492. var customerfax = this.data.TFax;
  493. var remark = this.data.TRemark;
  494. var qqno = "";
  495. var webchat = "";
  496. var id = this.customerData ? this.customerData.id:"";
  497. var saveData = {
  498. "id":id,
  499. "customername":name,
  500. "customertype":customertype,
  501. "level":level,
  502. "source":source,
  503. "industryfirst":industryfirst,
  504. "industrysecond":industrysecond,
  505. "province":province,
  506. "city":city,
  507. "county":county,
  508. "houseno":houseno,
  509. "addresslongitude":addresslongitude,
  510. "addresslatitude":addresslatitude,
  511. "customerfax":customerfax,
  512. "telno":telno,
  513. "url":url,
  514. "remark":remark,
  515. "email":email,
  516. "state":state,
  517. "customerrank":rank,
  518. "qqno":qqno,
  519. "webchat":webchat
  520. };
  521. //alert(JSON.stringify(saveData))
  522. this.app.createShade();
  523. this.actions.saveCustomer(saveData,function(json){
  524. this.app.destroyShade();
  525. this.app.notice(this.lp.saveSuccess,"success");
  526. this.close();
  527. this.fireEvent("reloadView",json);
  528. }.bind(this),function(xhr,text,error){
  529. this.app.showErrorMessage(xhr,text,error);
  530. this.app.destroyShade();
  531. }.bind(this));
  532. }
  533. });