fix
This commit is contained in:
@@ -101,9 +101,9 @@
|
||||
<div class="admin_search_item" @click="searchHistoryList">
|
||||
Search
|
||||
</div>
|
||||
<!-- <div class="admin_search_item" @click="downloadTransaction">
|
||||
<div class="admin_search_item" @click="downloadTransaction">
|
||||
Export
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin_state_list">
|
||||
<div
|
||||
@@ -459,48 +459,26 @@ export default defineComponent({
|
||||
);
|
||||
};
|
||||
//导出报表
|
||||
let downloadTransaction = async () => {
|
||||
return
|
||||
let downloadTransaction = () => {
|
||||
filter.tableLoading = true;
|
||||
let data = setHistoryListData();
|
||||
// ?uniqueId=5956dc1e-3ae6-48bb-8c19-b7d9b4ba2332-1-83&userId=83&timeZone=Asia%2FShanghai&type=Generate
|
||||
|
||||
let jsonData:any = setHistoryListData()
|
||||
|
||||
let str = JSON.stringify(jsonData)
|
||||
let url = 'https://develop.api.aida.com.hk/api/inquiry/queryTransaction/download' + `?params=${encodeURIComponent(str)}`
|
||||
// const response:any = await axios.get(Https.httpUrls.queryTransactionDownload, {
|
||||
// responseType: 'blob', // 重要:确保设置响应类型为 'blob'
|
||||
// params:{params:str}
|
||||
// }).then((rv)=>{
|
||||
// console.log(rv);
|
||||
// })
|
||||
fetch(url,{
|
||||
headers: {
|
||||
'Authorization': `${getCookie('token')}`, // 添加 Bearer token 验证
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
console.log(response);
|
||||
|
||||
// return response.blob(); // 将响应转为 Blob 类型
|
||||
})
|
||||
.then((blob:any) => {
|
||||
// 创建一个 URL 对象链接 Blob 数据
|
||||
console.log(blob);
|
||||
|
||||
const objectURL = URL.createObjectURL(blob);
|
||||
// 创建一个临时的 <a> 标签
|
||||
const link = document.createElement('a');
|
||||
link.href = objectURL;
|
||||
link.download = 'download'; // 设置下载的文件名
|
||||
// 触发点击事件,下载文件
|
||||
link.click();
|
||||
// 清理
|
||||
URL.revokeObjectURL(objectURL); // 释放 objectURL
|
||||
})
|
||||
.catch(error => {
|
||||
});
|
||||
Https.axiosPost(Https.httpUrls.queryTransactionDownload, data).then(
|
||||
(rv: any) => {
|
||||
if (rv) {
|
||||
fetch(rv)
|
||||
.then(response => response.blob()) // 将响应转换为 Blob 对象
|
||||
.then(blob => {
|
||||
// 创建一个指向 Blob 对象的 URL
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(blob); // 将 Blob 对象转换为可下载的 URL
|
||||
link.download = 'transaction'; // 设置文件名
|
||||
filter.tableLoading = false;
|
||||
link.click(); // 触发下载
|
||||
URL.revokeObjectURL(link.href); // 释放 URL 对象
|
||||
})
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
let lastGeTrialList = (str: string) => {
|
||||
clearHistoryList();
|
||||
|
||||
Reference in New Issue
Block a user