hrms-user/src/modules/06_evaluate/components/step/step3.vue

163 lines
5 KiB
Vue
Raw Normal View History

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