Revert "Revert "V0.4.0 imporve error response""

This reverts commit acccdb65bd.
This commit is contained in:
yaziming
2019-09-04 20:41:37 +08:00
parent a5449a674a
commit 5e2b3ca228
51 changed files with 1373 additions and 416 deletions

View File

@@ -120,6 +120,22 @@ const actions = {
commit('SET_TASK_RESULTS_TOTAL_COUNT', response.data.total)
})
},
async getTaskResultExcel ({ state, commit }, id) {
const { data } = await request.request('GET', '/tasks/' + id + '/results/download', {}, {
responseType: 'blob' // important
})
const downloadUrl = window.URL.createObjectURL(new Blob([data]))
const link = document.createElement('a')
link.href = downloadUrl
link.setAttribute('download', 'data.csv') // any other extension
document.body.appendChild(link)
link.click()
link.remove()
},
cancelTask ({ state, dispatch }, id) {
return request.post(`/tasks/${id}/cancel`)
.then(() => {