2024-03-08 16:08:46 +07:00
|
|
|
<script setup lang="ts">
|
2024-03-20 15:50:00 +07:00
|
|
|
import { ref, onMounted, reactive } from "vue";
|
2024-03-20 14:29:50 +07:00
|
|
|
import axios from "axios";
|
2024-03-11 11:25:42 +07:00
|
|
|
import { useRoute, useRouter } from "vue-router";
|
2024-03-20 14:29:50 +07:00
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
2024-03-11 11:25:42 +07:00
|
|
|
import http from "@/plugins/http";
|
|
|
|
|
import config from "@/app.config";
|
2024-03-20 14:29:50 +07:00
|
|
|
import { useQuasar } from "quasar";
|
2024-03-11 11:25:42 +07:00
|
|
|
import type { DataOption } from "@/modules/04_registryNew/interface/index/Main";
|
2024-03-11 10:11:32 +07:00
|
|
|
import type { DataPerson } from "@/modules/04_registryNew/interface/response/Main";
|
2024-03-20 14:29:50 +07:00
|
|
|
import avatar from "@/assets/avatar_user.jpg";
|
2024-03-11 10:11:32 +07:00
|
|
|
import TabMain from "@/modules/04_registryNew/components/detail/TabMain.vue";
|
2024-03-20 14:29:50 +07:00
|
|
|
import UploadFile from "@/modules/11_discipline/components/UploadFile.vue";
|
|
|
|
|
const mixin = useCounterMixin();
|
|
|
|
|
const $q = useQuasar();
|
2024-03-08 16:08:46 +07:00
|
|
|
const router = useRouter();
|
2024-03-11 11:25:42 +07:00
|
|
|
const route = useRoute();
|
2024-03-20 14:29:50 +07:00
|
|
|
const {
|
|
|
|
|
dialogRemove,
|
|
|
|
|
dialogConfirm,
|
|
|
|
|
showLoader,
|
|
|
|
|
hideLoader,
|
|
|
|
|
messageError,
|
|
|
|
|
success,
|
|
|
|
|
date2Thai,
|
|
|
|
|
} = mixin;
|
2024-03-11 10:11:32 +07:00
|
|
|
|
2024-03-11 11:25:42 +07:00
|
|
|
const profileId = ref<string>(route.params.id.toString());
|
2024-03-20 17:10:14 +07:00
|
|
|
const formDetail = ref<any>();
|
2024-03-11 11:25:42 +07:00
|
|
|
const itemsMenu = ref<DataOption[]>([
|
|
|
|
|
{
|
|
|
|
|
id: "1",
|
|
|
|
|
name: "ช่วยราชการ",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "2",
|
|
|
|
|
name: "ส่งตัวกลับ",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "3",
|
|
|
|
|
name: "แต่งตั้ง-เลื่อน-ย้าย",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "4",
|
|
|
|
|
name: "ถึงแก่กรรม",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "5",
|
|
|
|
|
name: "ให้ออกจากราชการ",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "6",
|
|
|
|
|
name: "อื่นๆ",
|
|
|
|
|
},
|
|
|
|
|
]);
|
2024-03-20 14:29:50 +07:00
|
|
|
|
|
|
|
|
const uploadUrl = ref<string>("");
|
|
|
|
|
const fileName = ref<string>("");
|
|
|
|
|
const profilePicture = ref<string>("");
|
|
|
|
|
const profileFile = ref();
|
2024-03-13 13:13:49 +07:00
|
|
|
const input = document.createElement("input");
|
|
|
|
|
input.type = "file";
|
2024-03-14 16:51:09 +07:00
|
|
|
input.accept = ".jpg,.png,.tif,.pic";
|
2024-03-13 13:13:49 +07:00
|
|
|
|
2024-03-20 14:29:50 +07:00
|
|
|
input.addEventListener("change", (e) => {
|
|
|
|
|
profileFile.value = (e.currentTarget as HTMLInputElement).files?.[0];
|
|
|
|
|
uploadProfile();
|
|
|
|
|
});
|
|
|
|
|
|
2024-03-13 13:13:49 +07:00
|
|
|
function selectFile() {
|
|
|
|
|
input.click();
|
|
|
|
|
}
|
2024-03-11 10:11:32 +07:00
|
|
|
|
2024-03-20 14:29:50 +07:00
|
|
|
async function uploadProfile() {
|
|
|
|
|
await http
|
|
|
|
|
.post(config.API.file("ทะเบียนประวัติ", "โปรไฟล์", profileId.value), {
|
|
|
|
|
replace: true,
|
|
|
|
|
fileList: [
|
|
|
|
|
{
|
|
|
|
|
fileName: fileName.value,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
.then(async (res) => {
|
|
|
|
|
uploadUrl.value = res.data[fileName.value].uploadUrl;
|
|
|
|
|
uploadFileURL(uploadUrl.value, profileFile.value);
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function uploadFileURL(uploadUrl: string, file: any) {
|
|
|
|
|
showLoader();
|
|
|
|
|
await axios
|
|
|
|
|
.put(uploadUrl, file, {
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": file.type,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
fetchProfile(profileId.value);
|
|
|
|
|
success($q, "อัปโหลดไฟล์สำเร็จ");
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function fetchProfile(id: string) {
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, fileName.value))
|
|
|
|
|
.then(async (res) => {
|
|
|
|
|
profilePicture.value = res.data.downloadUrl;
|
|
|
|
|
})
|
2024-03-20 15:50:00 +07:00
|
|
|
.catch(() => {
|
2024-03-20 14:29:50 +07:00
|
|
|
profilePicture.value = avatar;
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-20 15:50:00 +07:00
|
|
|
async function fetchDataPersonal() {
|
|
|
|
|
showLoader();
|
|
|
|
|
await http
|
|
|
|
|
.get(config.API.registryNewByProfileId(profileId.value))
|
|
|
|
|
.then((res) => {
|
|
|
|
|
formDetail.value = res.data.result;
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
messageError($q, err);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
hideLoader();
|
|
|
|
|
});
|
2024-03-11 10:11:32 +07:00
|
|
|
}
|
2024-03-11 11:25:42 +07:00
|
|
|
|
|
|
|
|
function onClickDownloadKp7(type: string) {
|
|
|
|
|
if (type === "FULL") {
|
|
|
|
|
window.open(config.API.profileReportId(profileId.value));
|
|
|
|
|
} else if (type === "SHORT") {
|
|
|
|
|
window.open(config.API.profileKp7ShortId(profileId.value));
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-20 14:29:50 +07:00
|
|
|
onMounted(async () => {
|
|
|
|
|
fileName.value = `profile-${profileId.value}`;
|
|
|
|
|
fetchProfile(profileId.value);
|
2024-03-11 10:11:32 +07:00
|
|
|
fetchDataPersonal();
|
|
|
|
|
});
|
2024-03-08 16:08:46 +07:00
|
|
|
</script>
|
2024-03-08 13:11:20 +07:00
|
|
|
<template>
|
2024-03-12 15:51:47 +07:00
|
|
|
<div class="row items-center q-gutter-sm q-mb-xs">
|
2024-03-08 16:08:46 +07:00
|
|
|
<div class="toptitle text-dark row items-center q-py-xs">
|
|
|
|
|
<q-btn
|
|
|
|
|
icon="mdi-arrow-left"
|
|
|
|
|
unelevated
|
|
|
|
|
round
|
|
|
|
|
dense
|
|
|
|
|
flat
|
|
|
|
|
color="primary"
|
|
|
|
|
class="q-mr-sm"
|
|
|
|
|
@click="router.go(-1)"
|
|
|
|
|
/>
|
|
|
|
|
ทะเบียนประวัติ
|
|
|
|
|
</div>
|
|
|
|
|
<q-space />
|
|
|
|
|
<q-btn-dropdown
|
2024-03-12 15:51:47 +07:00
|
|
|
size="md"
|
2024-03-08 16:08:46 +07:00
|
|
|
rounded
|
|
|
|
|
unelevated
|
|
|
|
|
color="grey-4"
|
|
|
|
|
text-color="red"
|
|
|
|
|
icon="mdi-home-export-outline"
|
|
|
|
|
dropdown-icon="mdi-chevron-down"
|
|
|
|
|
>
|
2024-03-11 11:25:42 +07:00
|
|
|
<q-list v-for="(item, index) in itemsMenu" key="index">
|
2024-03-08 16:08:46 +07:00
|
|
|
<q-item clickable v-close-popup>
|
2024-03-11 11:25:42 +07:00
|
|
|
<q-item-section>{{ item.name }}</q-item-section>
|
2024-03-08 16:08:46 +07:00
|
|
|
</q-item>
|
|
|
|
|
</q-list>
|
|
|
|
|
</q-btn-dropdown>
|
2024-03-11 11:25:42 +07:00
|
|
|
|
2024-03-08 16:08:46 +07:00
|
|
|
<q-btn
|
|
|
|
|
unelevated
|
|
|
|
|
round
|
|
|
|
|
color="grey-4"
|
|
|
|
|
text-color="primary"
|
|
|
|
|
icon="mdi-file-eye-outline"
|
2024-03-12 15:51:47 +07:00
|
|
|
size="md"
|
2024-03-11 11:25:42 +07:00
|
|
|
>
|
|
|
|
|
<q-tooltip>ดาวน์ไฟล์</q-tooltip>
|
|
|
|
|
<q-menu>
|
|
|
|
|
<q-list style="min-width: 120px">
|
|
|
|
|
<q-item clickable v-close-popup @click="onClickDownloadKp7('FULL')">
|
|
|
|
|
<q-item-section class="text-blue">ก.พ.7/ก.ก.1</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
<q-item clickable v-close-popup @click="onClickDownloadKp7('SHORT')">
|
|
|
|
|
<q-item-section class="text-primary">ประวัติแบบย่อ</q-item-section>
|
|
|
|
|
</q-item>
|
|
|
|
|
</q-list>
|
|
|
|
|
</q-menu>
|
|
|
|
|
</q-btn>
|
2024-03-08 16:08:46 +07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<q-card>
|
2024-03-12 15:51:47 +07:00
|
|
|
<div class="column" style="height: 160px">
|
2024-03-11 10:11:32 +07:00
|
|
|
<div class="col row items-center">
|
|
|
|
|
<div class="row col-12">
|
|
|
|
|
<div class="col-sm-3 col-md-2"></div>
|
|
|
|
|
<div class="col">
|
2024-03-12 15:51:47 +07:00
|
|
|
<div class="col-12 text-primary">
|
|
|
|
|
<h2 class="title q-ma-none q-pa-none">
|
|
|
|
|
{{
|
|
|
|
|
`${formDetail?.prefix}${formDetail?.firstName} ${formDetail?.lastName}`
|
|
|
|
|
}}
|
|
|
|
|
</h2>
|
2024-03-11 10:11:32 +07:00
|
|
|
</div>
|
2024-03-12 15:51:47 +07:00
|
|
|
<div class="col-12 subtitle">{{ formDetail?.position }}</div>
|
2024-03-08 18:03:44 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-03-08 16:08:46 +07:00
|
|
|
<div class="absolute-center-left q-ml-lg">
|
|
|
|
|
<q-avatar size="130px">
|
2024-03-20 14:29:50 +07:00
|
|
|
<img :src="profilePicture" />
|
2024-03-08 16:08:46 +07:00
|
|
|
</q-avatar>
|
|
|
|
|
<q-btn
|
|
|
|
|
round
|
|
|
|
|
color="white"
|
|
|
|
|
text-color="primary"
|
|
|
|
|
icon="mdi-pencil-outline"
|
|
|
|
|
style="position: absolute; bottom: 0; right: 0"
|
2024-03-13 13:13:49 +07:00
|
|
|
@click="selectFile"
|
|
|
|
|
>
|
|
|
|
|
</q-btn>
|
2024-03-08 16:08:46 +07:00
|
|
|
</div>
|
2024-03-08 18:03:44 +07:00
|
|
|
|
2024-03-11 10:11:32 +07:00
|
|
|
<div class="col row items-center bg-teal-1">
|
|
|
|
|
<div class="row col-12">
|
|
|
|
|
<div class="col-sm-3 col-md-2"></div>
|
|
|
|
|
<div class="col-2">
|
|
|
|
|
<div class="col-sm-3 col-md-3">
|
2024-03-12 15:51:47 +07:00
|
|
|
<div class="col text-grey-6">ตำแหน่งในสายงาน</div>
|
2024-03-20 17:10:14 +07:00
|
|
|
<div class="col">{{ formDetail?.position }}</div>
|
2024-03-11 10:11:32 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-2">
|
|
|
|
|
<div class="col-sm-3 col-md-3">
|
2024-03-12 15:51:47 +07:00
|
|
|
<div class="col text-grey-6">ประเภทตำแหน่ง</div>
|
2024-03-20 17:10:14 +07:00
|
|
|
<div class="col">{{ formDetail?.posType.posTypeName }}</div>
|
2024-03-11 10:11:32 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-2">
|
|
|
|
|
<div class="col-sm-3 col-md-3">
|
2024-03-20 15:50:00 +07:00
|
|
|
<div class="col text-grey-6">ระดับตำแหน่ง</div>
|
2024-03-20 17:10:14 +07:00
|
|
|
<div class="col">{{ formDetail?.posLevel.posLevelName }}</div>
|
2024-03-11 10:11:32 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-03-08 18:03:44 +07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-03-08 16:08:46 +07:00
|
|
|
</div>
|
|
|
|
|
</q-card>
|
|
|
|
|
|
2024-03-12 15:51:47 +07:00
|
|
|
<q-card class="q-mt-md rounded">
|
2024-03-08 16:08:46 +07:00
|
|
|
<TabMain />
|
|
|
|
|
</q-card>
|
2024-03-08 13:11:20 +07:00
|
|
|
</template>
|
|
|
|
|
|
2024-03-08 16:08:46 +07:00
|
|
|
<style scoped>
|
2024-03-12 15:51:47 +07:00
|
|
|
h2.title {
|
|
|
|
|
font-size: 1.2rem;
|
|
|
|
|
line-height: 1.6rem;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
.subtitle {
|
|
|
|
|
font-size: 1rem;
|
|
|
|
|
color: #34373c;
|
|
|
|
|
}
|
2024-03-08 16:08:46 +07:00
|
|
|
.absolute-center-left {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 50%;
|
|
|
|
|
transform: translateY(-50%);
|
|
|
|
|
}
|
2024-03-12 15:51:47 +07:00
|
|
|
.rounded {
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
}
|
2024-03-08 16:08:46 +07:00
|
|
|
</style>
|