เพิ่ม โหลด pdf

This commit is contained in:
STW_TTTY\stwtt 2024-09-30 14:35:32 +07:00
parent f74fcdf9e0
commit 3b1e85168b
5 changed files with 94 additions and 16 deletions

View file

@ -159,13 +159,16 @@
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useQuasar } from 'quasar'
import { useRoute } from 'vue-router'
import { useCounterMixin } from '@/stores/mixin'
import { useDataStore } from '@/stores/data'
import { onMounted, ref } from 'vue'
import http from '@/plugins/http'
import config from '@/app.config'
import { useQuasar } from 'quasar'
import { useCounterMixin } from '@/stores/mixin'
import { useDataStore } from '@/stores/data'
import genReport from '@/plugins/genreport'
const $q = useQuasar()
const route = useRoute()
@ -246,19 +249,17 @@ const fetchStatus = async () => {
const download = async () => {
loaderPage(true)
await http
.get(config.API.candidateReport(candidateId.value), {
responseType: 'blob'
})
.then((res) => {
const data = res.data
downloadFilePDF(data, `ใบสมัครสอบ.pdf`)
.get(config.API.candidateReport(candidateId.value))
.then(async (res) => {
const data = await res.data.result
await genReport(data, `ใบสมัครสอบ`, 'pdf')
loaderPage(false)
})
.catch((e) => {
messageError($q, e)
})
.finally(() => {
loaderPage(false)
})
.finally(() => {})
}
const downloadFilePDF = async (res: string, fileName: string) => {
const link = document.createElement('a')