fix: select district & subdistrict
This commit is contained in:
parent
f019c62351
commit
77eacda307
1 changed files with 3 additions and 7 deletions
|
|
@ -23,7 +23,6 @@ const provinceId = defineModel<string | null | undefined>('provinceId');
|
|||
const districtId = defineModel<string | null | undefined>('districtId');
|
||||
const subDistrictId = defineModel<string | null | undefined>('subDistrictId');
|
||||
const zipCode = defineModel<string | null | undefined>('zipCode');
|
||||
const isOpen = defineModel<boolean>('isOpen', { default: false });
|
||||
|
||||
const addrOptions = reactive<{
|
||||
provinceOps: Province[];
|
||||
|
|
@ -66,9 +65,10 @@ async function selectSubDistrict(id: string) {
|
|||
|
||||
onMounted(async () => {
|
||||
await fetchProvince();
|
||||
await fetchDistrict();
|
||||
await fetchSubDistrict();
|
||||
});
|
||||
|
||||
watch(isOpen, fetchDistrict);
|
||||
watch(provinceId, fetchDistrict);
|
||||
watch(districtId, fetchSubDistrict);
|
||||
</script>
|
||||
|
|
@ -149,11 +149,7 @@ watch(districtId, fetchSubDistrict);
|
|||
emit-value
|
||||
map-options
|
||||
id="select-sub-district"
|
||||
:model-value="
|
||||
addrOptions.subDistrictOps.length === 1
|
||||
? (subDistrictId = addrOptions.subDistrictOps[0].id)
|
||||
: ''
|
||||
"
|
||||
v-model="subDistrictId"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
:label="$t('subDistrict')"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue