โหลดใบสมัคร
This commit is contained in:
parent
96f92a5b69
commit
428670b515
5 changed files with 312 additions and 152 deletions
|
|
@ -195,6 +195,7 @@ const score_expired = ref<Date | null>(new Date())
|
|||
const number = ref<string>('')
|
||||
const reviewPoint = ref<number>(0)
|
||||
const review = ref<string>('-')
|
||||
const candidateId = ref<string>('')
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchStatus()
|
||||
|
|
@ -232,6 +233,7 @@ const fetchStatus = async () => {
|
|||
positionLevel.value = data.positionLevel
|
||||
reviewPoint.value = data.reviewPoint
|
||||
review.value = data.review == null ? '-' : data.review
|
||||
candidateId.value = data.id
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e)
|
||||
|
|
@ -241,8 +243,33 @@ const fetchStatus = async () => {
|
|||
})
|
||||
}
|
||||
|
||||
const download = () => {
|
||||
window.print()
|
||||
const download = async () => {
|
||||
loaderPage(true)
|
||||
await http
|
||||
.get(config.API.candidateReport(candidateId.value), {
|
||||
responseType: 'blob'
|
||||
})
|
||||
.then((res) => {
|
||||
const data = res.data
|
||||
downloadFilePDF(data, `ใบสมัครสอบ.pdf`)
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e)
|
||||
})
|
||||
.finally(() => {
|
||||
loaderPage(false)
|
||||
})
|
||||
}
|
||||
const downloadFilePDF = async (res: string, fileName: string) => {
|
||||
const link = document.createElement('a')
|
||||
link.href = window.URL.createObjectURL(
|
||||
new Blob([res], {
|
||||
type: 'application/vnd.ms-excel'
|
||||
})
|
||||
)
|
||||
link.setAttribute('download', fileName)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue