|
@@ -176,44 +176,61 @@ const uploadFile = (params, channelNo = 'service', callback1) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-const downloadFile = (params, channelNo = 'service') => {
|
|
|
- const config = {
|
|
|
- timeout: 60000,
|
|
|
-
|
|
|
- }
|
|
|
+// const downloadFile = (params, channelNo = 'service') => {
|
|
|
+// const config = {
|
|
|
+// timeout: 60000,
|
|
|
+// }
|
|
|
|
|
|
- const url = getUrl(channelNo) // 获取请求地址
|
|
|
+// const url = getUrl(channelNo) // 获取请求地址
|
|
|
|
|
|
- // 加上公共参数
|
|
|
- const fullParams = {
|
|
|
- ...params,
|
|
|
- clientToken: getToken(),
|
|
|
- userId: getUserId(),
|
|
|
- channelNo
|
|
|
- }
|
|
|
+// // 加上公共参数
|
|
|
+// const fullParams = {
|
|
|
+// ...params,
|
|
|
+// clientToken: getToken(),
|
|
|
+// userId: getUserId(),
|
|
|
+// channelNo
|
|
|
+// }
|
|
|
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- axios.post(url, fullParams, config).then(response => {
|
|
|
- // 提取文件名(如果后端在 header 中返回了 Content-Disposition)
|
|
|
- const disposition = response.headers['content-disposition']
|
|
|
- let fileName = 'downloaded_file'
|
|
|
- if (disposition && disposition.includes('filename=')) {
|
|
|
- fileName = decodeURIComponent(disposition.split('filename=')[1].replace(/"/g, ''))
|
|
|
- }
|
|
|
+// return new Promise((resolve, reject) => {
|
|
|
+// axios.post(url, fullParams, config).then(response => {
|
|
|
+// // 提取文件名(如果后端在 header 中返回了 Content-Disposition)
|
|
|
+// const disposition = response.headers['content-disposition']
|
|
|
+// let fileName = 'downloaded_file'
|
|
|
+// if (disposition && disposition.includes('filename=')) {
|
|
|
+// fileName = decodeURIComponent(disposition.split('filename=')[1].replace(/"/g, ''))
|
|
|
+// }
|
|
|
|
|
|
- // 创建 blob 链接进行下载
|
|
|
- const blob = new Blob([response.data])
|
|
|
- const link = document.createElement('a')
|
|
|
- link.href = URL.createObjectURL(blob)
|
|
|
- link.download = fileName
|
|
|
- link.click()
|
|
|
- URL.revokeObjectURL(link.href)
|
|
|
-
|
|
|
- resolve(response)
|
|
|
- }).catch(error => {
|
|
|
- reject(error)
|
|
|
- })
|
|
|
- })
|
|
|
+// // 创建 blob 链接进行下载
|
|
|
+// const blob = new Blob([response.data])
|
|
|
+// const link = document.createElement('a')
|
|
|
+// link.href = URL.createObjectURL(blob)
|
|
|
+// link.download = fileName
|
|
|
+// link.click()
|
|
|
+// URL.revokeObjectURL(link.href)
|
|
|
+
|
|
|
+// resolve(response)
|
|
|
+// }).catch(error => {
|
|
|
+// reject(error)
|
|
|
+// })
|
|
|
+// })
|
|
|
+// }
|
|
|
+
|
|
|
+const downloadFile = (id, channelNo = 'service') => {
|
|
|
+ const token = getToken();
|
|
|
+ const userId = getUserId();
|
|
|
+ const url = import.meta.env.VITE_BASE_URL + getUrl(channelNo)
|
|
|
+ + "?transCode=MDO0080&clientToken=" + token + "&pid=" + id
|
|
|
+ + "&userId=" + userId;
|
|
|
+
|
|
|
+ // 创建隐藏 a 标签下载
|
|
|
+ const link = document.createElement('a');
|
|
|
+ console.log('下载链接:', url);
|
|
|
+ link.href = url;
|
|
|
+ link.download = '';
|
|
|
+ link.target = '_blank';
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link);
|
|
|
}
|
|
|
|
|
|
// 获取图片验证码
|