|
@@ -95,44 +95,41 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
districtChange(val){
|
|
|
- var item=this.citys.find((item)=>{
|
|
|
- return item.cityId==val;
|
|
|
- })
|
|
|
- console.log(item)
|
|
|
+ const item = this.district.find(i => i.cityId === val)
|
|
|
this.form.district=item.name;
|
|
|
-
|
|
|
},
|
|
|
cityChange(val){
|
|
|
- this.district=this.citys.filter(item => item.parentId===val )
|
|
|
+ const item = this.city.find(i => i.cityId === val)
|
|
|
+ this.district = item.children
|
|
|
this.form.district=null;
|
|
|
- var item=this.citys.find((item)=>{
|
|
|
- return item.cityId==val;
|
|
|
- })
|
|
|
- console.log(item)
|
|
|
this.form.city=item.name;
|
|
|
this.form.cityId=val;
|
|
|
-
|
|
|
},
|
|
|
provinceChange(val){
|
|
|
- console.log(val)
|
|
|
- this.city=this.citys.filter(item => item.parentId===val )
|
|
|
+ const item = this.citys.find(i => i.cityId === val)
|
|
|
+ this.city = item.children
|
|
|
this.district=[];
|
|
|
this.form.city=null;
|
|
|
this.form.district=null;
|
|
|
- var item=this.citys.find((item)=>{
|
|
|
- return item.cityId==val;
|
|
|
- })
|
|
|
- console.log(item)
|
|
|
this.form.province=item.name;
|
|
|
},
|
|
|
getCityList(){
|
|
|
getCitys().then(res => {
|
|
|
this.loading = false;
|
|
|
- this.citys=res.data;
|
|
|
- console.log("this.citys",this.citys)
|
|
|
- this.province=res.data.filter(item => item.level===0 )
|
|
|
+ this.citys = this.convertCityData(res.data)
|
|
|
+ this.province=this.citys.filter(item => item.parentId===0 )
|
|
|
})
|
|
|
},
|
|
|
+ convertCityData(array) {
|
|
|
+ return array.map(item => {
|
|
|
+ return {
|
|
|
+ 'cityId': item.value,
|
|
|
+ 'name': item.label,
|
|
|
+ 'parentId': item.pid,
|
|
|
+ 'children': item.children && this.convertCityData(item.children)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
init(userId){
|
|
|
this.form.userId=userId;
|
|
|
},
|