apiรายละเอียดการประเมินของ

This commit is contained in:
setthawutttty 2023-12-21 16:33:54 +07:00
parent ec4dd527c4
commit 693e8008a5
6 changed files with 179 additions and 63 deletions

View file

@ -11,5 +11,6 @@ export default {
meeting: () => `${evaluation}/meeting`, meeting: () => `${evaluation}/meeting`,
meetingById: (id: string) => `${evaluation}/meeting/${id}`, meetingById: (id: string) => `${evaluation}/meeting/${id}`,
evaluationFilebyId:(volume:string,id:string,file:string) => `${evaluationFile}/${volume}/${id}/${file}` evaluationFilebyId:(volume:string,id:string,file:string) => `${evaluationFile}/${volume}/${id}/${file}`,
evaluationFileListbyId:(volume:string,id:string) => `${evaluationFile}/${volume}/${id}`
}; };

View file

@ -1,11 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref, watch, onMounted } from "vue"; import { reactive, ref, watch, onMounted } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { VuePDF, usePDF } from "@tato30/vue-pdf";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useEvaluateDetailStore } from "@/modules/12_evaluatePersonal/store/EvaluateDetail"; import { useEvaluateDetailStore } from "@/modules/12_evaluatePersonal/store/EvaluateDetail";
import http from "@/plugins/http"; import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
import { useRouter, useRoute } from "vue-router"; import { useRouter, useRoute } from "vue-router";
import axios from "axios";
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
@ -27,16 +29,51 @@ function handleItemClick(itemNumber: number) {
function getFile(volume: number) { function getFile(volume: number) {
const fileText = numToThai(volume); const fileText = numToThai(volume);
showLoader(); showLoader();
http.get(config.API.evaluationFilebyId("เล่ม 1", id.value, fileText)) http
.then((res)=>{ .get(config.API.evaluationFilebyId("เล่ม 1", id.value, fileText))
console.log(res) .then((res) => {
}) const link = res.data.downloadUrl;
.catch((e)=>{ const type = res.data.fileType;
messageError($q,e) getPDF(link,type);
}) })
.finally(()=>{ .catch((e) => {
hideLoader() // messageError($q, e);
}) })
.finally(() => {
hideLoader();
});
}
function getPDF(url: string,type:string) {
axios
.get(url, {
method: "GET",
responseType: "blob",
headers: {
"Content-Type": "application/json",
Accept: type, //
},
})
.then(async (res) => {
store.log = 0
console.log(res);
const blob = new Blob([res.data]);
const objectUrl = URL.createObjectURL(blob);
const pdfData = await usePDF(`${objectUrl}`);
showLoader();
setTimeout(() => {
store.log = 1
store.pdfSrcStore = pdfData.pdf.value;
store.numOfPagesStore = pdfData.pages.value;
hideLoader();
}, 1500);
}).catch((e)=>{
messageError($q,e)
})
.finally(()=>{
})
} }
function numToThai(val: number) { function numToThai(val: number) {
@ -46,20 +83,20 @@ function numToThai(val: number) {
case 2: case 2:
return "2-แบบแสดงรายละเอียดการเสนอผลงาน"; return "2-แบบแสดงรายละเอียดการเสนอผลงาน";
case 3: case 3:
return "3-แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูล"; return "3-แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลเพื่อประกอบการคัดเลือกบุคคล (เอกสารแบบ ก.)";
case 4: case 4:
return "4-แบบประเมินคุณลักษณะบุคคล"; return "4-แบบประเมินคุณลักษณะบุคคล";
case 5: case 5:
return "5-แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก"; return "5-แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก (เอกสารหมายเลข 9)";
case 6: case 6:
return "6-ผลงานที่จะส่งประเมิน"; return "6-ผลงานที่จะส่งประเมิน (เอกสารหมายเลข 11)";
default: default:
return "1-แบบพิจารณาคุณสมบัติบุคคล"; return "1-แบบพิจารณาคุณสมบัติบุคคล";
} }
} }
onMounted(() => { onMounted(() => {
getFile(1) getFile(1);
}); });
</script> </script>

