xx-controller1

createAddressCtrl.js

  1 /**
  2  * Created on 2015/4/13.
  3  */
  4 /*global
  5  VERSION_KEY_HK
  6  customiseVer
  7  commons
  8  ENT_RSP_SUCCESS
  9  */
 10 define(["language/usercenter", "language/v1r2", "language/custom", "language/errMsg"],
 11     function (i18user, i18v1r2,i18cus,i18Err) {
 12         "use strict";
 13 
 14         var createAddress = ["$scope", "$state", "$rootScope", "validator", "$stateParams", "invoiceService", "tiModalInstance", "tiValid", "csbMessage", "addressObj", "utilService",
 15             function ($scope, $state, $rootScope, validator, $stateParams, invoiceService, tiModalInstance, tiValid, csbMessage, addressObj, utilService) {
 16                 if ($rootScope.i18user == null || $rootScope.i18user == undefined || $rootScope.i18user == "") { 17 $rootScope.i18user = i18user; 18  } 19 if ($rootScope.i18v1r2 == null || $rootScope.i18v1r2 == undefined || $rootScope.i18v1r2 == "") { 20 $rootScope.i18v1r2 = i18v1r2; 21  } 22 if ($rootScope.i18cus == null || $rootScope.i18cus == undefined || $rootScope.i18cus == "") { 23 $rootScope.i18cus = i18cus; 24  } 25 if ($rootScope.i18Err == null || $rootScope.i18Err == undefined || $rootScope.i18Err == "") { 26 $rootScope.i18Err =i18Err; 27 } 28 var addressItem = 29 addressObj; 30 // ============== maintenance data from the data transfer interface adapter codes; 31 if ( "Hong Kong" == addressItem.nationality | | "Hong Kong" == addressItem.nationality) = {32 addressItem.province addressItem.nationality; 33 } 34 //1.10.4 version: address provincial, municipal and district centers by the user self-maintenance data into calling partner domain interface achieve. Both sides of the difference data (i.e., data string can not be matched). key: User center; value: partner domain 35 var addressTransfer = {36 "Neimenggu": "Nei Mongol" , 37 [ "Alashan": "Alxa Meng" , 38 is "Huhehaote": "Hohhot" , 39 "Hulunbuir": " Buir Hulun " , 40" Erds ":" The Ordos " , 41 is" Xilinguole ":" Xilin Gol Meng " , 42 is" Alar ":" Ala'er " , 43 is", 46 "Kashgar":"Kashi(Kaxgar) Diqu", 47 "Tumxuk":"Tumushuke" 48  }; 49 //CBC接口无港澳台数据。自己拼接 50 var otherprovince = i18cus.other_province; 51 /*var zhixiashi = ["CN-11","CN-12","CN-31","CN-50"]; //直辖市*/ 52 53 var districtDefault = { 54 id:-1, 55  label:i18v1r2.county_region 56  }; 57 var cityDefault = { 58 id:-1, 59  label:i18v1r2.city_region 60  }; 61 62  function selectedCheck(id) { 63 return !(id == "-1" || id == null || id == undefined || $.trim(id).length == 0); 64  } 65 66  function zipCodeCheck(id) { 67 return /^[0-9]{6}$/.test(id); 68  } 69 70 mobilePhoneCheck function (ID) 71 is ID = id.replace {(/ \ S / G, "" ); return id.length == 72. 11 && validator.mobilePhoneCheck_R2 (ID); 73 is 74 } 75 76 // 77 special characters limit specialCharCheck function (ID) 78 {IF (ID == undefined == null || || $ .trim ID (ID) .length == 0 ) {79 return to false ; 80 } 81 return validator.specialCharCheckValidator (ID); / / tip_3_0 82 83 } 84 85 // special character limit, do not limit "- #" 86 function subSpecialCharCheck (ID) 87 {IF (ID == undefined == null || || $ .trim ID (ID) = .length 0 = ) {88 return to false ; 89 } 90 return validator.subSpecialCharCheckValidator_2 (ID); tip_3_2 91 is // } // fixed number authentication 92 93 94telePhoneCheck function (value) {95 return (value && (/ ^ [0-9 \ - \ + \ (\)] {1,32} $ /!! .test (value))); 96 } 97 // 98 The default option region 99 function setDefaultDistrictOptions () {$ scope.districtMapArr = 100 [districtDefault]; 101 $ scope.district.selectedId = -1 ; $ 102 = $ scope.selectedDistrict scope.districtMapArr [0 ]; 103 } 104 105 // options provided district TODO: there is a problem: no English looks counties 106 function setDistrictOptions (cityCode) {107 var districtList = [], District = "", selectdIndex = 0, options = []; 108 IF (-1 = = cityCode) {109 setDefaultDistrictOptions (); 110 IF (! $ scope.initAreaTag) {111 tiValid.check ($ ( "# District" )); 112 } 113 return ; 114 } 115 1 16 = Options [districtDefault]; 117 district = addressItem.district ? $.trim(addressItem.district) : ""; 118  invoiceService.getDistrictList(cityCode).then(function(data) { 119 if(ENT_RSP_SUCCESS == data.error_code) { 120 districtList = data.result.countyList; 121 for(var i = 0; i < districtList.length; i++) { 122 if(district && $scope.initAreaTag) { //初次匹配默认值。 123 if(-1 != districtList[i].chineseName.indexOf(district) || (districtList[i].englishName && -1 != districtList[i].englishName.toLowerCase().indexOf(district.toLowerCase()))) { 124 selectdIndex = i + 1; 125  } 126  } 127 if($rootScope.currentLanguage !== 'en-us') { 128  options.push({ 129  id:districtList[i].alpha2Code, 130  label:districtList[i].chineseName 131  }); 132 }else if(districtList[i].englishName) { 133  options.push({ 134  id:districtList[i].alpha2Code, 135  label:districtList[i].englishName 136  }); 137  } 138  } 139 if(1 == options.length && $rootScope.currentLanguage === 'en-us') { //现网没有英文数据时,固定给一个全区 140  options.push({ 141 id:0, 142 label:"All areas" 143  }); 144  } 145 if(0 == selectdIndex) { 146 selectdIndex = 1; 147  } 148  } 149 }).finally(function() { 150 $scope.districtMapArr = options; 151 $scope.district.selectedId = options[selectdIndex].id; 152 $scope.selectedDistrict = options[selectdIndex]; 153 if(!$scope.initAreaTag) { 154 tiValid.check($("#district")); 155  } 156 $scope.initAreaTag = false; 157  }); 158  } 159 160 //默认市选项 161  function setDefaultCityOptions() { 162 $scope.cityMapArr = [cityDefault]; 163 $scope.city.selectedId = -1; 164 $scope.selectedCity = $scope.cityMapArr[0]; 165  } 166 167 168 //设置市/区选项 169  function setCityOptions(provinceCode) { 170 var cityList = [],city="",options=[],selectdIndex = 0; 171 if(-1 == provinceCode) { 172  setDefaultCityOptions(); 173 setDistrictOptions(-1); 174 if(!$scope.initAreaTag) { 175 tiValid.check($("#city")); 176  } 177 return; 178  } 179 options = [cityDefault]; 180 //差异数据适配为接口数据; 181 if(addressItem.city && addressTransfer[addressItem.city]) { 182 addressItem.city = addressTransfer[addressItem.city]; 183  } 184 city = addressItem.city ? $.trim(addressItem.city):""; 185 //数据过渡,匹配港澳台数据 186 if("32" === provinceCode || "33" === provinceCode || "34" === provinceCode ) { 187 for(var i = 0; i < otherprovince.length; i++) { 188 if(otherprovince[i].alpha2Code == provinceCode) { 189 cityList = otherprovince[i].city; 190 for(var j = 0; j < cityList.length; j++) { 191  options.push({ 192  id:cityList[j].alpha2Code, 193 label:$rootScope.currentLanguage === 'en-us'? cityList[j].englishName : cityList[j].chineseName 194  }); 195 if(city && $scope.initAreaTag) { 196 if(-1 != cityList[j].chineseName.indexOf(city) || 197 -1 != cityList[j].englishName.toLowerCase().indexOf(city.toLowerCase()) || 198 -1 != city.indexOf(cityList[j].shortNameCn) 199  ) { 200 selectdIndex = j + 1; //有个默认选项。 201  } 202  } 203  } 204  } 205  } 206 if(0 == selectdIndex) { // 207 selectdIndex = 1; //默认选中第一个。 208  } 209 $scope.cityMapArr = options; 210 $scope.city.selectedId = options[selectdIndex].id; 211 $scope.selectedCity = options[selectdIndex]; 212 if(!$scope.initAreaTag) { 213 tiValid.check($("#city")); 214  } 215  setDefaultDistrictOptions(); 216 $scope.initAreaTag = false; 217 return; 218  } 219 220  invoiceService.getCityList(provinceCode).then(function(data) { 221 if("0" == data.code) { 222 cityList = data.result.cityList; 223 for(var k = 0; k < cityList.length; k++) { 224 if(city && $scope.initAreaTag) { 225 if(-1 != cityList[k].chineseName.indexOf(city) || -1 != cityList[k].englishName.toLowerCase().indexOf(city.toLowerCase())) { 226 selectdIndex = k + 1; //有个默认选项。 227  } 228  } 229  options.push({ 230  id:cityList[k].alpha2Code, 231 label:$rootScope.currentLanguage === 'en-us'? cityList[k].englishName : cityList[k].chineseName 232  }); 233  } 234 if(0 == selectdIndex) { 235 selectdIndex = 1; 236  } 237  } 238 }).finally(function() { 239 $scope.cityMapArr = options; 240 $scope.selectedCity = options[selectdIndex]; 241 $scope.city.selectedId = options[selectdIndex].id; 242 if(!$scope.initAreaTag) { 243 tiValid.check($("#city")); 244  } 245  setDistrictOptions($scope.city.selectedId); 246  }); 247  } 248 249 //设省/市选项 250  function setProviceOptions() { 251 var provinceList = [],province="",selectdIndex = 0,options=[]; 252 //香港版本只展示香港,且不展示区县 253 if($scope.isHKStation) { 254 $scope.provinceMapArr = [{ 255 id:otherprovince[0].alpha2Code, 256 label:$rootScope.currentLanguage === 'en-us'?otherprovince[0].englishName : otherprovince[0].chineseName, 257 checked:true 258  }]; 259 $scope.province.selectedId = otherprovince[0].alpha2Code; 260 $scope.selectedProvince = $scope.provinceMapArr[0]; 261 tiValid.check($("#province")); 262  setDefaultCityOptions(); 263  setDefaultDistrictOptions(); 264 return; 265  } 266 //非香港版本 267 options = [{ 268 id:-1, 269  label:i18v1r2.province_city 270  }]; 271 //差异数据适配为接口数据; 272 if(addressItem.province && addressTransfer[addressItem.province]) { 273 addressItem.province = addressTransfer[addressItem.province]; 274  } 275 province = addressItem.province ? $.trim(addressItem.province):""; 276  invoiceService.getProvinceList().then(function(data) { 277 if("0" == data.code) { 278 provinceList = data.result.provinceList.concat(otherprovince);//数据过渡 匹配代码:拼接港澳台。 279 for(var i = 0; i < provinceList.length; i++) { 280 if(province && $scope.initAreaTag) { 281 if(-1 != provinceList[i].chineseName.indexOf(province) || 282 -1 != provinceList[i].englishName.toLowerCase().indexOf(province.toLowerCase()) || 283 -1 != province.indexOf(provinceList[i].shortNameCn) 284  ) { 285 selectdIndex = i + 1; //有个默认选项。 286  } 287  } 288  options.push({ 289  id:provinceList[i].alpha2Code, 290 label:$rootScope.currentLanguage === 'en-us'? provinceList[i].englishName : provinceList[i].chineseName 291  }); 292  } 293  } 294 }).finally(function() { 295 $scope.provinceMapArr = options; 296 $scope.province.selectedId = options[selectdIndex].id; 297 $scope.selectedProvince = options[selectdIndex]; 298 if(!$scope.initAreaTag) { 299 tiValid.check($("#province")); 300  } 301 302 if(-1 != $scope.province.selectedId) { 303  setCityOptions($scope.province.selectedId); 304 }else{ 305  setDefaultCityOptions(); 306  setDefaultDistrictOptions(); 307 if(!$scope.initAreaTag) { 308 tiValid.check($("#city")); 309 tiValid.check($("#district")); 310  } 311  } 312 313  }); 314  } 315 316 //初始化地区信息 317  function initAreaSelect() { 318 $scope.initAreaTag = true; 319 $scope.nationalityMapArr = [ 320  { 321 id:1, 322  label: i18v1r2.national_china, 323 checked:true 324  } 325  ]; 326  setProviceOptions(); 327  } 328 329 //初始化固定电话 330  function initTelePhone() { 331 if (addressItem.recFixedPhone && typeof(addressItem.recFixedPhone) != "undefined") { 332 $scope.phoneNum.value = addressItem.recFixedPhone; 333  } 334 } 335 336 // Initialize Address enter the length of 337 function initAreaLength () {338 var length = 0 ; IF 339 (= undefined addressItem.address addressItem.address = null &&!! ) {Length = 340. addressItem.address.length; 341 = -} $ scope.addressLength 342 343; length } 344 345 // 346 347 initializes a page event listener / initial page data logic ** * show the begin / 348 function the _init () {349 $ scope.setConfig (); 350 } 351352353354 @ ============== maintenance data from the data transfer interface adapter codes; scope.isHKStation 355 = $ 356 (customiseVer === VERSION_KEY_HK); 357 $ scope.winTitle = i18user.invoice.addAddress; 358 = $ scope.isModifying to false ; 359 IF (! $ .isEmptyObject (addressItem)) = {360 $ scope.winTitle i18user.invoice.modifyAddress; 361 $scope.isModifying = true; 362  } 363 $scope.labelMaxWidth = '100%'; //自定义最大宽度 364 $scope.fieldVertivalAlign = "top"; 365 $scope.itemVerticalAlign = "top"; 366 $scope.fieldsWidth = "310px"; //组件宽度。 367 $scope.fieldsWidthStyle = {"width": "310px"}; 368 $scope.fieldsWidthStyle1 = {"width": $rootScope.currentLanguage == "en-us" ? "214px" : "173px"}; 369 if ($rootScope.language === "en-us") { 370 $scope.fieldsWidth = "362px"; //组件宽度。 371 $scope.fieldsWidthStyle = {"width": "362px"}; 372  } 373 $scope.countryCodeStyle = {"width":$rootScope.currentLanguage == "en-us" ? "130px" : "123px"}; 374 375 376 //国家 377 $scope.nationality = { 378 "elementId": "nation_select", 379 "id": "nationality", 380 "required": true, 381 "label": $rootScope.i18user.createAddress.label_0, 382 selectedId: 1, 383 panelMaxHeight: '200px', 384 width: "310px", 385 style: {"width": $rootScope.currentLanguage == "en-us" ? "362px" : "310px"}, 386  change: function (option) { 387 $scope.selectedNationality = option; //国家选中项。 388  }, 389  tiValidation: { 390 "tip": "", 391 "type":"blurCheck", 392 "validator": [ 393  { 394 rule: "required" 395  }, 396 397  { 398  rule: function () { 399 return selectedCheck($scope.nationality.selectedId); 400  }, 401 errorMsg: "" 402  } 403  ] 404  } 405  }; 406 407 //省份 408 $scope.province = { 409 "elementId": "province_select", 410 "id": "province", 411 "required": true, 412 "label": $rootScope.i18user.createAddress.label_1, 413 selectedId: -1, 414 panelMaxHeight: '310px', 415 width: "100px", 416 style: {"width": $rootScope.currentLanguage == "en-us" ? "118px" : "101px"}, 417 "change": function (option) { 418 $scope.selectedProvince = option; 419  setCityOptions(option.id); 420  }, 421  tiValidation: { 422 "tip": "", 423 "type":"blurCheck", 424 "validator": [ 425  { 426  rule: function () { 427 return selectedCheck($scope.province.selectedId); 428  }, 429 errorMsg: "" 430  } 431  ] 432  } 433  }; 434 435 //城市 436 $scope.city = { 437 "elementId": "city_select", 438 "id": "city", 439 "required": !$scope.isHKStation, 440 "label": $rootScope.i18user.createAddress.label_1, 441 selectedId: -1, 442 panelMaxHeight: '310px', 443 width: "100px", 444 style: {"width": $rootScope.currentLanguage == "en-us" ? "118px" : "101px"}, 445  change: function (option) { 446 $scope.selectedCity = option; 447  setDistrictOptions(option.id); 448  }, 449  tiValidation: { 450 "tip": "", 451 "type":"blurCheck", 452 "validator": [ 453  { 454  rule: function () { 455 return selectedCheck($scope.city.selectedId); 456  }, 457 errorMsg:"" 458  } 459  ] 460  } 461  }; 462 463 //区县 464 $scope.district = { 465 "elementId": "city_select", 466 "id": "district", 467 "required": !$scope.isHKStation, 468 "label": $rootScope.i18user.createAddress.label_1, 469 selectedId: -1, 470 panelMaxHeight: '310px', 471 width: "100px", 472 style: {"width": $rootScope.currentLanguage == "en-us" ? "118px" : "101px"}, 473  change: function (option) { 474 $scope.selectedDistrict = option; 475  }, 476  tiValidation: { 477 "tip": "", 478 "type":"blurCheck", 479 "validator": [ 480  { 481  rule: function () { 482 return selectedCheck($scope.district.selectedId); 483  }, 484 errorMsg: utilService.i18nReplace(i18user.invoice.common_choose_tip, {"0": i18user.createAddress.label_10}) 485  } 486  ] 487  } 488  }; 489 490 //详细地址 491 $scope.addressMaxLength = 60; 492 $scope.addressLength = 60; 493 $scope.address = { 494 "id": "addressID", 495 "maxLength": $scope.addressLength, 496 "label": $rootScope.i18user.createAddress.label_2, 497 required: true, 498 value: addressItem.address || "", 499 "height": "70px", 500 "width": "307px", 501 "resize": "none", 502 style: {"width": $rootScope.currentLanguage == "en-us" ? "358px" : "307px", "resize": "none"}, 503 "placeholder": i18v1r2.address_add_placseholder, 504  change: function () { 505 $scope.addressLength = $scope.addressMaxLength - $("#addressID").val().length; 506 if ($scope.addressLength < 0) { 507 $("#addressID").val($("#addressID").val().substring(0, $scope.addressMaxLength)); 508 $scope.addressLength = 0; 509  } 510  }, 511  tiValidation: { 512 "tip": "", 513 "type":"blurCheck", 514 "validator": [ 515  { 516 rule: "maxSize", 517 param: [60], 518 errorMsg: utilService.i18nReplace(i18user.invoice.characters_length, {"0": 60}) 519  }, 520  { 521  rule: function (value) { 522 if ($.trim(value) == '') { 523 return utilService.i18nReplace(i18user.invoice.common_enter_tip, {"0": i18user.createAddress.label_20}); 524  } 525 if (!subSpecialCharCheck(value)) { 526 return $rootScope.i18user.createInvoice.tip_3_2; 527  } 528 return true; 529  } 530  } 531  ] 532  } 533  }; 534 //邮政编码 535 $scope.zipcode = { 536 "id": "zipcode", 537 "required": true, 538 "label": $rootScope.i18user.createAddress.label_3, 539 "value": addressItem.zip_code || '', 540 "readonly": false, 541 "placeholder": $rootScope.i18user.createAddress.tip_4, 542 "change": function () { 543 this.value = this.value.replace(/\D/g, ''); 544  }, 545  tiValidation: { 546 "tip": "", 547 "type":"blurCheck", 548 "validator": [ 549  { 550  rule: function (value) { 551 if ($.trim(value) == '') { 552 return utilService.i18nReplace(i18user.invoice.common_enter_tip, {"0": i18user.createAddress.label_30}); 553  } 554 if (!zipCodeCheck(value)) { 555 return $rootScope.i18user.createAddress.tip_4; 556  } 557 return true; 558  } 559  } 560  ] 561  } 562  }; 563 564 565 //姓名输入框 566 $scope.name = { 567 "id": "nameID", 568 "required": true, 569 "label": $rootScope.i18user.createAddress.label_4, 570 "value": addressItem.recipient || '', 571 "readonly": false, 572 "placeholder": i18v1r2.address_name_placseholder, 573 "change": function () { 574 if ($scope.name.value.length > 20) { 575 $scope.name.value = $scope.name.value.substr(0, 20); 576  } 577  }, 578  tiValidation: { 579 "tip": "", 580 "type":"blurCheck", 581 "validator": [ 582  { 583 rule: "maxSize", 584 param: [20], 585 errorMsg: utilService.i18nReplace(i18user.invoice.characters_length, {"0": 20}) 586  }, 587  { 588  rule: function (value) { 589 if ($.trim(value) == '') { 590 return utilService.i18nReplace(i18user.invoice.common_enter_tip, {"0": i18user.createAddress.label_40}); 591  } 592 if (!specialCharCheck(value)) { 593 return $rootScope.i18user.createInvoice.tip_3_0; 594  } 595 return true; 596  } 597  } 598  ] 599  } 600  }; 601 602 //手机号码 603 if(addressItem.mobile_phone && addressItem.mobile_phone.replace(/\s/g,"").length === 11) {//点击修改,11位手机号格式化 604 addressItem.mobile_phone = addressItem.mobile_phone.substr(0,3) + " " + addressItem.mobile_phone.substr(3,4) + " " +addressItem.mobile_phone.substr(7,4); 605  } 606 $scope.mobilePhone = { 607 "id": "mobilePhone", 608 "required": true, 609 "label": $rootScope.i18user.createAddress.label_5, 610 "value": addressItem.mobile_phone || '', 611 "readonly": false, 612 style: {"width": $rootScope.currentLanguage == "en-us" ? "118px" : "101px"}, 613 "placeholder": ($scope.isHKStation) ?$rootScope.i18user.createAddress.tip_6hk:$rootScope.i18user.createAddress.tip_6, 614 "change": function () { 615 this.value = this.value.replace(/\D/g, ''); 616 if(this.value.length>0 && this.value.length===11) { 617 this.value = this.value.substr(0,3) + " " + this.value.substr(3,4) + " " +this.value.substr(7,4); 618  } 619  }, 620  tiValidation: { 621 "tip": "", 622 "type":"blurCheck", 623 "validator": [ 624  { 625  rule: function (value) { 626 if ($.trim(value) == '') { 627 return utilService.i18nReplace(i18user.invoice.common_enter_tip, {"0": i18user.createAddress.label_50}); 628  } 629 if (!mobilePhoneCheck(value)) { 630 return $rootScope.i18user.createAddress.tip_7; 631  } 632 return true; 633  } 634  } 635  ] 636  } 637  }; 638 639 $scope.telePhone = { 640 "id": "telePhone", 641 "verticalAlign": "middle", 642 "label": $rootScope.i18user.createAddress.label_6 643  }; 644 645 //固话号码 646 $scope.phoneNum = { 647 "id": "phoneNum", 648 "required": false, 649 "label": $rootScope.i18user.createAddress.label_6, 650 "value": "", 651 "placeholder": ($scope.isHKStation) ? $rootScope.i18user.accountInfo_placeholder_phoneNumhk : $rootScope.i18user.accountInfo_placeholder_phoneNum, 652 "change": function () { 653 this.value = this.value.replace(/\D/g, ''); 654  }, 655  tiValidation: { 656 "tip": "", 657 "type":"blurCheck", 658 "validator": [ 659  { 660 rule: "maxSize", 661 param: [32], 662  errorMsg: $rootScope.i18user.accountEdit.msg_validator_name_maxSize 663  }, { 664  rule: function (value) { 665 $scope.phoneNum.value = value; 666 return telePhoneCheck(value); 667  }, 668  errorMsg: $rootScope.i18user.accountInfo_errorMsg_phoneNum 669  } 670  ] 671  } 672  }; 673 674 $scope.setDefaultCheckbox = { 675  title: i18v1r2.set_default2, 676 checked: addressItem.is_default ? true : false 677  };678 679 680 // Create / modify information stored 681 function saveAddress() { 682 var msg = ""; 683 var city = $scope.city.selectedId != -1 ? $scope.selectedCity.label :""; 684 var info = { 685  province: $scope.selectedProvince.label, 686 city: $scope.isHKStation ? $scope.selectedProvince.label : city, 687 district: $scope.district.selectedId != -1 ? $scope.selectedDistrict.label:"", 688  recipient:$scope.name.value, 689  zip_code: $scope.zipcode.value, 690 areacode:$scope.isHKStation ? "00852":"0086", 691 nationality: $scope.nationalityMapArr[0].label, 692  address: $scope.address.value, 693 telephone: $scope.phoneNum.value || "", 694 mobile_phone:$.trim($scope.mobilePhone.value).replace(/\s/g,""), 695 is_default:+$scope.setDefaultCheckbox.checked 696  }; 697 if(addressItem.address_id) { //修改 698 info.address_id = addressItem.address_id; 699 }else{ //新增 700 info.customer_id = $rootScope.domainId; 701  } 702  invoiceService.saveCustomerAddress(info).then(function(data) { 703 if (data && data.error_code == ENT_RSP_SUCCESS) { 704 if($scope.isModifying) { 705  csbMessage.showSuccess(i18v1r2.modify_address_success); 706 }else{ 707  csbMessage.showSuccess(i18v1r2.save_address_success); 708  } 709 710  tiModalInstance.dismiss(); 711  $rootScope.refreshAddressTable(); 712 }else{ 713 msg = i18Err[data.error_code] || i18v1r2.workorder_system_busy; 714 csbMessage.oneBtnMsg({type: "warn", message: msg}); 715  } 716  }); 717  } 718 719 $scope.saveAddressModel = { 720 "id": "saveAddressID", 721 text: $scope.isModifying ? i18user.createAddress.save : i18user.createAddress.add, 722  click: function () { 723 $scope.initAreaTag = false; 724 var result = tiValid.check($("#mailAddrInfoDiv")); 725 if (!result) { 726 return; 727  } 728  saveAddress(); 729  } 730  }; 731 732 $scope.cancelAddressModel = { 733 "id": "cancelAddressID", 734  text: $rootScope.i18user.createAddress.cancel, 735  click: function () { 736  tiModalInstance.dismiss(); 737  } 738  }; 739 740 $scope.cancel = function () { 741  tiModalInstance.dismiss(); 742  }; 743 744 $scope.setConfig = function () { 745  initAreaSelect(); 746  initTelePhone(); 747  initAreaLength(); 748  }; 749 750 // 初始化页面数据 751 if ($rootScope.domainId == null || $rootScope.domainId == "" || $rootScope.domainId == undefined) { 752 $scope.$on("initUser", _init); 753 } else { 754  _init(); 755  } 756 /**页面初始数据逻辑展示 end*/ 757  }]; 758 759 var module = angular.module('expense.config'); 760 module.tinyController('createAddress.ctrl', createAddress); 761  } 762 );

Guess you like

Origin www.cnblogs.com/77yaer/p/10349781.html