166 lines
5.1 KiB
Vue
166 lines
5.1 KiB
Vue
<script setup lang="ts">
|
|
import { ref, onMounted } from "vue";
|
|
import { useRoute } from "vue-router";
|
|
import { useQuasar } from "quasar";
|
|
import http from "@/plugins/http";
|
|
import config from "@/app.config";
|
|
import axios from "axios";
|
|
|
|
/** importStroe*/
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
import { useEvaluateStore } from "@/modules/06_evaluate/store";
|
|
|
|
/** use*/
|
|
const $q = useQuasar();
|
|
const store = useEvaluateStore();
|
|
const mixin = useCounterMixin();
|
|
const route = useRoute();
|
|
const { showLoader, hideLoader, messageError } = mixin;
|
|
|
|
/** id ประเมิน*/
|
|
const evaluateId = ref<string>(route.params.id.toString());
|
|
|
|
/** emit*/
|
|
const emit = defineEmits(["update:file"]);
|
|
|
|
const selectedItem = ref(1);
|
|
const fileName = ref([
|
|
"1-แบบพิจารณาคุณสมบัติบุคคล",
|
|
"2-แบบแสดงรายละเอียดการเสนอผลงาน",
|
|
"3-แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลเพื่อประกอบการคัดเลือกบุคคล (เอกสารแบบ ก)",
|
|
"4-แบบประเมินคุณลักษณะบุคคล",
|
|
"5-แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก (เอกสารหมายเลข 9)",
|
|
"6-ผลงานที่จะส่งประเมิน (เอกสารหมายเลข 11)",
|
|
]);
|
|
|
|
/**
|
|
* function กดเลือกแสดงเอกสาน
|
|
* @param itemNumber เอกสาร
|
|
*/
|
|
function handleItemClick(itemNumber: number) {
|
|
store.tabPanels = itemNumber.toString();
|
|
selectedItem.value = itemNumber;
|
|
fetchDocument(fileName.value[itemNumber - 1]);
|
|
}
|
|
|
|
/**
|
|
* function เรีกยเอกสาร
|
|
* @param fileName ชื่อเอกสาร
|
|
*/
|
|
async function fetchDocument(fileName: string) {
|
|
showLoader();
|
|
evaluateId.value &&
|
|
(await http
|
|
.get(config.API.loadFileDocument("เล่ม 1", evaluateId.value, fileName))
|
|
.then((res) => {
|
|
downloadFile(res.data.downloadUrl);
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
})
|
|
.finally(() => {
|
|
showLoader();
|
|
}));
|
|
}
|
|
|
|
/**
|
|
* function ดาวน์โหลดไฟล์
|
|
* @param url ลิงก์ดาวน์โหลดไฟล์
|
|
*/
|
|
async function downloadFile(url: string) {
|
|
showLoader();
|
|
await axios
|
|
.get(url, {
|
|
responseType: "blob",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
})
|
|
.then((res) => {
|
|
console.log(url);
|
|
|
|
const blob = new Blob([res.data]);
|
|
const objectUrl = URL.createObjectURL(blob);
|
|
console.log(objectUrl);
|
|
|
|
emit("update:file", objectUrl, url);
|
|
})
|
|
.catch((err) => {
|
|
messageError($q, err);
|
|
})
|
|
.finally(() => {
|
|
hideLoader();
|
|
});
|
|
}
|
|
|
|
/** HooK lifecycle*/
|
|
onMounted(async () => {
|
|
await fetchDocument(fileName.value[selectedItem.value - 1]);
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<q-list separator>
|
|
<q-item
|
|
clickable
|
|
v-ripple
|
|
:active="selectedItem === 1 ? true : false"
|
|
active-class="text-primary"
|
|
@click="handleItemClick(1)"
|
|
>
|
|
<q-item-section>แบบพิจารณาคุณสมบัติบุคคล</q-item-section>
|
|
</q-item>
|
|
<q-item
|
|
clickable
|
|
v-ripple
|
|
:active="selectedItem === 2 ? true : false"
|
|
active-class="text-primary"
|
|
@click="handleItemClick(2)"
|
|
>
|
|
<q-item-section>แบบแสดงรายละเอียดการเสนอผลงาน</q-item-section>
|
|
</q-item>
|
|
<q-item
|
|
clickable
|
|
v-ripple
|
|
:active="selectedItem === 3 ? true : false"
|
|
active-class="text-primary"
|
|
@click="handleItemClick(3)"
|
|
>
|
|
<q-item-section
|
|
>แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลเพื่อประกอบการคัดเลือกบุคคล
|
|
(เอกสารแบบ ก)</q-item-section
|
|
>
|
|
</q-item>
|
|
<q-item
|
|
clickable
|
|
v-ripple
|
|
:active="selectedItem === 4 ? true : false"
|
|
active-class="text-primary"
|
|
@click="handleItemClick(4)"
|
|
>
|
|
<q-item-section> แบบประเมินคุณลักษณะบุคคล </q-item-section>
|
|
</q-item>
|
|
<q-item
|
|
clickable
|
|
v-ripple
|
|
:active="selectedItem === 5 ? true : false"
|
|
active-class="text-primary"
|
|
@click="handleItemClick(5)"
|
|
>
|
|
<q-item-section>
|
|
แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก (เอกสารหมายเลข 9)
|
|
</q-item-section>
|
|
</q-item>
|
|
<q-item
|
|
clickable
|
|
v-ripple
|
|
:active="selectedItem === 6 ? true : false"
|
|
active-class="text-primary"
|
|
@click="handleItemClick(6)"
|
|
>
|
|
<q-item-section> ผลงานที่จะส่งประเมิน (เอกสารหมายเลข 11) </q-item-section>
|
|
</q-item>
|
|
</q-list>
|
|
</template>
|
|
|
|
<style scoped></style>
|