diff --git a/src/modules/04_registry/components/Information/Address.vue b/src/modules/04_registry/components/Information/Address.vue index ae57f5613..52e5bd0db 100644 --- a/src/modules/04_registry/components/Information/Address.vue +++ b/src/modules/04_registry/components/Information/Address.vue @@ -31,7 +31,7 @@ />
-
-
-
-
-
- { showLoader(); await http .get(config.API.province) - .then((res) => { + .then(async (res) => { const data = res.data.result; let option: DataOption[] = []; data.map((r: any) => { @@ -807,6 +807,29 @@ const fetchProvince = async () => { }); Ops.value.provinceOps = option; OpsFilter.value.provinceOps = option; + + const checkRegistProvinceId = await option.find( + (e: any) => e.id === addressData.value.provinceId + ); + if (checkRegistProvinceId) { + addressData.value = addressData.value; + } else { + addressData.value.provinceId = ""; + addressData.value.districtId = ""; + addressData.value.subdistrictId = ""; + addressData.value.codep = ""; + } + const checkCurrentProvinceId = await option.find( + (e: any) => e.id === addressData.value.provinceIdC + ); + if (checkCurrentProvinceId) { + addressData.value = addressData.value; + } else { + addressData.value.provinceIdC = ""; + addressData.value.districtIdC = ""; + addressData.value.subdistrictIdC = ""; + addressData.value.codec = ""; + } }) .catch((e) => { messageError($q, e); @@ -821,7 +844,7 @@ const fetchDistrict = async (id: string | null, position: string) => { showLoader(); await http .get(config.API.listDistrict(id)) - .then((res) => { + .then(async (res) => { const data = res.data.result; let option: DataOption[] = []; data.map((r: any) => { @@ -830,9 +853,35 @@ const fetchDistrict = async (id: string | null, position: string) => { if (position == "1") { Ops.value.districtOps = option; OpsFilter.value.districtOps = option; + + const checkRegistDistrictId = await option.find( + (e: any) => e.id === addressData.value.districtId + ); + if (checkRegistDistrictId) { + addressData.value.districtId = addressData.value.districtId; + addressData.value.subdistrictId = addressData.value.subdistrictId; + addressData.value.codep = addressData.value.codep; + } else { + addressData.value.districtId = ""; + addressData.value.subdistrictId = ""; + addressData.value.codep = ""; + } } else { Ops.value.districtCOps = option; OpsFilter.value.districtCOps = option; + + const checkCurrentDistrictIdC = await option.find( + (e: any) => e.id === addressData.value.districtIdC + ); + if (checkCurrentDistrictIdC) { + addressData.value.districtIdC = addressData.value.districtIdC; + addressData.value.subdistrictIdC = addressData.value.subdistrictIdC; + addressData.value.codec = addressData.value.codec; + } else { + addressData.value.districtIdC = ""; + addressData.value.subdistrictIdC = ""; + addressData.value.codec = ""; + } } }) .catch((e) => { @@ -849,7 +898,7 @@ const fetchSubDistrict = async (id: string | null, position: string) => { showLoader(); await http .get(config.API.listSubDistrict(id)) - .then((res) => { + .then(async (res) => { const data = res.data.result; let option: zipCodeOption[] = []; data.map((r: any) => { @@ -862,9 +911,31 @@ const fetchSubDistrict = async (id: string | null, position: string) => { if (position == "1") { Ops.value.subdistrictOps = option; OpsFilter.value.subdistrictOps = option; + + const checkRegistSubdistrictId = await option.find( + (e: any) => e.id === addressData.value.subdistrictId + ); + if (checkRegistSubdistrictId) { + addressData.value.subdistrictId = addressData.value.subdistrictId; + addressData.value.codep = addressData.value.codep; + } else { + addressData.value.subdistrictId = ""; + addressData.value.codep = ""; + } } else { Ops.value.subdistrictCOps = option; OpsFilter.value.subdistrictCOps = option; + + const checkCurrentSubdistrictIdC = await option.find( + (e: any) => e.id === addressData.value.subdistrictIdC + ); + if (checkCurrentSubdistrictIdC) { + addressData.value.subdistrictIdC = addressData.value.subdistrictIdC; + addressData.value.codec = addressData.value.codec; + } else { + addressData.value.subdistrictIdC = ""; + addressData.value.codec = ""; + } } }) .catch((e) => { diff --git a/src/modules/05_placement/components/PersonalDetail/Information/Address.vue b/src/modules/05_placement/components/PersonalDetail/Information/Address.vue index 820acc19c..58c93d330 100644 --- a/src/modules/05_placement/components/PersonalDetail/Information/Address.vue +++ b/src/modules/05_placement/components/PersonalDetail/Information/Address.vue @@ -172,7 +172,7 @@ const editData = async () => { config.API.placementAddressId(route.params.personalId.toString()), body ) - .then((res) => { + .then(() => { success($q, "แก้ไขข้อมูลสำเร็จ"); }) .catch((e) => { @@ -182,7 +182,7 @@ const editData = async () => { edit.value = false; emit("update:statusEdit", false); await getNewData(); - // await props.fetch(); + await props.fetch(); // await fetchProvince(); }); }; @@ -469,7 +469,7 @@ const getClass = (val: boolean) => { />
- { />
- { />
- { class="col-xs-6 col-sm-3 col-md-3" v-if="addressData.registSame == '0'" > - { class="col-xs-6 col-sm-3 col-md-3" v-if="addressData.registSame == '0'" > - { class="col-xs-6 col-sm-3 col-md-3" v-if="addressData.registSame == '0'" > -