#389 fix:修改输入没有代入值的问题

Samengevoegd
JackZ heeft 2 commits samengevoegd van United_Software/dev_g naar United_Software/dev 1 maand geleden
1 gewijzigde bestanden met toevoegingen van 25 en 36 verwijderingen
  1. 25 36
      src/views/DestinationDelivery/src/components/CreateNewBooking/src/CreateNewbooking.vue

+ 25 - 36
src/views/DestinationDelivery/src/components/CreateNewBooking/src/CreateNewbooking.vue

@@ -221,48 +221,39 @@ const Countryloading = ref(false)
 const city = ref<CountryItem[]>([])
 const Cityoptions = ref<CountryItem[]>([])
 const cityloading = ref(false)
-const getAddressCountryCityData = (type: any) => {
-  $api
+const querySearchCountry = (query: string) => {
+  Countryloading.value = true
+  setTimeout(() => {
+    $api
     .getAddressCountryCityData({
-      term: '',
-      term_type: type,
-      limit: type == 'country' ? CityCode.value : CountryCode.value
+      term: query,
+      term_type: 'country',
+      limit: CityCode.value != ''  ? CityCode.value : ''
     })
     .then((res: any) => {
       if (res.code === 200) {
-        if (type == 'country') {
-          countrys.value = res.data
-        } else {
-          city.value = res.data
-        }
+        Countryoptions.value = res.data
+        Countryloading.value = false
       }
     })
-}
-const querySearchCountry = (query: string) => {
-  if (query) {
-    Countryloading.value = true
-    setTimeout(() => {
-      Countryloading.value = false
-      Countryoptions.value = countrys.value.filter((item) => {
-        return item.label.toLowerCase().includes(query.toLowerCase())
-      })
-    }, 1000)
-  } else {
-    Countryoptions.value = []
-  }
+  }, 1000)
 }
 const querySearchCity = (query: string) => {
-  if (query) {
-    cityloading.value = true
-    setTimeout(() => {
-      cityloading.value = false
-      Cityoptions.value = city.value.filter((item) => {
-        return item.label.toLowerCase().includes(query.toLowerCase())
-      })
-    }, 1000)
-  } else {
-    Cityoptions.value = []
-  }
+  cityloading.value = true
+  setTimeout(() => {
+    $api
+    .getAddressCountryCityData({
+      term: query,
+      term_type: 'city',
+      limit: CountryCode.value != ''  ? CountryCode.value : ''
+    })
+    .then((res: any) => {
+      if (res.code === 200) {
+        Cityoptions.value = res.data
+        cityloading.value = false
+      }
+    })
+  }, 1000)
 }
 // 特殊日期样式
 const getCurrentStyle = (current: any) => {
@@ -1148,7 +1139,6 @@ onMounted(() => {
             v-model="CountryCode"
             filterable
             remote
-            @focus="getAddressCountryCityData('country')"
             placeholder="Select Country"
             :remote-method="querySearchCountry"
             :loading="Countryloading"
@@ -1168,7 +1158,6 @@ onMounted(() => {
             v-model="CityCode"
             filterable
             remote
-            @focus="getAddressCountryCityData('city')"
             placeholder="Select City"
             :remote-method="querySearchCity"
             :loading="cityloading"