2024-05-02 15:12:10 +07:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref, reactive, watch } from "vue";
|
|
|
|
|
import { useQuasar } from "quasar";
|
|
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
|
|
|
|
|
|
|
|
|
/** importType*/
|
2024-10-15 16:16:59 +07:00
|
|
|
import type { PropType } from "vue";
|
2024-05-02 15:12:10 +07:00
|
|
|
import type { FormProfile } from "@/interface/main";
|
|
|
|
|
import type { DataProfile } from "@/modules/05_placement/interface/index/Main";
|
|
|
|
|
|
|
|
|
|
/** importComponents*/
|
|
|
|
|
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
|
|
|
|
|
|
|
|
|
|
/** impoerStore*/
|
|
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
|
|
|
|
|
|
/** use*/
|
2025-03-19 17:41:35 +07:00
|
|
|
const { findOrgNameOld, findOrgName, textTranForm } = useCounterMixin();
|
2024-05-02 15:12:10 +07:00
|
|
|
|
|
|
|
|
/** propsDataProfile*/
|
|
|
|
|
const props = defineProps({
|
2024-10-15 16:16:59 +07:00
|
|
|
data: { type: Object as PropType<DataProfile>, required: true },
|
2024-05-17 17:20:50 +07:00
|
|
|
type: { type: String, default: "" },
|
2024-05-02 15:12:10 +07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const profile = reactive<FormProfile>({
|
|
|
|
|
id: "",
|
|
|
|
|
avatar: "",
|
|
|
|
|
fullName: "",
|
|
|
|
|
position: "",
|
|
|
|
|
positionLevel: "",
|
|
|
|
|
organization: "",
|
|
|
|
|
});
|
|
|
|
|
const modalPersonal = ref<boolean>(false);
|
|
|
|
|
|
2024-05-02 18:09:29 +07:00
|
|
|
const profileId = ref<string | null>("");
|
|
|
|
|
|
2024-11-20 17:21:35 +07:00
|
|
|
async function fetchDataProfile(data: DataProfile) {
|
2024-05-16 10:58:18 +07:00
|
|
|
if (data.profileId) {
|
2024-06-11 16:34:25 +07:00
|
|
|
fetchCheckAvatar(data.profileId);
|
2024-05-16 10:58:18 +07:00
|
|
|
}
|
2024-05-02 15:12:10 +07:00
|
|
|
profile.id = data.profileId;
|
2024-11-21 13:56:50 +07:00
|
|
|
profile.fullName = `${data.prefix ?? ""}${data.firstName ?? ""} ${
|
2024-05-20 10:11:43 +07:00
|
|
|
data.lastName ?? ""
|
|
|
|
|
} `;
|
2024-05-24 14:58:40 +07:00
|
|
|
|
|
|
|
|
if (data["posTypeNameOld"] !== undefined) {
|
|
|
|
|
profile.position =
|
|
|
|
|
data.positionOld == "" || data.positionOld == null
|
|
|
|
|
? "-"
|
|
|
|
|
: data.positionOld;
|
|
|
|
|
if (data.posTypeNameOld && data.posLevelNameOld) {
|
|
|
|
|
profile.positionLevel = `${data.posTypeNameOld} (${data.posLevelNameOld})`;
|
|
|
|
|
} else if (data.posTypeNameOld) {
|
|
|
|
|
profile.positionLevel = `${data.posTypeNameOld}`;
|
|
|
|
|
} else if (data.posLevelNameOld) {
|
|
|
|
|
profile.positionLevel = `(${data.posLevelNameOld})`;
|
|
|
|
|
} else profile.positionLevel = "-";
|
|
|
|
|
profile.organization = findOrgNameOld(data);
|
|
|
|
|
} else {
|
|
|
|
|
profile.position =
|
|
|
|
|
data.position == "" || data.position == null ? "-" : data.position;
|
|
|
|
|
if (data.posTypeName && data.posLevelName) {
|
|
|
|
|
profile.positionLevel = `${data.posTypeName} (${data.posLevelName})`;
|
|
|
|
|
} else if (data.posTypeName) {
|
|
|
|
|
profile.positionLevel = `${data.posTypeName}`;
|
|
|
|
|
} else if (data.posLevelName) {
|
|
|
|
|
profile.positionLevel = `(${data.posLevelName})`;
|
|
|
|
|
} else profile.positionLevel = "-";
|
|
|
|
|
profile.organization = findOrgName(data);
|
|
|
|
|
}
|
2024-05-02 15:12:10 +07:00
|
|
|
}
|
|
|
|
|
|
2024-06-11 16:34:25 +07:00
|
|
|
function fetchCheckAvatar(id: string) {
|
2024-08-29 11:17:29 +07:00
|
|
|
const path =
|
|
|
|
|
props.type === "employee"
|
|
|
|
|
? `profile-employee/avatar/profileEmployeeId-admin/${id}`
|
|
|
|
|
: `profile/avatar/profileId-admin/${id}`;
|
|
|
|
|
http.get(config.API.orgCheckAvatarCard(path)).then((res) => {
|
2024-06-11 16:34:25 +07:00
|
|
|
const data = res.data.result;
|
|
|
|
|
if (data.avatarName) {
|
|
|
|
|
fetchProfile(id, data.avatarName);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fetchProfile(id: string, name: string) {
|
2024-05-02 15:12:10 +07:00
|
|
|
if (profile.avatar === "") {
|
|
|
|
|
http
|
2024-06-11 16:34:25 +07:00
|
|
|
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, `${name}`))
|
2024-05-02 15:12:10 +07:00
|
|
|
.then(async (res) => {
|
|
|
|
|
profile.avatar = res.data.downloadUrl;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updatemodalPersonal(modal: boolean) {
|
|
|
|
|
modalPersonal.value = modal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onclickViewinfo() {
|
|
|
|
|
modalPersonal.value = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => props.data,
|
2024-08-29 11:17:29 +07:00
|
|
|
async () => {
|
|
|
|
|
const dataMain = (await props.data) as DataProfile;
|
2024-05-02 18:09:29 +07:00
|
|
|
profileId.value = dataMain.profileId;
|
2024-08-29 11:17:29 +07:00
|
|
|
await fetchDataProfile(dataMain);
|
2024-05-02 15:12:10 +07:00
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<q-card bordered class="row col-12 text-dark">
|
|
|
|
|
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
|
|
|
|
|
<div class="q-pl-sm text-weight-bold text-subtitle2">
|
|
|
|
|
{{ profile.fullName }}
|
|
|
|
|
</div>
|
|
|
|
|
<q-space />
|
|
|
|
|
<q-btn
|
2024-05-02 18:09:29 +07:00
|
|
|
v-if="profileId"
|
2024-05-02 15:12:10 +07:00
|
|
|
outline
|
|
|
|
|
color="blue"
|
|
|
|
|
dense
|
|
|
|
|
icon-right="mdi-open-in-new"
|
|
|
|
|
class="q-px-sm"
|
|
|
|
|
label="ดูข้อมูลทะเบียนประวัติ"
|
|
|
|
|
@click="onclickViewinfo()"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-12"><q-separator /></div>
|
|
|
|
|
<div class="row col-12 q-pa-md">
|
|
|
|
|
<div class="col-12 row bg-white q-col-gutter-md">
|
|
|
|
|
<div class="col-xs-3 col-sm-2 col-md-1 row">
|
|
|
|
|
<q-img :src="profile.avatar" v-if="profile.avatar !== ''" />
|
|
|
|
|
<q-img src="@/assets/avatar_user.jpg" v-else />
|
|
|
|
|
</div>
|
2024-06-27 14:07:38 +07:00
|
|
|
<div class="col-xs-6 col-sm-3 row">
|
2024-05-02 15:12:10 +07:00
|
|
|
<div class="col-12 q-pl-md">
|
2024-05-24 14:58:40 +07:00
|
|
|
<div class="col-12 text-top">
|
|
|
|
|
{{ props.type == "employee" ? "ตำแหน่ง" : "ตำแหน่งในสายงาน" }}
|
|
|
|
|
</div>
|
2024-05-02 15:12:10 +07:00
|
|
|
<div class="col-12 text-detail">
|
|
|
|
|
{{ profile.position }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-06-27 14:07:38 +07:00
|
|
|
<div class="col-xs-6 col-sm-3 row">
|
2024-05-02 15:12:10 +07:00
|
|
|
<div class="col-12">
|
2024-05-24 14:58:40 +07:00
|
|
|
<div class="col-12 text-top">
|
2025-02-25 11:37:37 +07:00
|
|
|
{{
|
|
|
|
|
props.type.toLowerCase() == "employee"
|
|
|
|
|
? "กลุ่มงาน"
|
2025-03-19 17:41:35 +07:00
|
|
|
: "ตำแหน่งประเภท"
|
2025-02-25 11:37:37 +07:00
|
|
|
}}
|
2024-05-24 14:58:40 +07:00
|
|
|
</div>
|
2024-05-02 15:12:10 +07:00
|
|
|
<div class="col-12 text-detail">
|
|
|
|
|
{{ profile.positionLevel }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-06-27 14:07:38 +07:00
|
|
|
<div class="col-xs-6 col-sm-3 row">
|
2024-05-02 15:12:10 +07:00
|
|
|
<div class="col-12">
|
|
|
|
|
<div class="col-12 text-top">สังกัด</div>
|
2025-03-19 17:41:35 +07:00
|
|
|
<div class="col-12 text-detail text-html">
|
|
|
|
|
{{ textTranForm(profile.organization) }}
|
2024-05-02 15:12:10 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</q-card>
|
|
|
|
|
|
|
|
|
|
<PopupPersonal
|
|
|
|
|
:modal="modalPersonal"
|
|
|
|
|
:id="profile.id"
|
|
|
|
|
@update:modal="updatemodalPersonal"
|
2024-05-17 17:20:50 +07:00
|
|
|
:type="props.type"
|
2025-01-20 16:38:08 +07:00
|
|
|
:is-employee="props.type"
|
2024-05-02 15:12:10 +07:00
|
|
|
/>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|