This commit is contained in:
Professional 2025-05-25 20:50:46 +07:00
parent 679c1f20e2
commit 1d8d55fc94

View File

@ -72,18 +72,36 @@
<i class="bi-geo-alt"></i> <i class="bi-geo-alt"></i>
Город Город
</label> </label>
<div class="custom-select"> <div class="select-wrapper">
<select <input
type="text"
id="city" id="city"
v-model="city" v-model="citySearchQuery"
placeholder="Начните вводить название города..."
@focus="showCityList = true"
@input="onCitySearch"
required required
:disabled="loading" :disabled="loading"
/>
<button
type="button"
class="clear-btn"
@click="clearCitySelection"
v-if="city"
:disabled="loading"
> >
<option value="" disabled selected>Выберите город</option> <i class="bi-x"></i>
<option v-for="cityItem in cities" :key="cityItem.name" :value="cityItem.name"> </button>
{{ cityItem.name }} <div class="dropdown" v-if="showCityList && filteredCities.length > 0">
</option> <div
</select> v-for="cityOption in filteredCities"
:key="cityOption"
class="dropdown-option"
@click="selectCity(cityOption)"
>
{{ cityOption }}
</div>
</div>
</div> </div>
</div> </div>
@ -164,6 +182,9 @@ const errorMessage = ref('');
const loading = ref(false); const loading = ref(false);
const birthdateInput = ref(null); const birthdateInput = ref(null);
const cities = ref([]); const cities = ref([]);
const citySearchQuery = ref('');
const showCityList = ref(false);
const filteredCities = ref([]);
// Функция для открытия календаря при клике на поле // Функция для открытия календаря при клике на поле
const openDatePicker = () => { const openDatePicker = () => {
@ -268,6 +289,31 @@ const handleRegister = async () => {
loading.value = false; loading.value = false;
} }
}; };
const onCitySearch = () => {
if (!citySearchQuery.value) {
filteredCities.value = [];
return;
}
const query = citySearchQuery.value.toLowerCase();
filteredCities.value = cities.value
.map(cityItem => cityItem.name) // Получаем только названия городов
.filter(cityName => cityName.toLowerCase().includes(query)) // Фильтруем по запросу
.slice(0, 10); // Ограничиваем количество результатов
};
const selectCity = (cityName) => {
city.value = cityName;
citySearchQuery.value = cityName; // Устанавливаем значение в поле ввода
showCityList.value = false; // Скрываем список городов
};
const clearCitySelection = () => {
city.value = '';
citySearchQuery.value = '';
filteredCities.value = [];
};
</script> </script>
<style scoped> <style scoped>
@ -437,12 +483,12 @@ const handleRegister = async () => {
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
} }
.custom-select { .select-wrapper {
position: relative; position: relative;
width: 100%; width: 100%;
} }
.custom-select select { .select-wrapper input {
width: 100%; width: 100%;
padding: 0.9rem 1rem; padding: 0.9rem 1rem;
background: rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.15);
@ -450,29 +496,51 @@ const handleRegister = async () => {
border-radius: 12px; border-radius: 12px;
color: white; color: white;
font-size: 1rem; font-size: 1rem;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
cursor: pointer;
transition: all 0.3s ease; transition: all 0.3s ease;
} }
.custom-select:after { .clear-btn {
content: '▼';
position: absolute; position: absolute;
top: 50%; top: 50%;
right: 10px; right: 10px;
transform: translateY(-50%); transform: translateY(-50%);
font-size: 0.8rem; background: transparent;
border: none;
color: rgba(255, 255, 255, 0.7); color: rgba(255, 255, 255, 0.7);
pointer-events: none; cursor: pointer;
font-size: 1.1rem;
display: flex;
align-items: center;
justify-content: center;
} }
.custom-select select:focus { .clear-btn:disabled {
outline: none; cursor: not-allowed;
background: rgba(255, 255, 255, 0.25); opacity: 0.5;
border-color: rgba(255, 255, 255, 0.5); }
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
.dropdown {
position: absolute;
top: 100%;
left: 0;
width: 100%;
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 12px;
max-height: 200px;
overflow-y: auto;
z-index: 100;
margin-top: 0.2rem;
}
.dropdown-option {
padding: 0.8rem 1rem;
cursor: pointer;
transition: background 0.3s ease;
}
.dropdown-option:hover {
background: rgba(255, 255, 255, 0.2);
} }
.action-button { .action-button {