Skip to content
Snippets Groups Projects
Commit e55f0d03 authored by Ahmad Saladin's avatar Ahmad Saladin
Browse files

download report

parent 9fefe6b2
Branches
Tags
2 merge requests!38Main,!37download report
......@@ -140,9 +140,23 @@ export default {
report(e){
e.preventDefault()
//download report
HTTP.get(`report/${this.emp.slug}?before=${this.endReport}&after=${this.startReport}`).then((res)=>{
console.log(res.data.data)
}).catch((e)=>{console.log(e.response.data)})
HTTP.get(`report/${this.emp.slug}?before=${this.endReport}&after=${this.startReport}`, {responseType: 'arraybuffer',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/pdf'
}
}).then((res)=>{
// console.log(res.data.data)
const url = window.URL.createObjectURL(new Blob([res.data]))
const link = document.createElement('a')
link.href = url
link.setAttribute('download', `KPI-Report-${this.emp.name}.pdf`)
document.body.appendChild(link)
link.click()
}).catch((e)=>{
console.log(e.response.data)
alert("Gagal Membuat Report")
})
// HTTP.get(`report/${this.emp.slug}?before=${this.endReport}`).then((res)=>{
// console.log(res.data.data)
// }).catch((e)=>{console.log(e.response.data)})
......@@ -151,7 +165,6 @@ export default {
HTTP.get(`employees/${this.slug}`).then((res)=>{
this.emp = res.data.data
this.endpoint = `kpis/assigned/${this.emp.id}`
console.log(this.emp)
}).catch(()=> {alert("Error loading page")})
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment