From 41cc892c917202370230788c3616bcc7d5e5c9c7 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 13 Mar 2024 10:33:55 +0700 Subject: [PATCH 1/2] =?UTF-8?q?=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A?= =?UTF-8?q?=E0=B8=B5=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4:=20=E0=B8=82=E0=B9=89=E0=B8=AD?= =?UTF-8?q?=E0=B8=A1=E0=B8=B9=E0=B8=A5=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B8=AD?= =?UTF-8?q?=E0=B8=A2=E0=B8=B9=E0=B9=88=20(=E0=B9=81=E0=B8=81=E0=B9=89?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B9=80=E0=B8=A5=E0=B8=B7=E0=B8=AD?= =?UTF-8?q?=E0=B8=81=E0=B8=88=E0=B8=B1=E0=B8=87=E0=B8=AB=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/PersonalInformation/03_Address.vue | 195 ++++++++++++------ 1 file changed, 129 insertions(+), 66 deletions(-) diff --git a/src/modules/04_registryNew/components/detail/PersonalInformation/03_Address.vue b/src/modules/04_registryNew/components/detail/PersonalInformation/03_Address.vue index 071c50896..01e224c38 100644 --- a/src/modules/04_registryNew/components/detail/PersonalInformation/03_Address.vue +++ b/src/modules/04_registryNew/components/detail/PersonalInformation/03_Address.vue @@ -47,7 +47,7 @@ const resultData = ref({ currentDistrictId: "ce9a2984-938f-454c-a758-26dcf8176afe", currentSubDistrictId: "97dba284-7cdc-45c6-863c-9590810fe8e2", currentZipCode: "50100", - registrationSame: "1", + registrationSame: "0", }); const dataLabel = { @@ -262,6 +262,20 @@ function defaultAdd() { } async function fetchData() { + // mock data + addressData.value.address = resultData.value.registrationAddress; + addressData.value.provinceId = resultData.value.registrationProvinceId; + addressData.value.districtId = resultData.value.registrationDistrictId; + addressData.value.subdistrictId = resultData.value.registrationSubDistrictId; + addressData.value.codep = resultData.value.registrationZipCode; + + addressData.value.same = resultData.value.registrationSame; + + addressData.value.addressC = resultData.value.currentAddress; + addressData.value.provinceIdC = resultData.value.currentProvinceId; + addressData.value.districtIdC = resultData.value.currentDistrictId; + addressData.value.subdistrictIdC = resultData.value.currentSubDistrictId; + addressData.value.codec = resultData.value.currentZipCode; // if (route.params.id) { // // showLoader(); // await http @@ -464,13 +478,57 @@ async function fetchSubDistrict(id: string | null, position: string) { } else isLoad.value++; } +async function selectProvince(e: string | null, name: string) { + if (e != null) { + if (name == "1") { + addressData.value.districtId = ""; + addressData.value.subdistrictId = ""; + addressData.value.codep = ""; + } else { + addressData.value.districtIdC = ""; + addressData.value.subdistrictIdC = ""; + addressData.value.codec = ""; + } + myForm.value.resetValidation(); + await fetchDistrict(e, name); + } +}; + +async function selectDistrict(e: string | null, name: string) { + if (e != null) { + if (name == "1") { + addressData.value.subdistrictId = ""; + addressData.value.codep = ""; + } else { + addressData.value.subdistrictIdC = ""; + addressData.value.codec = ""; + } + myForm.value.resetValidation(); + await fetchSubDistrict(e, name); + } +}; + +function selectSubDistrict(e: string | null, name: string) { + if (e != null) { + if (name == "1") { + const findcode = Ops.value.subdistrictOps.filter((r) => r.id == e); + const namecode = findcode.length > 0 ? findcode[0].zipCode : ""; + addressData.value.codep = namecode; + } else { + const findcode = Ops.value.subdistrictCOps.filter((r) => r.id == e); + const namecode = findcode.length > 0 ? findcode[0].zipCode : ""; + addressData.value.codec = namecode; + } + } +}; + async function getNewData() { await fetchData(); await fetchProvince(); - await fetchDistrict(resultData.value.registrationProvinceId, "1"); - await fetchDistrict(resultData.value.currentProvinceId, "2"); - await fetchSubDistrict(resultData.value.registrationDistrictId, "1"); - await fetchSubDistrict(resultData.value.currentDistrictId, "2"); + await fetchDistrict(addressData.value.provinceId, "1"); + await fetchDistrict(addressData.value.provinceIdC, "2"); + await fetchSubDistrict(addressData.value.districtId, "1"); + await fetchSubDistrict(addressData.value.districtIdC, "2"); } function filterSelector(val: any, update: Function, refData: string) { @@ -554,15 +612,14 @@ function onSubmit() { myForm.value.validate().then(async (result: boolean) => { if (result) { // await saveData(); - console.log("Hello"); modal.value = false; } }); } onMounted(async () => { - await getNewData(); defaultAdd(); + await getNewData(); });