ปรับ ข้อมูลที่อยู่

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-10-12 11:32:13 +07:00
parent 6707bfef8c
commit 8e5dfc1a02
2 changed files with 88 additions and 17 deletions

View file

@ -31,7 +31,7 @@
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -57,7 +57,7 @@
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -83,7 +83,7 @@
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -163,7 +163,7 @@
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3" v-if="addressData.same == '0'">
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -189,7 +189,7 @@
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3" v-if="addressData.same == '0'">
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -215,7 +215,7 @@
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3" v-if="addressData.same == '0'">
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -799,7 +799,7 @@ const fetchProvince = async () => {
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) => {

View file

@ -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) => {
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -495,7 +495,7 @@ const getClass = (val: boolean) => {
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -521,7 +521,7 @@ const getClass = (val: boolean) => {
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -604,7 +604,7 @@ const getClass = (val: boolean) => {
class="col-xs-6 col-sm-3 col-md-3"
v-if="addressData.registSame == '0'"
>
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -633,7 +633,7 @@ const getClass = (val: boolean) => {
class="col-xs-6 col-sm-3 col-md-3"
v-if="addressData.registSame == '0'"
>
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"
@ -662,7 +662,7 @@ const getClass = (val: boolean) => {
class="col-xs-6 col-sm-3 col-md-3"
v-if="addressData.registSame == '0'"
>
<selector
<q-select
:hide-dropdown-icon="!edit"
hide-bottom-space
:class="getClass(edit)"