mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-24 10:12:54 +08:00
下载的从新封装一下
This commit is contained in:
@@ -2,15 +2,15 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {*} data 文件流Blob对象
|
* @param {*} data 文件流Blob对象
|
||||||
* @param {*} mimeType 类型
|
* @param {String} fileType [导出文件类型] 默认值 xls
|
||||||
* @param {*} fileName 名字
|
* @param {String} fileName [导出文件名称] 默认值 导出文件
|
||||||
*/
|
*/
|
||||||
const useDownload = (data, fileName, mimeType = 'application/vnd.ms-excel;charset=UTF-8') => {
|
const useDownload = (data, fileName = '导出文件', fileType = 'xls') => {
|
||||||
const link = document.createElement('a');// 创建a标签
|
const link = document.createElement('a');// 创建a标签
|
||||||
let blob = new Blob([data], { type: mimeType }); // 设置文件类型
|
// let blob = new Blob([data], { type: mimeType }); // 设置文件类型
|
||||||
link.style.display = "none";
|
link.style.display = "none";
|
||||||
link.href = URL.createObjectURL(blob); // 创建URL
|
link.href = URL.createObjectURL(data); // 创建URL
|
||||||
link.setAttribute("download", fileName);
|
link.setAttribute("download", `${fileName}.${fileType}`);
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
URL.revokeObjectURL(link.href);
|
URL.revokeObjectURL(link.href);
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ function handleOper(record, type) {
|
|||||||
const downloadInfo = (record) => {
|
const downloadInfo = (record) => {
|
||||||
caseInfoDownload({ casesRecommendId: record.id })
|
caseInfoDownload({ casesRecommendId: record.id })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
useDownload(res.data, '案例信息.xls')
|
useDownload(res.data, '案例信息')
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
message.info("信息下载失败");
|
message.info("信息下载失败");
|
||||||
|
|||||||
Reference in New Issue
Block a user