View file

@ -1,7 +1,22 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { ref, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
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";
const mixin = useCounterMixin();
const { date2Thai, showLoader, hideLoader, messageError } = mixin;
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 mesasger = ref<string>(""); const mesasger = ref<string>("");
const title = ref<string>(""); const title = ref<string>("");
const modalEvaluation = ref<boolean>(false); const modalEvaluation = ref<boolean>(false);
@ -9,35 +24,36 @@ const fileEvaluationUpload = ref<any>();
const status = ref<string>("WAIT_CHECK_DOC_V1"); const status = ref<string>("WAIT_CHECK_DOC_V1");
const files = [ const files = [
{ {
id: "x1", id: "file1",
fileName: "แบบพิจารณาคุณสมบัติบุคคล", fileName: "แบบพิจารณาคุณสมบัติบุคคล",
pathName: "12", pathName: "1-แบบพิจารณาคุณสมบัติบุคคล",
}, },
{ {
id: "x2", id: "file2",
fileName: "แบบแสดงรายละเอียดการเสนอผลงาน", fileName: "แบบแสดงรายละเอียดการเสนอผลงาน",
pathName: "12", pathName: "2-แบบแสดงรายละเอียดการเสนอผลงาน",
}, },
{ {
id: "x3", id: "file3",
fileName: fileName:
"แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลเพื่อประกอบการคัดเลือกบุคคล (เอกสารแบบ ก.)", "แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลเพื่อประกอบการคัดเลือกบุคคล (เอกสารแบบ ก.)",
pathName: "12", pathName:
"3-แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลเพื่อประกอบการคัดเลือกบุคคล (เอกสารแบบ ก.)",
}, },
{ {
id: "x4", id: "file4",
fileName: "แบบประเมินคุณลักษณะบุคคล", fileName: "แบบประเมินคุณลักษณะบุคคล",
pathName: "12", pathName: "4-แบบประเมินคุณลักษณะบุคคล",
}, },
{ {
id: "x5", id: "file5",
fileName: "แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก (เอกสารหมายเลข 9)", fileName: "แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก (เอกสารหมายเลข 9)",
pathName: "12", pathName: "5-แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก (เอกสารหมายเลข 9)",
}, },
{ {
id: "x6", id: "file6",
fileName: "ผลงานที่จะส่งประเมิน (เอกสารหมายเลข 11)", fileName: "ผลงานที่จะส่งประเมิน (เอกสารหมายเลข 11)",
pathName: "12", pathName: "6-ผลงานที่จะส่งประเมิน (เอกสารหมายเลข 11)",
}, },
]; ];
@ -46,21 +62,21 @@ async function onClickDowloadFile(
templateName: string, templateName: string,
fileName: string fileName: string
) { ) {
// showLoader(); showLoader();
// const data = Object.assign( const data = Object.assign(
// { fullName: fullName.value }, { fullName: fullName.value },
// tp === "EV1_005" || tp === "EV1_007" tp === "EV1_005" || tp === "EV1_007"
// ? { organizationName: "" } ? { organizationName: "หน่วยงาน" }
// : null, : null,
// tp === "EV1_007" ? { positionName: "" } : null, tp === "EV1_007" ? { positionName: "ตำแหน่ง" } : null,
// tp === "EV1_007" ? { positionLeaveName: "" } : null tp === "EV1_007" ? { positionLeaveName: "ระดับ" } : null
// ); );
// const body = { const body = {
// template: tp, template: tp,
// reportName: templateName, reportName: templateName,
// data: data, data: data,
// }; };
// await genReport(body, fileName); await genReport(body, fileName);
} }
/** ติดต่อผู้ขอประเมิน */ /** ติดต่อผู้ขอประเมิน */
@ -70,13 +86,64 @@ function openPopUp() {
} }
function downloadFile(name: string) { function downloadFile(name: string) {
console.log("11"); showLoader();
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) => {})
.finally(() => {
hideLoader();
});
}
function getPDF(url: string, type: string, fileName: string) {
axios
.get(url, {
method: "GET",
responseType: "blob",
headers: {
"Content-Type": "application/json",
Accept: type, //
},
})
.then(async (res) => {
console.log(res);
const a = document.createElement("a");
a.href = window.URL.createObjectURL(res.data);
a.download = fileName;
// a.download = res.data.fileName + `.${mime.getExtension(res.data.fileType)}`
a.click();
})
.catch((e) => {})
.finally(() => {});
} }
/** ส่งไปประกาศบนเว็บไซต์ */ /** ส่งไปประกาศบนเว็บไซต์ */
function onWebSite(){ function onWebSite() {}
} // function getFileList() {
// showLoader();
// http
// .get(config.API.evaluationFilebyId(" 1", id.value))
// .then((res) => {
// const fileList = res.data;
// files.forEach((file, index) => {
// const apiFile = fileList[index];
// file.pathName = apiFile.pathname;
// });
// console.log(files);
// })
// .catch((e) => {})
// .finally(() => {
// hideLoader();
// });
// }
</script> </script>
<template> <template>
@ -195,10 +262,6 @@ function onWebSite(){
</div> </div>
</div> </div>
<q-dialog v-model="modalEvaluation" persistent> <q-dialog v-model="modalEvaluation" persistent>
<q-card style="min-width: 60vw"> <q-card style="min-width: 60vw">
<q-toolbar> <q-toolbar>
@ -249,11 +312,7 @@ function onWebSite(){
label="ส่งข้อความ" label="ส่งข้อความ"
> >
</q-btn> </q-btn>
</div> </div>
</q-card> </q-card>
</q-dialog> </q-dialog>
</template> </template>

View file

@ -1,5 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { ref, watch } from "vue";
import { VuePDF, usePDF } from "@tato30/vue-pdf";
import { useEvaluateDetailStore } from "@/modules/12_evaluatePersonal/store/EvaluateDetail";
const store = useEvaluateDetailStore();
const splitterModel = ref(14); const splitterModel = ref(14);
const numOfPages = ref<number>(0); const numOfPages = ref<number>(0);
@ -19,6 +23,15 @@ function backPage() {
page.value--; page.value--;
} }
} }
watch(()=>store.log, () => {
if(store.log === 1){
numOfPages.value = store.numOfPagesStore;
pdfSrc.value = store.pdfSrcStore;
console.log('1',pdfSrc.value)
console.log('2',numOfPages.value)
}
});
</script> </script>
<template> <template>

