From a7364941552ae8ab2e4d10f5bde69ad9c405e241 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Tue, 19 Nov 2024 11:52:53 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87=E0=B8=A3?= =?UTF-8?q?=E0=B8=B9=E0=B8=9B=20Profile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/02_organizational/api.organization.ts | 2 + src/views/MainLayout.vue | 42 +++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index c9c1c79f..fee3c0c8 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -6,6 +6,8 @@ const orgProfile = `${env.API_URI}/org/profile`; const orgEmployeePos = `${env.API_URI}/org/employee/pos`; export default { + keycloakPosition: () => `${organization}/profile/keycloak/position`, + /** โครงสร้างอัตรากำลัง*/ activeOrganization: `${organization}/active`, orgByid: (id: string) => `${organization}/super-admin/${id}`, diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index 36b880b8..f2a5c253 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -10,6 +10,7 @@ import { logout, tokenParsed } from "@/plugins/auth"; import checkPermission from "@/plugins/checkPermission"; import { useCounterMixin } from "@/stores/mixin"; import { useDataStore } from "@/stores/data"; +import avatar from "@/assets/avatar_user.jpg"; import type { ScrollType, @@ -333,6 +334,33 @@ function getLandingUrl() { } } +/** ฟังก์ชันเรียกข้อมูลผู้ใช่งาน*/ +async function fetchKeycloakPosition() { + await http + .get(config.API.keycloakPosition()) + .then(async (res) => { + const data = await res.data.result; + //เช็คว่ามีรูปไหม ถ้ามีรูปเรียกข้อมูลรูป + if (data.avatarName) { + await getImg(data.profileId, data.avatarName); + } else { + profileImg.value = avatar; + } + }) + .catch((err) => { + messageError($q, err); + }); +} + +const profileImg = ref(""); +async function getImg(id: string, pathName: string) { + await http + .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, pathName)) + .then((res) => { + profileImg.value = res.data.downloadUrl; + }); +} + /** * ฟังก์ชัน watch การเปลี่ยนแปลงของค่า notiTrigger * เมื่อค่า notiTrigger เปลี่ยนเป็น false, @@ -375,6 +403,7 @@ onBeforeMount(async () => { * ยังจับ boolean ผิด จึงต้อง set */ onMounted(async () => { + fetchKeycloakPosition(); await fetchmsgNoread(); myEventHandler(null, false); window.addEventListener("resize", (e: any) => { @@ -554,8 +583,13 @@ onUnmounted(() => { - - + + @@ -572,8 +606,8 @@ onUnmounted(() => { >
- - + +
{{ fullname }}