|
@@ -20,7 +20,7 @@
|
|
|
label="附件"
|
|
|
width="240">
|
|
|
<template slot-scope="scope">
|
|
|
- <span @click="downfile(scope.row.annex)" class="downfile">{{ scope.row.annexName }}</span>
|
|
|
+ <span @click="downfile(scope.row)" class="downfile">{{ scope.row.annexName }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
@@ -171,9 +171,30 @@
|
|
|
.catch(_ => {});
|
|
|
},
|
|
|
downfile(e){
|
|
|
- readFile(e).then(response => {
|
|
|
- window.open('https://dev-sy.derom.com/document-center/minio/'+response.data.filepath);
|
|
|
- });
|
|
|
+ readFile(e.annex).then(response => {
|
|
|
+ let fileUrl = 'https://dev-sy.derom.com/document-center/minio/'+response.data.filepath;
|
|
|
+ let fileName = e.annexName;
|
|
|
+ fetch(fileUrl)
|
|
|
+ .then((response) => response.blob())
|
|
|
+ .then((blob) => {
|
|
|
+ // 创建一个临时的URL对象
|
|
|
+ const url = URL.createObjectURL(blob);
|
|
|
+ // 创建一个隐藏的<a>标签,并设置其href属性为临时URL
|
|
|
+ const a = document.createElement('a');
|
|
|
+ a.href = url;
|
|
|
+ a.download = fileName; // 设置下载的文件名
|
|
|
+ a.style.display = 'none';
|
|
|
+ // 将<a>标签添加到文档中,并模拟点击下载
|
|
|
+ document.body.appendChild(a);
|
|
|
+ a.click();
|
|
|
+ // 下载完成后,移除<a>标签和临时URL对象
|
|
|
+ document.body.removeChild(a);
|
|
|
+ URL.revokeObjectURL(url);
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.error('下载文件时出错:', error);
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
onSuccess(e){
|
|
|
this.thisFile.push({id:e.id,
|