From 0a385408f2f5b515ceae8b8e1a8c7f8958c59e3a Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 29 Jul 2025 11:39:42 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=20Skeleton?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RoleOrganization/DialogPersonal.vue | 125 ++++++++++-------- 1 file changed, 69 insertions(+), 56 deletions(-) diff --git a/src/modules/02_users/components/RoleOrganization/DialogPersonal.vue b/src/modules/02_users/components/RoleOrganization/DialogPersonal.vue index 7077acc7..28740568 100644 --- a/src/modules/02_users/components/RoleOrganization/DialogPersonal.vue +++ b/src/modules/02_users/components/RoleOrganization/DialogPersonal.vue @@ -15,12 +15,10 @@ import type { Avatar } from "@/components/information/interface/response/avatar" import { useCounterMixin } from "@/stores/mixin"; /** use*/ -const route = useRoute(); + const mixin = useCounterMixin(); -const router = useRouter(); const $q = useQuasar(); -const retireDate = ref(); -const { showLoader, hideLoader, messageError, date2Thai } = mixin; +const { messageError, date2Thai } = mixin; const isEmployee = defineModel("isEmployee", { type: String }); const empType = ref("officer"); @@ -42,6 +40,9 @@ const emit = defineEmits(["update:modal"]); /** ตัวแปร*/ const modal = ref(false); +const isloadInformation = ref(true); +const isloadGoverment = ref(true); +const retireDate = ref(); const avatar = reactive({ avatar: "", fullname: "", @@ -94,7 +95,7 @@ function calculateAge(birthDate: Date | null) { * @param id profileID */ async function fetchInformation(id: string) { - showLoader(); + isloadInformation.value = true; await http .get( config.API.orgProfileAdminById( @@ -111,9 +112,7 @@ async function fetchInformation(id: string) { imformation.birthDate = data.birthDate ? date2Thai(data.birthDate) : "-"; imformation.age = data.birthDate ? calculateAge(data.birthDate) : "-"; imformation.gender = data.gender ?? "-"; - avatar.fullname = `${data.prefix}${data.firstName} ${data.lastName}`; - avatar.position = data.position ? data.position : "-"; if (data.avatarName) { await fetchProfile(data.id as string, data.avatarName); @@ -125,7 +124,7 @@ async function fetchInformation(id: string) { messageError($q, err); }) .finally(() => { - hideLoader(); + isloadInformation.value = false; }); } @@ -134,7 +133,7 @@ async function fetchInformation(id: string) { * @param id profileID */ async function fetchProfileGov(id: string) { - showLoader(); + isloadGoverment.value = true; await http .get( config.API.profileNewGovernmentCard( @@ -158,19 +157,21 @@ async function fetchProfileGov(id: string) { goverment.positionExecutiveSide = data.positionExecutiveField !== "" ? data.positionExecutiveField : "-"; }) - .catch((err) => { messageError($q, err); }) .finally(() => { - hideLoader(); + isloadGoverment.value = false; }); } -// function redirecToRegistry() { -// router.push(`/registry-${empType.value}/${props.id}`); -// modal.value = 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; + }); +} watch( () => props.modal, @@ -178,12 +179,6 @@ watch( modal.value = props.modal ? props.modal : false; if (modal.value) { if (props.id) { - // empType.value = - // route.name === "appoint-employee-detail" || - // isEmployee.value == "EMPLOYEE" - // ? "employee" - // : "officer"; - await Promise.all([ fetchInformation(props.id), fetchProfileGov(props.id), @@ -198,14 +193,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; - }); -}