diff --git a/src/modules/04_registryPerson/components/Dialog/01_Information.vue b/src/modules/04_registryPerson/components/Dialog/01_Information.vue new file mode 100644 index 000000000..70b8f6755 --- /dev/null +++ b/src/modules/04_registryPerson/components/Dialog/01_Information.vue @@ -0,0 +1,364 @@ + + diff --git a/src/modules/04_registryPerson/components/Dialog/02_Address.vue b/src/modules/04_registryPerson/components/Dialog/02_Address.vue new file mode 100644 index 000000000..3c49fe27d --- /dev/null +++ b/src/modules/04_registryPerson/components/Dialog/02_Address.vue @@ -0,0 +1,325 @@ + + diff --git a/src/modules/04_registryPerson/components/Dialog/03_Family.vue b/src/modules/04_registryPerson/components/Dialog/03_Family.vue new file mode 100644 index 000000000..a34c53fa4 --- /dev/null +++ b/src/modules/04_registryPerson/components/Dialog/03_Family.vue @@ -0,0 +1,571 @@ + + diff --git a/src/modules/04_registryPerson/components/Dialog/DialogUpdate.vue b/src/modules/04_registryPerson/components/Dialog/DialogUpdate.vue new file mode 100644 index 000000000..5281e2bde --- /dev/null +++ b/src/modules/04_registryPerson/components/Dialog/DialogUpdate.vue @@ -0,0 +1,482 @@ + + + diff --git a/src/modules/04_registryPerson/components/requestEdit/01_TabInformation.vue b/src/modules/04_registryPerson/components/requestEdit/01_TabInformation.vue index b2890d17f..006088263 100644 --- a/src/modules/04_registryPerson/components/requestEdit/01_TabInformation.vue +++ b/src/modules/04_registryPerson/components/requestEdit/01_TabInformation.vue @@ -17,12 +17,15 @@ import type { DateRequest } from "@/modules/04_registryPerson/interface/response /** importComponents*/ import DialogStatus from "@/modules/04_registryPerson/components/requestEdit/Dialog01_EditStatus.vue"; +import DialogUpdate from "@/modules/04_registryPerson/components/Dialog/DialogUpdate.vue"; const $q = useQuasar(); const store = useRequestEditStore(); const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin(); //Table +const idCard = ref(""); +const profileId = ref(""); const rows = ref([]); //รายการข้อมูลคำร้องขอแก้ไขทะเบียนประวัติ const page = ref(1); //หน้า const pageSize = ref(10); //จำนวนต่อหน้า @@ -113,6 +116,7 @@ const status = ref("PENDING"); //ค้นหาตามสถานะ const keyword = ref(""); //คำค้นหา const statusOption = ref(store.optionStatus); //รายการสถานะ const modalStatus = ref(false); //แก้ไขสถานะคำร้อง +const modalUpdate = ref(false); //อัปเดตข้อมูลจากกรมการปกครอง const requestId = ref(""); //id รายการแก้ไข /** function fetch รายการคำร้องขอแก้ไขทะเบียนประวัติ*/ @@ -172,9 +176,15 @@ function filterOption(val: string, update: Function) { * funciton แก่ไขคำร้อง * @param id รายการคำร้อง */ -function onclickEdit(id: string) { - modalStatus.value = true; - requestId.value = id; +function onclickEdit(data: any) { + requestId.value = data.id; + if (data.topic == "ขออัปเดตข้อมูลจากกรมการปกครอง") { + modalUpdate.value = true; + idCard.value = data.idcard as string; + profileId.value = data.profileId; + } else { + modalStatus.value = true; + } } /** @@ -336,14 +346,26 @@ onMounted(() => { - {{props.row.topic == 'ขออัปเดตข้อมูลจากกรมการปกครอง' ? 'ขออัปเดตข้อมูลจากกรมการปกครอง':'แก้ไขสถานะคำร้อง'}} + {{ + props.row.topic == "ขออัปเดตข้อมูลจากกรมการปกครอง" + ? "ขออัปเดตข้อมูลจากกรมการปกครอง" + : "แก้ไขสถานะคำร้อง" + }} @@ -388,6 +410,14 @@ onMounted(() => { :fetch-data="fetchListRequset" :request-id="requestId" /> + + diff --git a/src/modules/04_registryPerson/interface/request/Address.ts b/src/modules/04_registryPerson/interface/request/Address.ts index 4b2136838..45d8656e4 100644 --- a/src/modules/04_registryPerson/interface/request/Address.ts +++ b/src/modules/04_registryPerson/interface/request/Address.ts @@ -11,4 +11,17 @@ interface RequestObject { registrationAddress: string | null; } -export type { RequestObject }; +interface RequestAddressObject { + currentZipCode: string | null; + currentSubDistrictId: string | null; + currentDistrictId: string | null; + currentProvinceId: string | null; + currentAddress: string | null; + registrationZipCode: string | null; + registrationSubDistrictId: string | null; + registrationDistrictId: string | null; + registrationProvinceId: string | null; + registrationAddress: string | null; +} + +export type { RequestObject ,RequestAddressObject}; diff --git a/src/modules/04_registryPerson/interface/response/Main.ts b/src/modules/04_registryPerson/interface/response/Main.ts index 95f0abf69..370eaee4e 100644 --- a/src/modules/04_registryPerson/interface/response/Main.ts +++ b/src/modules/04_registryPerson/interface/response/Main.ts @@ -37,6 +37,8 @@ interface DateRequest { remark: string; status: string; topic: string; + profileId?: string; + idcard?: string; } interface DataProfile { diff --git a/src/modules/04_registryPerson/stores/LinkCenter.ts b/src/modules/04_registryPerson/stores/LinkCenter.ts new file mode 100644 index 000000000..4b2f2409f --- /dev/null +++ b/src/modules/04_registryPerson/stores/LinkCenter.ts @@ -0,0 +1,352 @@ +import { ref } from "vue"; +import { defineStore } from "pinia"; +import { useCounterMixin } from "@/stores/mixin"; +import { useQuasar } from "quasar"; +import http from "@/plugins/http"; +import config from "@/app.config"; + +import type { RequestObject } from "@/modules/04_registryPerson/interface/request/Address"; +import type { ResponseObject } from "@/modules/04_registryPerson/interface/response/Address"; + +import type { + DataOption, + AddressOps, + InformationOps, + zipCodeOption, +} from "@/modules/04_registryPerson/interface/index/Main"; + +const $q = useQuasar(); +const mixin = useCounterMixin(); +const { + showLoader, + hideLoader, + + messageError, +} = mixin; + +export const useDataLinkCenter = defineStore("DataLinkCenter", () => { + const retireDate = ref(); + const optionRelationshipMain = ref([]); + const optionRelationship = ref([]); + //รายการตัวเลือก + const OpsPerson = ref({ + prefixOps: [], + rankOps: [], + genderOps: [], + bloodOps: [], + statusOps: [], + religionOps: [], + employeeClassOps: [ + { id: "perm", name: "ลูกจ้างประจำ" }, + { id: "temp", name: "ลูกจ้างชั่วคราว" }, + ], + employeeTypeOps: [ + { id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" }, + { id: "bkk", name: "งบประมาณกรุงเทพมหานคร" }, + ], + }); + + //ข้อมูลตัวเลือก + const OpsPersonFilter = ref({ + prefixOps: [], + rankOps: [], + genderOps: [], + bloodOps: [], + statusOps: [], + religionOps: [], + employeeClassOps: [ + { id: "perm", name: "ลูกจ้างประจำ" }, + { id: "temp", name: "ลูกจ้างชั่วคราว" }, + ], + employeeTypeOps: [ + { id: "gov", name: "งบประมาณเงินอุดหนุนรัฐบาล" }, + { id: "bkk", name: "งบประมาณกรุงเทพมหานคร" }, + ], + }); + + const OpsAddress = ref({ + provinceOps: [], + districtOps: [], + districtCOps: [], + subdistrictOps: [], + subdistrictCOps: [], + }); + const OpsAddressFilter = ref({ + provinceOps: [], + districtOps: [], + districtCOps: [], + subdistrictOps: [], + subdistrictCOps: [], + }); + + /** + * ฟังก์ชันคำนวนอายุด้วยวันเดิอนปีเกิด + * @param birthDate วันเกิด + * @returns อายุ + */ + function calculateAge(birthDate: Date | null) { + if (!birthDate) return null; + const birthDateTimeStamp = new Date(birthDate).getTime(); + const now = new Date(); + const diff = now.getTime() - birthDateTimeStamp; + + const ageDate = new Date(diff); + const years = ageDate.getUTCFullYear() - 1970; + const months = ageDate.getUTCMonth(); + const days = ageDate.getUTCDate() - 1; + const retire = new Date(birthDate); + retire.setFullYear(retire.getFullYear() + 60); + retireDate.value = retire; + + if (years > 60) { + return "อายุเกิน 60 ปี"; + } + + return `${years} ปี ${months} เดือน ${days} วัน`; + } + + /** + * ฟังก์ชันดึงข้อมูลตัวเลือกข้อมูลหลัก + */ + async function fetchPerson() { + await http + .get(config.API.profileNewMetaMain) + .then((res) => { + const data = res.data.result; + let optionbloodGroups: DataOption[] = []; + data.bloodGroups.map((r: any) => { + optionbloodGroups.push({ + id: r.id.toString(), + name: r.name.toString(), + }); + }); + OpsPerson.value.bloodOps = optionbloodGroups; + OpsPersonFilter.value.bloodOps = optionbloodGroups; + + let optiongenders: DataOption[] = []; + data.genders.map((r: any) => { + optiongenders.push({ + id: r.id.toString(), + name: r.name.toString(), + }); + }); + OpsPerson.value.genderOps = optiongenders; + OpsPersonFilter.value.genderOps = optiongenders; + + let optionprefixs: DataOption[] = []; + data.prefixs.map((r: any) => { + optionprefixs.push({ + id: r.id.toString(), + name: r.name.toString(), + }); + }); + OpsPerson.value.prefixOps = optionprefixs; + OpsPersonFilter.value.prefixOps = optionprefixs; + + let optionrank: DataOption[] = []; + data.rank.map((r: any) => { + optionrank.push({ + id: r.id.toString(), + name: r.name.toString(), + }); + }); + OpsPerson.value.rankOps = optionrank; + OpsPersonFilter.value.rankOps = optionrank; + + let optionrelationships: DataOption[] = []; + data.relationships.map((r: any) => { + optionrelationships.push({ + id: r.id.toString(), + name: r.name.toString(), + }); + }); + OpsPerson.value.statusOps = optionrelationships; + OpsPersonFilter.value.statusOps = optionrelationships; + + let optionreligions: DataOption[] = []; + data.religions.map((r: any) => { + optionreligions.push({ + id: r.id.toString(), + name: r.name.toString(), + }); + }); + OpsPerson.value.religionOps = optionreligions; + OpsPersonFilter.value.religionOps = optionreligions; + }) + .catch((e) => { + messageError($q, e); + hideLoader(); + }) + .finally(() => {}); + } + + /** -----(จังหวัด-อำเภอ-ตำบล)----- */ + /** + * ฟังก์ชันดึงข้อมูลจังหวัด + */ + async function fetchProvince(isLoad?: boolean) { + isLoad && showLoader(); + await http + .get(config.API.profileNewProvince) + .then(async (res) => { + const data = res.data.result; + let option: DataOption[] = []; + data.map((r: any) => { + option.push({ id: r.id.toString(), name: r.name.toString() }); + }); + OpsAddress.value.provinceOps = option; + OpsAddressFilter.value.provinceOps = option; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + isLoad && hideLoader(); + }); + } + + /** + * ฟังก์ชันดึงข้อมูล เขต / อำเภอ + * @param id จังหวัด + * @param position ที่อยู่ตามทะเบียนบ้าน, ที่อยู่ปัจจุบัน + */ + async function fetchDistrict( + id: string | null, + position: string, + isLoad?: boolean + ) { + if (!id) return; + isLoad && showLoader(); + await http + .get(config.API.profileNewDistrictByPId(id)) + .then(async (res) => { + const data = res.data.result; + let option: DataOption[] = []; + data.districts.map((r: any) => { + option.push({ id: r.id, name: r.name }); + }); + if (position == "1") { + OpsAddress.value.districtOps = option; + OpsAddressFilter.value.districtOps = option; + } else { + OpsAddress.value.districtCOps = option; + OpsAddressFilter.value.districtCOps = option; + } + return option; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + isLoad && hideLoader(); + }); + } + + /** + * ฟังก์ชันดึงข้อมูล แขวง / ตำบล + * @param id เขต / อำเภอ + * @param position ที่อยู่ตามทะเบียนบ้าน, ที่อยู่ปัจจุบัน + */ + async function fetchSubDistrict( + id: string | null, + position: string, + isLoad: boolean + ) { + if (!id) return; + isLoad && showLoader(); + await http + .get(config.API.profileNewSubDistrictByDId(id)) + .then(async (res) => { + const data = res.data.result; + let option: zipCodeOption[] = []; + data.subDistricts.map((r: any) => { + option.push({ + id: r.id, + name: r.name, + zipCode: r.zipCode, + }); + }); + if (position == "1") { + OpsAddressFilter.value.subdistrictOps = option; + OpsAddress.value.subdistrictOps = option; + } else { + OpsAddressFilter.value.subdistrictCOps = option; + OpsAddress.value.subdistrictCOps = option; + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + isLoad && hideLoader(); + }); + } + + /** + * ฟังกชันค้นหาข้อมูลใน select + * @param val คำที่ต้องการค้นหา + * @param update function + * @param refData ประเภทตัวเลือก + */ + function filterSelector(val: any, update: Function, refData: string) { + switch (refData) { + case "provinceOps": + update(() => { + OpsAddress.value.provinceOps = + OpsAddressFilter.value.provinceOps.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + case "districtOps": + update(() => { + OpsAddress.value.districtOps = + OpsAddressFilter.value.districtOps.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + case "districtCOps": + update(() => { + OpsAddress.value.districtCOps = + OpsAddressFilter.value.districtCOps.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + case "subdistrictOps": + update(() => { + OpsAddress.value.subdistrictOps = + OpsAddressFilter.value.subdistrictOps.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + case "subdistrictCOps": + update(() => { + OpsAddress.value.subdistrictCOps = + OpsAddressFilter.value.subdistrictCOps.filter( + (v: DataOption) => v.name.indexOf(val) > -1 + ); + }); + break; + + default: + break; + } + } + return { + fetchPerson, + OpsPersonFilter, + OpsPerson, + OpsAddress, + OpsAddressFilter, + calculateAge, + fetchProvince, + filterSelector, + fetchDistrict, + fetchSubDistrict, + optionRelationshipMain, + optionRelationship, + }; +}); diff --git a/src/modules/05_placement/components/PersonalDetail/DialogCheckInformation.vue b/src/modules/05_placement/components/PersonalDetail/DialogCheckInformation.vue index 5c22cb8b4..578c91eb3 100644 --- a/src/modules/05_placement/components/PersonalDetail/DialogCheckInformation.vue +++ b/src/modules/05_placement/components/PersonalDetail/DialogCheckInformation.vue @@ -205,7 +205,7 @@ async function amiRequest() { formInformations.prefixId = data.value.titleName; formInformations.fullName = data.value.fullnameAndRank; formInformations.firstname = data.value.firstName; - formInformations.lastname = data.value.lastname; + formInformations.lastname = data.value.lastName; formInformations.nationality = data.value.nationalityDesc; formInformations.race = props.InformationData.race; formInformations.dateOfBirth = data.value.dateOfBirth; @@ -296,7 +296,7 @@ async function upDateInfomation() { } /** - * ฟังก์ชันบันทึกการแก้ไข + * อัพเดตข้อมูลที่อยู่ */ async function upDateAddress() { const body = { @@ -340,6 +340,7 @@ async function upDateAddress() { .finally(() => {}); } +/** อัพเดตข้อมูลครอบครัว */ async function upDateFamily() { const body = { couple: familyData.value.couple == "1", diff --git a/src/stores/linkage.ts b/src/stores/linkage.ts index f19415443..930a045ec 100644 --- a/src/stores/linkage.ts +++ b/src/stores/linkage.ts @@ -2,7 +2,7 @@ import { ref } from "vue"; import { defineStore } from "pinia"; import { useCounterMixin } from "./mixin"; -const { messageError, success } = useCounterMixin(); +const { messageError, success,hideLoader } = useCounterMixin(); export const useLinkageStore = defineStore("linkageData", () => { const apiURL = ref("http://127.0.0.1:51548"); // API URL From Agent @@ -248,21 +248,21 @@ export const useLinkageStore = defineStore("linkageData", () => { message = `${code}${T}${officeCode.value}${versionCode.value}${serviceCode}${idcard}`; } - fetch(`${apiURL.value}/ami/request`, { + await fetch(`${apiURL.value}/ami/request`, { method: "POST", headers: { "Content-type": "application/json; charset=UTF-8" }, body: JSON.stringify({ message: message, }), }) - .then((response) => { + .then(async (response) => { if (response.ok) { return response.json(); } throw new Error("Something went wrong"); }) .then(async (data) => { - const convertData = await bin2String(data); + const convertData = bin2String(await data); let removeText = await convertData.substr(9); // ตัด CODEREQ[4] + Status[5] if (code === 9080) { @@ -277,6 +277,7 @@ export const useLinkageStore = defineStore("linkageData", () => { }) .catch(async (error) => { messageError(q, error); + hideLoader() }); }