修复请假流程中附件下载功能
This commit is contained in:
1 parent
0573954221
commit
3f2b92eb4a
1 file changed
+14
-1
@@ -594,8 +594,21 @@ const handleDownloadAttachment = async (file: any) => {
|
||||
if (!response) {
|
||||
throw new Error('响应数据为空');
|
||||
}
|
||||
console.log('response', response);
|
||||
|
||||
const url = window.URL.createObjectURL(response.data as Blob);
|
||||
// 检查response的结构,判断是直接的Blob还是包含data属性的响应对象
|
||||
let blobData: Blob;
|
||||
if (response instanceof Blob) {
|
||||
// 如果response本身就是Blob对象
|
||||
blobData = response;
|
||||
} else if (response.data instanceof Blob) {
|
||||
// 如果response.data是Blob对象
|
||||
blobData = response.data;
|
||||
} else {
|
||||
throw new Error('无效的响应数据格式');
|
||||
}
|
||||
|
||||
const url = window.URL.createObjectURL(blobData);
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
|
||||
Reference in new issue
Block a user