View file

@ -63,14 +63,14 @@ export const useEvalutuonStore = defineStore("EvalutuonStore", () => {
function fetchData(data: any[]) { function fetchData(data: any[]) {
console.log(data); console.log(data);
const dataList: any[] = data.map((data: any) => ({ const dataList: any[] = data.map((data: any) => ({
id: data.Id, id: data.id,
citizanId: data.CitizenId, citizanId: data.citizenId,
fullName: data.FullName, fullName: data.fullName,
position: data.Position, position: data.position,
level: convertType(data.Type), level: convertType(data.type),
positionNumber: data.PosNo, positionNumber: data.posNo,
agency: data.Oc, agency: data.oc,
status: convertStatus(data.Step), status: convertStatus(data.step),
})); }));
rows.value = dataList; rows.value = dataList;
console.log(dataList); console.log(dataList);

View file

@ -20,6 +20,9 @@ export const useEvaluateDetailStore = defineStore("evaluateDetailStore", () => {
const tabPanels = ref<string>("1"); const tabPanels = ref<string>("1");
const log = ref<any>(0)
const pdfSrcStore = ref<any>()
const numOfPagesStore = ref<any>()
const columnsLicense = ref<QTableProps["columns"]>([ const columnsLicense = ref<QTableProps["columns"]>([
{ {
name: "", name: "",
@ -301,5 +304,8 @@ export const useEvaluateDetailStore = defineStore("evaluateDetailStore", () => {
columnPeriodhistory, columnPeriodhistory,
columnTrainingHistory, columnTrainingHistory,
columnProjectsProposed, columnProjectsProposed,
pdfSrcStore,
numOfPagesStore,
log
}; };
}); });