ต่อ API
This commit is contained in:
parent
daa78078a2
commit
c776d4e7f1
10 changed files with 105 additions and 103 deletions
|
|
@ -8,8 +8,9 @@ import config from "@/app.config";
|
|||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useLinkageStore } from "@/stores/linkage";
|
||||
import { useDataLinkCenter } from "@/modules/04_registryPerson/stores/LinkCenter";
|
||||
import { useRequestEditStore } from "@/modules/04_registryPerson/stores/RequestEdit";
|
||||
|
||||
import type { RequestAddressObject } from "@/modules/04_registryPerson/interface/request/Address";
|
||||
import type { RequestregistrationAddressObject } from "@/modules/04_registryPerson/interface/request/Address";
|
||||
import type { RequestObject } from "@/modules/04_registryPerson/interface/request/Profile";
|
||||
import type {
|
||||
FormPerson,
|
||||
|
|
@ -27,6 +28,7 @@ const profileId = defineModel<string>("profileId", { required: true }); //id บ
|
|||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const storeLinkage = useLinkageStore();
|
||||
const storeRequestEdit = useRequestEditStore();
|
||||
const storeLinkCenter = useDataLinkCenter();
|
||||
const {
|
||||
showLoader,
|
||||
|
|
@ -62,13 +64,7 @@ const formInformations = reactive<RequestObject>({
|
|||
rank: null,
|
||||
});
|
||||
|
||||
const formDataAddress = reactive<RequestAddressObject>({
|
||||
currentZipCode: "",
|
||||
currentSubDistrictId: "",
|
||||
currentDistrictId: "",
|
||||
currentProvinceId: "",
|
||||
currentAddress: "",
|
||||
|
||||
const formDataAddress = reactive<RequestregistrationAddressObject>({
|
||||
registrationZipCode: "",
|
||||
registrationSubDistrictId: "",
|
||||
registrationDistrictId: "",
|
||||
|
|
@ -114,12 +110,6 @@ async function upDateInfomation() {
|
|||
/** อัพเดตข้อมูลที่อยู่ */
|
||||
async function upDateAddress() {
|
||||
if (presentAddress.value === "1") {
|
||||
formDataAddress.currentAddress = formDataAddress.registrationAddress;
|
||||
formDataAddress.currentProvinceId = formDataAddress.registrationProvinceId;
|
||||
formDataAddress.currentDistrictId = formDataAddress.registrationDistrictId;
|
||||
formDataAddress.currentSubDistrictId =
|
||||
formDataAddress.registrationSubDistrictId;
|
||||
formDataAddress.currentZipCode = formDataAddress.registrationZipCode;
|
||||
storeLinkCenter.OpsAddress.districtCOps =
|
||||
storeLinkCenter.OpsAddress.districtOps;
|
||||
storeLinkCenter.OpsAddress.subdistrictCOps =
|
||||
|
|
@ -162,16 +152,40 @@ async function upDateStatus() {
|
|||
/** อัพเดตข้อมูล */
|
||||
function onSubmit() {
|
||||
dialogConfirm($q, async () => {
|
||||
const body = {
|
||||
registrationZipCode: formDataAddress.registrationZipCode,
|
||||
registrationSubDistrictId: formDataAddress.registrationSubDistrictId,
|
||||
registrationDistrictId: formDataAddress.registrationDistrictId,
|
||||
registrationProvinceId: formDataAddress.registrationProvinceId,
|
||||
registrationAddress: formDataAddress.registrationAddress,
|
||||
|
||||
bloodGroup: formInformations.bloodGroup,
|
||||
relationship: formInformations.relationship,
|
||||
gender: formInformations.gender,
|
||||
religion: formInformations.religion,
|
||||
nationality: formInformations.nationality,
|
||||
ethnicity: formInformations.ethnicity,
|
||||
birthDate: formInformations.birthDate,
|
||||
lastName: formInformations.lastName,
|
||||
firstName: formInformations.firstName,
|
||||
prefix: formInformations.prefix,
|
||||
rank: formInformations.rank,
|
||||
};
|
||||
showLoader();
|
||||
await upDateInfomation();
|
||||
await upDateAddress();
|
||||
if (count.value == 2) {
|
||||
await upDateStatus();
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
closeDialog();
|
||||
await props.fetchData?.();
|
||||
}
|
||||
hideLoader();
|
||||
http
|
||||
.patch(
|
||||
config.API.requestInformationbyType("myprofile", storeRequestEdit.profileId),
|
||||
body
|
||||
)
|
||||
.then(async (res) => {
|
||||
await upDateStatus();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -243,11 +257,6 @@ async function amiRequest() {
|
|||
formDataAddress.registrationSubDistrictId =
|
||||
data.value.registrationSubDistrictId;
|
||||
formDataAddress.registrationZipCode = data.value.registrationZipCode;
|
||||
formDataAddress.currentAddress = data.value.currentAddress;
|
||||
formDataAddress.currentProvinceId = data.value.currentProvinceId;
|
||||
formDataAddress.currentDistrictId = data.value.currentDistrictId;
|
||||
formDataAddress.currentSubDistrictId = data.value.currentSubDistrictId;
|
||||
formDataAddress.currentZipCode = data.value.currentZipCode;
|
||||
}
|
||||
|
||||
watch(
|
||||
|
|
@ -272,21 +281,11 @@ watch(
|
|||
"1",
|
||||
false
|
||||
);
|
||||
storeLinkCenter.fetchDistrict(
|
||||
formDataAddress.currentProvinceId,
|
||||
"2",
|
||||
false
|
||||
);
|
||||
storeLinkCenter.fetchSubDistrict(
|
||||
formDataAddress.registrationDistrictId,
|
||||
"1",
|
||||
false
|
||||
);
|
||||
storeLinkCenter.fetchSubDistrict(
|
||||
formDataAddress.currentDistrictId,
|
||||
"2",
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
hideLoader();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue