download
parent
4762eeab6d
commit
e460f44d0d
|
@ -47,7 +47,7 @@ export function downloadRequest(url, params) {
|
||||||
data: params,
|
data: params,
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,43 +343,41 @@ const save_room = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const exc = async () => {
|
const exc = async () => {
|
||||||
const param = {
|
const param = {
|
||||||
action: 90001,
|
action: 90001,
|
||||||
data: project,
|
data: project,
|
||||||
};
|
};
|
||||||
try {
|
|
||||||
const res = await myApi.download(param);
|
const res = await myApi.download(param);
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (1) {
|
const url = window.URL.createObjectURL(new Blob([res]));
|
||||||
// 文件下载成功
|
const link = document.createElement('a');
|
||||||
const blob = new Blob([res.data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
|
link.href = url;
|
||||||
const url = window.URL.createObjectURL(blob);
|
link.download = 'xx.xlsx';
|
||||||
const link = document.createElement("a");
|
document.body.appendChild(link);
|
||||||
link.href = url;
|
link.click();
|
||||||
link.download = 'xx.xlsx'; // 设置下载的文件名
|
link.remove();
|
||||||
document.body.appendChild(link);
|
window.URL.revokeObjectURL(url);
|
||||||
link.click();
|
//
|
||||||
link.remove();
|
// ElMessage({
|
||||||
window.URL.revokeObjectURL(url);
|
// message: "保存成功",
|
||||||
ElMessage({
|
// type: "success",
|
||||||
message: "保存成功",
|
// });
|
||||||
type: "success",
|
// } else {
|
||||||
});
|
// // 下载失败,显示错误信息
|
||||||
} else {
|
// ElMessage({
|
||||||
// 下载失败,显示错误信息
|
// message: res.message + "[" + res.data + "]",
|
||||||
ElMessage({
|
// type: "warning",
|
||||||
message: res.message + "[" + res.data + "]",
|
// });
|
||||||
type: "warning",
|
// }
|
||||||
});
|
// } catch (error) {
|
||||||
}
|
// // 捕获并处理可能的错误
|
||||||
} catch (error) {
|
// console.error("Error downloading file:", error);
|
||||||
// 捕获并处理可能的错误
|
// ElMessage({
|
||||||
console.error("Error downloading file:", error);
|
// message: "下载文件时发生错误",
|
||||||
ElMessage({
|
// type: "error",
|
||||||
message: "下载文件时发生错误",
|
// });
|
||||||
type: "error",
|
// // }
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function generateShortUUID() {
|
function generateShortUUID() {
|
||||||
|
|
Loading…
Reference in New Issue