diff --git a/src/api/common/api.ts b/src/api/common/api.ts index da434a9..bd30436 100644 --- a/src/api/common/api.ts +++ b/src/api/common/api.ts @@ -15,7 +15,9 @@ import axios from 'axios'; * @returns {*} */ export const downloadFile = (url, fileName?, parameter?) => { + return getFileblob(url, parameter).then((data) => { + if (!data || data.size === 0) { message.warning('文件下载失败'); return; @@ -33,7 +35,10 @@ export const downloadFile = (url, fileName?, parameter?) => { document.body.removeChild(link); //下载完成移除元素 window.URL.revokeObjectURL(url); //释放掉blob对象window.btoa(unescape(encodeURIComponent('我是一段需要处理的字符'))) } - }); + }) + .catch(error=>{ + message.error(error.message) + }) }; export const downloadonlinePreview = async (url, fileName,parameter) =>{ diff --git a/src/views/projectBoard/unfinishNode/index.vue b/src/views/projectBoard/unfinishNode/index.vue index caf41ea..4451e95 100644 --- a/src/views/projectBoard/unfinishNode/index.vue +++ b/src/views/projectBoard/unfinishNode/index.vue @@ -35,6 +35,7 @@ import { onMounted, ref, nextTick, computed } from 'vue'; import { downloadFile } from '@/api/common/api'; import dayjs from 'dayjs'; +import { message } from 'ant-design-vue'; const tableLoading = ref(false); const btnLoading1 = ref(false); const btnLoading2 = ref(false); @@ -109,7 +110,9 @@ btnLoading2.value = true; downloadFile('/export/timeOutInfo', `评分表${nowTime.value}.xlsx`, {}).then((_) => { btnLoading2.value = false; - }); + }).catch(err=>{ + message.error(err.message); + }) } function handleProjectResult() { btnLoading3.value = true;