ปรับ 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,33 +1,41 @@
<script setup lang="ts">
import { reactive, ref, onMounted } from "vue";
import { VuePDF, usePDF } from "@tato30/vue-pdf";
import { useCounterMixin } from "@/stores/mixin";
import { useEvaluateDetailStore } from "@/modules/12_evaluatePersonal/store/EvaluateDetail";
import { ref, onMounted } from "vue";
import { usePDF } from "@tato30/vue-pdf";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import axios from "axios";
import { useRouter, useRoute } from "vue-router";
import { useQuasar } from "quasar";
/** importStore*/
import { useEvaluateDetailStore } from "@/modules/12_evaluatePersonal/store/EvaluateDetail";
import { useCounterMixin } from "@/stores/mixin";
/** use*/
const $q = useQuasar();
const router = useRouter();
const route = useRoute();
const id = ref<string>(route.params.id as string);
const store = useEvaluateDetailStore();
const mixin = useCounterMixin();
const { date2Thai, showLoader, hideLoader, messageError } = mixin;
const { showLoader, hideLoader, messageError } = mixin;
const selectedItem = ref(1);
const id = ref<string>(route.params.id as string);
const selectedItem = ref<number>(1);
/**
* funtion เลอกไฟล
* @param itemNumber indexItems
*/
function handleItemClick(itemNumber: number) {
store.tabPanels = itemNumber.toString();
selectedItem.value = itemNumber;
getFile(itemNumber);
}
// evaluationFilebyId
/**
* function เรยกไฟล
* @param volume index item
*/
function getFile(volume: number) {
const fileText = numToThai(volume);
console.log(fileText);
@ -37,10 +45,9 @@ function getFile(volume: number) {
.then((res) => {
const link = res.data.downloadUrl;
const type = res.data.fileType;
console.log(link, type);
getPDF(link, type);
})
.catch((e) => {
.catch(() => {
// messageError($q, e);
})
.finally(() => {
@ -48,7 +55,13 @@ function getFile(volume: number) {
});
}
/**
* function loafFile PDF
* @param url linkLoadFile
* @param type ประเภทไฟล
*/
function getPDF(url: string, type: string) {
showLoader();
axios
.get(url, {
method: "GET",
@ -60,12 +73,11 @@ function getPDF(url: string, type: string) {
})
.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.urlDownloadFile = url;
store.log = 1;
@ -82,6 +94,10 @@ function getPDF(url: string, type: string) {
});
}
/**
* function Convert อไฟล
* @param val indexItems
*/
function numToThai(val: number) {
switch (val) {
case 1:
@ -91,8 +107,8 @@ function numToThai(val: number) {
}
}
onMounted(() => {
getFile(1);
onMounted(async () => {
await getFile(selectedItem.value);
});
</script>