Просмотр исходного кода

用户管理选择地市赋值问题修改

wangrulan 1 год назад
Родитель
Сommit
2fe89a089e
1 измененных файлов с 18 добавлено и 8 удалено
  1. 18 8
      src/components/permissions/user/index.vue

+ 18 - 8
src/components/permissions/user/index.vue

@@ -675,14 +675,24 @@ export default {
     selectCityChange(val){
       console.log('val: ', val);
       console.log('this.$refs: ', this.$refs);
-      setTimeout(()=>{
-        this.form.cityName = this.$refs.selectCity.selectedLabel
-        console.log('this.form.cityName: ', this.form.cityName);
-        getAreasByCityId({cityId: val}).then(res=>{
-          console.log('res: ', res);
-          this.areasList = res.data;
-        })
-      }, 500)
+      this.$nextTick(()=>{	
+        // setTimeout(()=>{
+          // this.form.cityName = this.$refs.selectCity.selectedLabel
+          // console.log('this.$refs.selectCity: ', this.$refs.selectCity);
+          // console.log('this.$refs.selectCity.selectedLabel: ', this.$refs.selectCity.selectedLabel);
+          // console.log('this.form.cityName: ', this.form.cityName);
+          this.formCityList.children.map(item=>{
+            if(val == item.value){
+              this.form.cityName = item.label
+            }
+          })
+          console.log('this.form.cityName: ', this.form.cityName);
+          getAreasByCityId({cityId: val}).then(res=>{
+            console.log('res: ', res);
+            this.areasList = res.data;
+          } );
+        // }, 1000)
+      })
 
     },
     // 表单查询条件地区选择