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 districtId = defineModel<string | null | undefined>('districtId');
|
||||||
const subDistrictId = defineModel<string | null | undefined>('subDistrictId');
|
const subDistrictId = defineModel<string | null | undefined>('subDistrictId');
|
||||||
const zipCode = defineModel<string | null | undefined>('zipCode');
|
const zipCode = defineModel<string | null | undefined>('zipCode');
|
||||||
const isOpen = defineModel<boolean>('isOpen', { default: false });
|
|
||||||
|
|
||||||
const addrOptions = reactive<{
|
const addrOptions = reactive<{
|
||||||
provinceOps: Province[];
|
provinceOps: Province[];
|
||||||
|
|
@ -66,9 +65,10 @@ async function selectSubDistrict(id: string) {
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await fetchProvince();
|
await fetchProvince();
|
||||||
|
await fetchDistrict();
|
||||||
|
await fetchSubDistrict();
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(isOpen, fetchDistrict);
|
|
||||||
watch(provinceId, fetchDistrict);
|
watch(provinceId, fetchDistrict);
|
||||||
watch(districtId, fetchSubDistrict);
|
watch(districtId, fetchSubDistrict);
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -149,11 +149,7 @@ watch(districtId, fetchSubDistrict);
|
||||||
emit-value
|
emit-value
|
||||||
map-options
|
map-options
|
||||||
id="select-sub-district"
|
id="select-sub-district"
|
||||||
:model-value="
|
v-model="subDistrictId"
|
||||||
addrOptions.subDistrictOps.length === 1
|
|
||||||
? (subDistrictId = addrOptions.subDistrictOps[0].id)
|
|
||||||
: ''
|
|
||||||
"
|
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
:label="$t('subDistrict')"
|
:label="$t('subDistrict')"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue