From adab68a63f97f3fb7a4ed52662426efd3e4fe848 Mon Sep 17 00:00:00 2001 From: "STW_TTTY\\stwtt" Date: Fri, 23 Aug 2024 13:33:26 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20download=20file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormEvaluation/Template2Format2.vue | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/modules/05_placement/components/probation/FormEvaluation/Template2Format2.vue b/src/modules/05_placement/components/probation/FormEvaluation/Template2Format2.vue index 5d3f4402a..b8943442f 100644 --- a/src/modules/05_placement/components/probation/FormEvaluation/Template2Format2.vue +++ b/src/modules/05_placement/components/probation/FormEvaluation/Template2Format2.vue @@ -6,6 +6,9 @@ import { useQuasar } from "quasar"; import { useRoute, useRouter } from "vue-router"; import { useCounterMixin } from "@/stores/mixin"; import { useProbationDataStore } from "@/modules/05_placement/storeProbation"; + +import genReport from "@/plugins/genreport"; + const probationStore = useProbationDataStore(); const { fecthdataAssign } = probationStore; @@ -59,35 +62,26 @@ const fecthAssign = async (id: string) => { hideLoader(); }); }; -const downloadFile = (response: any, filename: string) => { - const link = document.createElement("a"); - var fileName = filename; - link.href = window.URL.createObjectURL(new Blob([response.data])); - link.setAttribute("download", fileName); - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); -}; const FileDownload = async (type: string) => { let numTab = evaluate.value.find((e: any) => e.no === dataArrayNumber.value); showLoader(); await http - .get(config.API.reportEvaluateChairman(type, numTab.id), { - responseType: "blob", - }) + .get(config.API.reportEvaluateChairman(type, numTab.id)) .then(async (res) => { - downloadFile( - res, - `แบบประเมินผล(คณะกรรมการ)_${probationStore.person.name}_ครั้งที่${numTab.no}.${type}` + const data = res.data.result; + await genReport( + data, + `แบบประเมินผล(คณะกรรมการ)_${probationStore.person.name}_ครั้งที่${numTab.no}`, + type ); + hideLoader(); }) .catch(async (e) => { messageError($q, JSON.parse(await e.response.data.text())); - }) - .finally(() => { hideLoader(); - }); + }) + .finally(() => {}); }; const addData = () => { router.push( @@ -134,7 +128,13 @@ const changeTab = (tabVal: string) => {
- +