ต่อ API

This commit is contained in:
setthawutttty 2024-11-01 17:25:19 +07:00
parent daa78078a2
commit c776d4e7f1
10 changed files with 105 additions and 103 deletions

View file

@ -201,4 +201,6 @@ export default {
`${registryNew}-employee/employment/history/${id}`, `${registryNew}-employee/employment/history/${id}`,
developMentPlan: `${registryNew}/development`, developMentPlan: `${registryNew}/development`,
requestInformationbyType:(type:string,id:string)=>`${registryNew}/request-edit/${type}/${id}`
}; };

View file

@ -2,10 +2,10 @@
import { ref, onMounted, watch } from "vue"; import { ref, onMounted, watch } from "vue";
import { useDataLinkCenter } from "@/modules/04_registryPerson/stores/LinkCenter"; import { useDataLinkCenter } from "@/modules/04_registryPerson/stores/LinkCenter";
import type { RequestAddressObject } from "@/modules/04_registryPerson/interface/request/Address"; import type { RequestregistrationAddressObject } from "@/modules/04_registryPerson/interface/request/Address";
const storeLinkCenter = useDataLinkCenter(); const storeLinkCenter = useDataLinkCenter();
const formDataAddress = defineModel<RequestAddressObject>("formDataAddress", { const formDataAddress = defineModel<RequestregistrationAddressObject>("formDataAddress", {
required: true, required: true,
}); });
const presentAddress = defineModel<string>("presentAddress", { const presentAddress = defineModel<string>("presentAddress", {
@ -18,12 +18,6 @@ const dataLabel = {
registrationDistrict: "เขต/อำเภอ", registrationDistrict: "เขต/อำเภอ",
registrationSubDistrict: "แขวง / ตำบล", registrationSubDistrict: "แขวง / ตำบล",
registrationZipCode: "รหัสไปรษณีย์", registrationZipCode: "รหัสไปรษณีย์",
currentAddress: "ที่อยู่ปัจจุบัน",
currentProvince: "จังหวัด",
currentDistrict: "เขต/อำเภอ",
currentSubDistrict: "แขวง / ตำบล",
currentZipCode: "รหัสไปรษณีย์",
registrationSame: "ที่อยู่ปัจจุบันตรงกับที่อยู่ตามทะเบียนบ้าน",
}; };
/** /**
@ -37,10 +31,6 @@ async function selectProvince(e: string | null, name: string) {
formDataAddress.value.registrationSubDistrictId = ""; formDataAddress.value.registrationSubDistrictId = "";
formDataAddress.value.registrationZipCode = ""; formDataAddress.value.registrationZipCode = "";
formDataAddress.value.registrationDistrictId = ""; formDataAddress.value.registrationDistrictId = "";
} else {
formDataAddress.value.currentSubDistrictId = "";
formDataAddress.value.currentZipCode = "";
formDataAddress.value.currentDistrictId = "";
} }
await storeLinkCenter.fetchDistrict(e, name, true); await storeLinkCenter.fetchDistrict(e, name, true);
} }
@ -56,9 +46,6 @@ async function selectDistrict(e: string | null, name: string) {
if (name == "1") { if (name == "1") {
formDataAddress.value.registrationSubDistrictId = ""; formDataAddress.value.registrationSubDistrictId = "";
formDataAddress.value.registrationZipCode = ""; formDataAddress.value.registrationZipCode = "";
} else {
formDataAddress.value.currentSubDistrictId = "";
formDataAddress.value.currentZipCode = "";
} }
await storeLinkCenter.fetchSubDistrict(e, name, true); await storeLinkCenter.fetchSubDistrict(e, name, true);
} }
@ -81,7 +68,6 @@ function selectSubDistrict(e: string | null, name: string) {
(r) => r.id == e (r) => r.id == e
); );
const namecode = findcode.length > 0 ? findcode[0].zipCode : ""; const namecode = findcode.length > 0 ? findcode[0].zipCode : "";
formDataAddress.value.currentZipCode = namecode;
} }
} }
@ -92,11 +78,6 @@ watch(
() => presentAddress.value, () => presentAddress.value,
(v) => { (v) => {
if (v === "0") { if (v === "0") {
formDataAddress.value.currentAddress = "";
formDataAddress.value.currentProvinceId = "";
formDataAddress.value.currentDistrictId = "";
formDataAddress.value.currentSubDistrictId = "";
formDataAddress.value.currentZipCode = "";
storeLinkCenter.OpsAddress.districtCOps = []; storeLinkCenter.OpsAddress.districtCOps = [];
storeLinkCenter.OpsAddress.subdistrictCOps = []; storeLinkCenter.OpsAddress.subdistrictCOps = [];
} }

View file

@ -7,7 +7,7 @@ import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useDataLinkCenter } from "@/modules/04_registryPerson/stores/LinkCenter"; import { useDataLinkCenter } from "@/modules/04_registryPerson/stores/LinkCenter";
import { useProfileDataStore } from "@/modules/04_registryPerson/stores/profile"; import { useProfileDataStore } from "@/modules/04_registryPerson/stores/profile";
import { useRequestEditStore } from "@/modules/04_registryPerson/stores/RequestEdit";
import type { FormPerson } from "@/modules/04_registryPerson/interface/index/family"; import type { FormPerson } from "@/modules/04_registryPerson/interface/index/family";
import Header from "@/components/DialogHeader.vue"; // popup import Header from "@/components/DialogHeader.vue"; // popup
@ -15,6 +15,7 @@ import Header from "@/components/DialogHeader.vue"; //ส่วนหัว popu
const $q = useQuasar(); const $q = useQuasar();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const storeLinkCenter = useDataLinkCenter(); const storeLinkCenter = useDataLinkCenter();
const storeRequestEdit = useRequestEditStore();
const storeProfile = useProfileDataStore(); const storeProfile = useProfileDataStore();
const { const {
@ -56,30 +57,30 @@ async function closeDialog() {
fatherData.job = ""; fatherData.job = "";
} }
async function onSubmit() { function onSubmit() {
dialogConfirm($q, async () => { dialogConfirm($q, async () => {
const body = { const body = {
profileId: profileId.value,
fatherCitizenId: fatherData.citizenId,
fatherPrefix: fatherData.prefix, fatherPrefix: fatherData.prefix,
fatherFirstName: fatherData.firstName, fatherFirstName: fatherData.firstName,
fatherLastName: fatherData.lastName, fatherLastName: fatherData.lastName,
fatherCareer: fatherData.job, fatherCareer: fatherData.job,
fatherLive: fatherData.isLive === 1 ? true : false, fatherLive: fatherData.isLive === 1 ? true : false,
}; };
showLoader();
http http
.post(config.API.profileFamily("", "father"), body) .patch(
config.API.requestInformationbyType("father", storeRequestEdit.profileId),
body
)
.then(async (res) => { .then(async (res) => {
await upDateStatus(); await upDateStatus();
success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
await props.fetchData?.();
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
hideLoader();
}) })
.finally(() => {}); .finally(() => {
hideLoader();
});
}); });
} }
@ -102,6 +103,7 @@ async function upDateStatus() {
hideLoader(); hideLoader();
}); });
} }
watch( watch(
() => modal.value, () => modal.value,
() => { () => {

View file

@ -7,7 +7,7 @@ import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useDataLinkCenter } from "@/modules/04_registryPerson/stores/LinkCenter"; import { useDataLinkCenter } from "@/modules/04_registryPerson/stores/LinkCenter";
import { useProfileDataStore } from "@/modules/04_registryPerson/stores/profile"; import { useProfileDataStore } from "@/modules/04_registryPerson/stores/profile";
import { useRequestEditStore } from "@/modules/04_registryPerson/stores/RequestEdit";
import type { FormPerson } from "@/modules/04_registryPerson/interface/index/family"; import type { FormPerson } from "@/modules/04_registryPerson/interface/index/family";
import Header from "@/components/DialogHeader.vue"; // popup import Header from "@/components/DialogHeader.vue"; // popup
@ -16,6 +16,8 @@ const $q = useQuasar();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const storeLinkCenter = useDataLinkCenter(); const storeLinkCenter = useDataLinkCenter();
const storeProfile = useProfileDataStore(); const storeProfile = useProfileDataStore();
const storeRequestEdit = useRequestEditStore();
const { const {
showLoader, showLoader,
hideLoader, hideLoader,
@ -55,30 +57,30 @@ async function closeDialog() {
motherData.job = ""; motherData.job = "";
} }
async function onSubmit() { function onSubmit() {
dialogConfirm($q, async () => { dialogConfirm($q, async () => {
const body = { const body = {
profileId: profileId.value,
motherCitizenId: motherData.citizenId,
motherPrefix: motherData.prefix, motherPrefix: motherData.prefix,
motherFirstName: motherData.firstName, motherFirstName: motherData.firstName,
motherLastName: motherData.lastName, motherLastName: motherData.lastName,
motherCareer: motherData.job, motherCareer: motherData.job,
motherLive: motherData.isLive === 1 ? true : false, motherLive: motherData.isLive === 1 ? true : false,
}; };
showLoader();
http http
.post(config.API.profileFamily("", "mother"), body) .patch(
config.API.requestInformationbyType("mother", storeRequestEdit.profileId),
body
)
.then(async (res) => { .then(async (res) => {
await upDateStatus(); await upDateStatus();
success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
await props.fetchData?.();
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
hideLoader();
}) })
.finally(() => {}); .finally(() => {
hideLoader();
});
}); });
} }

View file

@ -7,7 +7,7 @@ import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useDataLinkCenter } from "@/modules/04_registryPerson/stores/LinkCenter"; import { useDataLinkCenter } from "@/modules/04_registryPerson/stores/LinkCenter";
import { useProfileDataStore } from "@/modules/04_registryPerson/stores/profile"; import { useProfileDataStore } from "@/modules/04_registryPerson/stores/profile";
import { useRequestEditStore } from "@/modules/04_registryPerson/stores/RequestEdit";
import type { FormPerson } from "@/modules/04_registryPerson/interface/index/family"; import type { FormPerson } from "@/modules/04_registryPerson/interface/index/family";
import Header from "@/components/DialogHeader.vue"; // popup import Header from "@/components/DialogHeader.vue"; // popup
@ -16,6 +16,8 @@ const $q = useQuasar();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const storeLinkCenter = useDataLinkCenter(); const storeLinkCenter = useDataLinkCenter();
const storeProfile = useProfileDataStore(); const storeProfile = useProfileDataStore();
const storeRequestEdit = useRequestEditStore();
const { const {
showLoader, showLoader,
hideLoader, hideLoader,
@ -59,11 +61,9 @@ async function closeDialog() {
coupleData.statusMarital = ""; coupleData.statusMarital = "";
} }
async function onSubmit() { function onSubmit() {
dialogConfirm($q, async () => { dialogConfirm($q, async () => {
const body = { const body = {
profileId: profileId.value,
coupleCitizenId: coupleData.citizenId,
couplePrefix: coupleData.prefix, couplePrefix: coupleData.prefix,
coupleFirstName: coupleData.firstName, coupleFirstName: coupleData.firstName,
coupleLastName: coupleData.lastName, coupleLastName: coupleData.lastName,
@ -72,19 +72,24 @@ async function onSubmit() {
relationship: coupleData.statusMarital, relationship: coupleData.statusMarital,
coupleLastNameOld: coupleData.lastNameOld, coupleLastNameOld: coupleData.lastNameOld,
}; };
showLoader();
http http
.post(config.API.profileFamily("", "couple"), body) .patch(
config.API.requestInformationbyType(
"couple",
storeRequestEdit.profileId
),
body
)
.then(async (res) => { .then(async (res) => {
await upDateStatus(); await upDateStatus();
success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog();
await props.fetchData?.();
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
hideLoader();
}) })
.finally(() => {}); .finally(() => {
hideLoader();
});
}); });
} }

View file

@ -8,8 +8,9 @@ import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useLinkageStore } from "@/stores/linkage"; import { useLinkageStore } from "@/stores/linkage";
import { useDataLinkCenter } from "@/modules/04_registryPerson/stores/LinkCenter"; 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 { RequestObject } from "@/modules/04_registryPerson/interface/request/Profile";
import type { import type {
FormPerson, FormPerson,
@ -27,6 +28,7 @@ const profileId = defineModel<string>("profileId", { required: true }); //id บ
const $q = useQuasar(); const $q = useQuasar();
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const storeLinkage = useLinkageStore(); const storeLinkage = useLinkageStore();
const storeRequestEdit = useRequestEditStore();
const storeLinkCenter = useDataLinkCenter(); const storeLinkCenter = useDataLinkCenter();
const { const {
showLoader, showLoader,
@ -62,13 +64,7 @@ const formInformations = reactive<RequestObject>({
rank: null, rank: null,
}); });
const formDataAddress = reactive<RequestAddressObject>({ const formDataAddress = reactive<RequestregistrationAddressObject>({
currentZipCode: "",
currentSubDistrictId: "",
currentDistrictId: "",
currentProvinceId: "",
currentAddress: "",
registrationZipCode: "", registrationZipCode: "",
registrationSubDistrictId: "", registrationSubDistrictId: "",
registrationDistrictId: "", registrationDistrictId: "",
@ -114,12 +110,6 @@ async function upDateInfomation() {
/** อัพเดตข้อมูลที่อยู่ */ /** อัพเดตข้อมูลที่อยู่ */
async function upDateAddress() { async function upDateAddress() {
if (presentAddress.value === "1") { 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.districtCOps =
storeLinkCenter.OpsAddress.districtOps; storeLinkCenter.OpsAddress.districtOps;
storeLinkCenter.OpsAddress.subdistrictCOps = storeLinkCenter.OpsAddress.subdistrictCOps =
@ -162,16 +152,40 @@ async function upDateStatus() {
/** อัพเดตข้อมูล */ /** อัพเดตข้อมูล */
function onSubmit() { function onSubmit() {
dialogConfirm($q, async () => { 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(); showLoader();
await upDateInfomation(); http
await upDateAddress(); .patch(
if (count.value == 2) { config.API.requestInformationbyType("myprofile", storeRequestEdit.profileId),
await upDateStatus(); body
success($q, "บันทึกข้อมูลสำเร็จ"); )
closeDialog(); .then(async (res) => {
await props.fetchData?.(); await upDateStatus();
} })
hideLoader(); .catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}); });
} }
@ -243,11 +257,6 @@ async function amiRequest() {
formDataAddress.registrationSubDistrictId = formDataAddress.registrationSubDistrictId =
data.value.registrationSubDistrictId; data.value.registrationSubDistrictId;
formDataAddress.registrationZipCode = data.value.registrationZipCode; 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( watch(
@ -272,21 +281,11 @@ watch(
"1", "1",
false false
); );
storeLinkCenter.fetchDistrict(
formDataAddress.currentProvinceId,
"2",
false
);
storeLinkCenter.fetchSubDistrict( storeLinkCenter.fetchSubDistrict(
formDataAddress.registrationDistrictId, formDataAddress.registrationDistrictId,
"1", "1",
false false
); );
storeLinkCenter.fetchSubDistrict(
formDataAddress.currentDistrictId,
"2",
false
);
} }
hideLoader(); hideLoader();

View file

@ -180,6 +180,7 @@ function filterOption(val: string, update: Function) {
*/ */
function onclickEdit(data: Request) { function onclickEdit(data: Request) {
requestId.value = data.id; requestId.value = data.id;
store.profileId = data.profileId;
router.push(`/registry-officer/request-edit/personal/${data.id}`); router.push(`/registry-officer/request-edit/personal/${data.id}`);
} }

View file

@ -234,7 +234,7 @@ onMounted(async () => {
<template> <template>
<div class="q-gutter-sm q-pa-sm"> <div class="q-gutter-sm q-pa-sm">
<div class="toptitle text-dark row items-center q-py-xs"> <div class="toptitle text-dark row items-center q-py-xs ">
<q-btn <q-btn
icon="mdi-arrow-left" icon="mdi-arrow-left"
unelevated unelevated
@ -246,19 +246,19 @@ onMounted(async () => {
@click="router.go(-1)" @click="router.go(-1)"
/> />
รายละเอยดคำรองขอแกไขทะเบยนประวของ{{ dataRequest.fullname }} รายละเอยดคำรองขอแกไขทะเบยนประวของ{{ dataRequest.fullname }}
<q-space />
<q-btn
v-if="
workflowRef?.permission.isUpdate &&
topicConvert(dataRequest.topic) !== ''
"
color="public"
:label="topicConvert(dataRequest.topic)"
@click="onUpdate(dataRequest)"
>
<q-tooltip>{{ topicConvert(dataRequest.topic) }}</q-tooltip>
</q-btn>
</div> </div>
<q-space />
<q-btn
v-if="
workflowRef?.permission.isUpdate &&
topicConvert(dataRequest.topic) !== ''
"
color="public"
:label="topicConvert(dataRequest.topic)"
@click="onUpdate(dataRequest)"
>
<q-tooltip>{{ topicConvert(dataRequest.topic) }}</q-tooltip>
</q-btn>
<q-card> <q-card>
<q-card-section> <q-card-section>

View file

@ -24,4 +24,12 @@ interface RequestAddressObject {
registrationAddress: string | null; registrationAddress: string | null;
} }
export type { RequestObject ,RequestAddressObject}; interface RequestregistrationAddressObject {
registrationZipCode: string | null;
registrationSubDistrictId: string | null;
registrationDistrictId: string | null;
registrationProvinceId: string | null;
registrationAddress: string | null;
}
export type { RequestObject ,RequestAddressObject,RequestregistrationAddressObject};

View file

@ -3,6 +3,7 @@ import { ref } from "vue";
import type { DataOption } from "@/modules/04_registryPerson/interface/index/Main"; import type { DataOption } from "@/modules/04_registryPerson/interface/index/Main";
export const useRequestEditStore = defineStore("requestEditStore", () => { export const useRequestEditStore = defineStore("requestEditStore", () => {
const profileId = ref<string>('')
const optionTopic = ref<string[]>([ const optionTopic = ref<string[]>([
"ขอแก้ไขคำนำหน้านาม ชื่อ นามสกุล", "ขอแก้ไขคำนำหน้านาม ชื่อ นามสกุล",
"ขอแก้ไขรูปภาพประจำตัว", "ขอแก้ไขรูปภาพประจำตัว",
@ -58,5 +59,6 @@ export const useRequestEditStore = defineStore("requestEditStore", () => {
optionStatus, optionStatus,
optionStatusIDP, optionStatusIDP,
convertStatusIDP, convertStatusIDP,
profileId
}; };
}); });