From 16c916f26e912bdfbaa65758ccf7ba5eddb29eca Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 29 Apr 2025 14:14:57 +0700 Subject: [PATCH] =?UTF-8?q?popup=20=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A?= =?UTF-8?q?=E0=B8=B5=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Dialogs/PopupPersonalNew.vue | 231 ++++++++++++++++-- .../interface/response/Government.ts | 15 +- 2 files changed, 226 insertions(+), 20 deletions(-) diff --git a/src/components/Dialogs/PopupPersonalNew.vue b/src/components/Dialogs/PopupPersonalNew.vue index c83c16196..3eb4c7f02 100644 --- a/src/components/Dialogs/PopupPersonalNew.vue +++ b/src/components/Dialogs/PopupPersonalNew.vue @@ -8,7 +8,10 @@ import { checkPermissionGet } from "@/utils/permissions"; /** importType*/ import type { PersonalImformation } from "@/components/information/interface/response/Information"; -import type { Goverment } from "@/components/information/interface/response/Government"; +import type { + Goverment, + GovermentEmpTemp, +} from "@/components/information/interface/response/Government"; import type { Avatar } from "@/components/information/interface/response/avatar"; /** importStore*/ @@ -74,6 +77,24 @@ const goverment = reactive({ dateRetireLaw: "", }); +const govermentTemp = reactive({ + positionEmployeeGroupId: "", + positionEmployeeLineId: "", + positionEmployeePositionId: "", + employeeOc: "", + employeeTypeIndividual: "", + employeeWage: "", + employeeMoneyIncrease: "", + employeeMoneyAllowance: "", + employeeMoneyEmployee: "", + employeeMoneyEmployer: "", +}); + +/** + * function คำนวนอายุ + * @param birthDate วันเดือนปีเกิด + * @returns อายุ + */ function calculateAge(birthDate: Date | null) { if (!birthDate) return null; const birthDateTimeStamp = new Date(birthDate).getTime(); @@ -130,11 +151,19 @@ async function fetchInformation(id: string) { avatar.fullname = `${data.prefix}${data.firstName} ${data.lastName}`; avatar.position = data.position ? data.position : "-"; + //ถ้ามีรูปเรียก Function fetchProfile เรียกข้อมูลรูปโปรไฟล์ if (data.avatarName) { await fetchProfile(data.id as string, data.avatarName); } else { avatar.avatar = ""; } + + if (props.id) { + // employeeClass.value === "TEMP" เรียกข้อมูลลูกจ้างชั่วคราว ไม่ใช่ เรียกข้อมูลข้อมูลราชการ + employeeClass.value === "TEMP" + ? await fetchProfileGovTemp(props.id) + : await fetchProfileGov(props.id); + } }) .catch((err) => { messageError($q, err); @@ -149,7 +178,6 @@ async function fetchInformation(id: string) { * @param id profileID */ async function fetchProfileGov(id: string) { - showLoader(); await http .get( config.API.profileNewGovernmentCard( @@ -184,9 +212,45 @@ async function fetchProfileGov(id: string) { .catch((err) => { messageError($q, err); + }); +} + +/** + * function fetch ข้อมูลลูกจ้างชั่วคราว + * @param id profileID + */ +async function fetchProfileGovTemp(id: string) { + await http + .get(config.API.informationEmployee(id)) + .then((res) => { + const data = res.data.result; + govermentTemp.positionEmployeeGroupId = data.positionEmployeeGroupId; + govermentTemp.positionEmployeeLineId = data.positionEmployeeLineId; + govermentTemp.positionEmployeePositionId = + data.positionEmployeePositionId; + govermentTemp.employeeOc = data.employeeOc; + govermentTemp.employeeTypeIndividual = data.employeeTypeIndividual; + govermentTemp.employeeWage = data.employeeWage; + govermentTemp.employeeMoneyIncrease = data.employeeMoneyIncrease; + govermentTemp.employeeMoneyAllowance = data.employeeMoneyAllowance; + govermentTemp.employeeMoneyEmployee = data.employeeMoneyEmployee; + govermentTemp.employeeMoneyEmployer = data.employeeMoneyEmployer; }) - .finally(() => { - hideLoader(); + .catch((err) => { + messageError($q, err); + }); +} + +/** + * function เรียกไฟล์รูป + * @param id profileID + * @param avatarName ชื่อไฟล์ + */ +async function fetchProfile(id: string, avatarName: string) { + await http + .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName)) + .then(async (res) => { + avatar.avatar = await res.data.downloadUrl; }); } @@ -215,10 +279,7 @@ watch( ? "employee" : "officer"; - await Promise.all([ - fetchInformation(props.id), - fetchProfileGov(props.id), - ]); + await fetchInformation(props.id); } } } @@ -229,14 +290,6 @@ watch(modal, (newValue) => { emit("update:modal", false); } }); - -async function fetchProfile(id: string, avatarName: string) { - await http - .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName)) - .then(async (res) => { - avatar.avatar = await res.data.downloadUrl; - }); -}