ปรับ Code ประเมืน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-01-11 13:26:46 +07:00
parent f9c4bb3b80
commit 5b2be2af2b
24 changed files with 603 additions and 1398 deletions

View file

@ -1,18 +1,25 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useRoute } from "vue-router";
import { useQuasar } from "quasar";
import axios from "axios";
import http from "@/plugins/http";
import config from "@/app.config";
import keycloak from "@/plugins/keycloak";
import { useCounterMixin } from "@/stores/mixin";
import genReport from "@/plugins/genreport";
import { useQuasar } from "quasar";
import PopupReason from "@/components/Dialogs/PopupReason.vue";
/** importType*/
import type { PersonInformation } from "@/modules/12_evaluatePersonal/interface/response/evalute";
/** importStore*/
import { useCounterMixin } from "@/stores/mixin";
import { useEvaluateDetailStore } from "@/modules/12_evaluatePersonal/store/EvaluateDetail";
/** use*/
const route = useRoute();
const $q = useQuasar();
const mixin = useCounterMixin();
const store = useEvaluateDetailStore();
const {
date2Thai,
showLoader,
@ -21,21 +28,15 @@ const {
success,
dialogConfirm,
} = mixin;
const store = useEvaluateDetailStore();
const router = useRouter();
const route = useRoute();
const id = ref<string>(route.params.id as string);
const fullName = ref<string>(
keycloak.tokenParsed ? keycloak.tokenParsed.name!.toString() : ""
);
const profile = ref<any>();
const messenger = ref<string>("");
const title = ref<string>("");
const modalEvaluation = ref<boolean>(false);
const fileEvaluationUpload = ref<any>();
const fileEvaluationUploadRef = ref<any>();
const status = ref<string>("WAIT_CHECK_DOC_V1");
const files = [
{
id: "file1",
@ -71,6 +72,7 @@ const files = [
},
];
/** function ดาวน์โหลดไฟล์ต้นแบบ*/
async function onClickDowloadFile(
tp: string,
templateName: string,
@ -110,20 +112,23 @@ async function onClickDowloadFile(
await genReport(body, fileName);
}
/** ติดต่อผู้ขอประเมิน */
/** function เปิด popup ติดต่อผู้ขอประเมิน */
function openPopUp() {
modalEvaluation.value = true;
}
function downloadFile(name: string) {
/**
* function ดาวนโหลดไฟล
* @param name อไฟล
*/
async function downloadFile(name: string) {
showLoader();
http
await http
.get(config.API.evaluationFilebyId("เล่ม 1", id.value, name))
.then((res) => {
const link = res.data.downloadUrl;
const type = res.data.fileType;
const fileName = res.data.fileName;
getPDF(link, type, fileName);
})
.catch((e) => {})
@ -132,8 +137,14 @@ function downloadFile(name: string) {
});
}
function getPDF(url: string, type: string, fileName: string) {
axios
/**
* function เรยกไฟล PDF
* @param url link PDF
* @param type ประเภทไฟล
* @param fileName อไฟล
*/
async function getPDF(url: string, type: string, fileName: string) {
await axios
.get(url, {
method: "GET",
responseType: "blob",
@ -152,7 +163,7 @@ function getPDF(url: string, type: string, fileName: string) {
.finally(() => {});
}
/** ส่งไปประกาศบนเว็บไซต์ */
/** function ส่งไปประกาศบนเว็บไซต์ */
function onWebSite() {
download10Url.value === ""
? (fileEvaluationUpload.value = "")
@ -168,10 +179,11 @@ function onWebSite() {
showLoader();
http
.put(config.API.evaluationApproveDoc1(id.value))
.then(() => {})
.then(() => {
success($q, "ส่งไปประกาศบนเว็บไซต์สำเร็จ");
})
.catch(() => {})
.finally(() => {
success($q, "ส่งไปประกาศบนเว็บไซต์สำเร็จ");
getStep();
});
},
@ -181,9 +193,10 @@ function onWebSite() {
}
}
function getStep() {
/** function เช็คขั้นตอน*/
async function getStep() {
showLoader();
http
await http
.get(config.API.evaluateGetStep(id.value))
.then((res: any) => {
const data = res.data.result;
@ -220,10 +233,14 @@ function getStep() {
});
}
function upLoadFile(file: any) {
/**
* function เรยก link ปโหลด
* @param file ไฟล
*/
async function upLoadFile(file: any) {
if (file) {
showLoader();
http
await http
.post(config.API.evaluationFileListbyId("เล่ม 1", id.value), {
fileList: {
fileName: "10-ประกาศผลการคัดเลือกบุคคล (เอกสารหมายเลข 10)",
@ -252,6 +269,10 @@ function upLoadFile(file: any) {
}
}
/**
* function ปโหลดไฟล
* @param url link ปโหลด
*/
function fileUpLoad(url: string) {
axios
.put(url, fileEvaluationUpload.value, {
@ -268,16 +289,18 @@ function fileUpLoad(url: string) {
}
const myForm = ref<any>();
function sentMessenger() {
/** fiunction ส่งข้อความ*/
async function sentMessenger() {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
showLoader();
http
await http
.put(config.API.evaluationSentToContact(id.value), {
subject: title.value,
body: messenger.value,
})
.then((res) => {
.then(() => {
success($q, "ส่งข้อความสำเร็จ");
})
.catch((e) => {
@ -294,9 +317,10 @@ function sentMessenger() {
}
const download10Url = ref<string>("");
function checkDoc10() {
/** function เช็คไฟล์อัปโหลด*/
async function checkDoc10() {
showLoader();
http
await http
.get(
config.API.evaluationPatchData(
"เล่ม 1",
@ -307,15 +331,16 @@ function checkDoc10() {
.then((res: any) => {
download10Url.value = res.data.downloadUrl;
})
// .catch((e) => {
// messageError($q, e);
// })
.catch(() => {
// messageError($q, e);
})
.finally(() => {
hideLoader();
});
fetchProfile();
}
/** function เรียกข้แมูลคุณสมบัติ*/
async function fetchProfile() {
showLoader();
await http
@ -335,9 +360,10 @@ async function fetchProfile() {
const author = ref<string>("");
const subject = ref<string>("");
function fetchDataSigner() {
/** function เรียกข้อมูลผลงาน*/
async function fetchDataSigner() {
showLoader();
http
await http
.get(config.API.evaluationSigner(id.value, 1))
.then((res) => {
const data = res.data.result;
@ -352,14 +378,15 @@ function fetchDataSigner() {
});
}
onMounted(() => {
checkDoc10();
fetchDataSigner();
onMounted(async () => {
await checkDoc10();
await fetchDataSigner();
});
</script>
<template>
<div class="row q-col-gutter-md">
<!-- เอกสารเลมท 1 -->
<div class="col-12">
<q-card bordered style="border: 1px solid #d6dee1">
<div class="text-weight-medium bg-grey-1 q-py-sm q-px-md">
@ -397,6 +424,8 @@ onMounted(() => {
</q-list>
</q-card>
</div>
<!-- ประกาศผลการคดเลอกบคคล (เอกสารหมายเลข 10) -->
<div class="col-12">
<q-card bordered style="border: 1px solid #d6dee1">
<div class="text-weight-medium bg-grey-1 q-py-sm q-px-md">
@ -478,6 +507,8 @@ onMounted(() => {
</div>
</q-card>
</div>
<!-- ดตอผขอประเม -->
<div class="col-12" v-if="store.currentStep == 4">
<div class="q-mt-xs q-gutter-md" align="right">
<q-btn label="ติดต่อผู้ขอประเมิน" color="info" @click="openPopUp" />
@ -491,6 +522,7 @@ onMounted(() => {
</div>
</div>
<!-- popup ดตอผขอประเม -->
<q-dialog v-model="modalEvaluation" persistent>
<q-card style="min-width: 60vw">
<q-toolbar>