Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

fix: check permission and feedback ui download something #167

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions app/pages/paths/management/ManageDets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default {
maxCount: null,
targetGrade: null,
endDate: new Date()
}
},
percentages: 100
}
},

Expand Down Expand Up @@ -93,6 +94,14 @@ export default {
}
},

async download () {
try {
await detsManager.getExcel()
} catch (err) {
this.$swal('이런!', err.message, 'error')
}
},

openEditModal (dets) {
this.modals.edit = true
this.currentDets = dets
Expand Down Expand Up @@ -168,7 +177,7 @@ export default {
</span>
<span
class="dets__excel"
onclick="location.href='http://dev-api.dimigo.in/dets/excel'"
@click="download()"
>
<span class="icon-long-arrow-down" />엑셀 다운로드
</span>
Expand Down
14 changes: 14 additions & 0 deletions app/src/api/dets/dets.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,18 @@ export class DetsManagerService extends DetsService {
403: '권한이 없습니다.'
})
}

async getExcel () {
taevel02 marked this conversation as resolved.
Show resolved Hide resolved
const { data } = await this.magician(() => this.r.get(`/excel`, {
responseType: 'blob'
}), {
403: '권한이 없습니다.',
default: '파일을 다운로드하던 중 문제가 발생했습니다.'
})
const link = document.createElement('a')
link.href = window.URL.createObjectURL(new Blob([data]))
link.setAttribute('download', 'dets.xls')
document.body.appendChild(link)
link.click()
}
}