| | |
| | | .then(res => { |
| | | this.provinces = res |
| | | }) |
| | | if(this.form.provinceCode){ |
| | | this.selectProvince(this.form.provinceCode,true) |
| | | } |
| | | }, |
| | | // 选择省份 |
| | | selectProvince (val) { |
| | | selectProvince (val,isInit) { |
| | | this.provinces.forEach(item => { |
| | | if (item.id == val) { |
| | | this.form.provinceName = item.name |
| | |
| | | }) |
| | | this.cities = [] |
| | | this.areas = [] |
| | | if(!isInit){ |
| | | this.form.cityName = '' |
| | | this.form.areaCode = '' |
| | | this.form.cityCode = '' |
| | | this.form.areaName = '' |
| | | } |
| | | if(!val || val ==''){ |
| | | return |
| | | } |
| | | this.api.areaList({ pid: val }) |
| | | .then(res => { |
| | | this.cities = res |
| | | this.selectCity(this.form.cityId) |
| | | if(isInit){ |
| | | this.selectCity(this.form.cityCode,isInit) |
| | | } |
| | | }) |
| | | }, |
| | | // 选择城市 |
| | | selectCity (val) { |
| | | selectCity (val,isInit) { |
| | | this.cities.forEach(item => { |
| | | if (item.id == val) { |
| | | this.form.cityName = item.name |
| | | } |
| | | }) |
| | | this.areas = [] |
| | | if(!isInit){ |
| | | this.form.areaCode = '' |
| | | this.form.areaName = '' |
| | | } |
| | | if(!val || val ==''){ |
| | | return |
| | | } |