parent
3a02832e08
commit
4123236854
|
@ -216,7 +216,7 @@ const refreshTken = function () {
|
||||||
* @param method
|
* @param method
|
||||||
* @param filename
|
* @param filename
|
||||||
*/
|
*/
|
||||||
export const downloadFile = function ({ url, params, method, filename="文件导出" }) {
|
export const downloadFile = function ({ url, params, method, filename= '文件导出' }) {
|
||||||
request({
|
request({
|
||||||
url: url,
|
url: url,
|
||||||
method: method,
|
method: method,
|
||||||
|
@ -224,7 +224,8 @@ export const downloadFile = function ({ url, params, method, filename="文件导
|
||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
// headers: {Accept: 'application/vnd.openxmlformats-officedocument'}
|
// headers: {Accept: 'application/vnd.openxmlformats-officedocument'}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
const fileName = window.decodeURI(filename + '.xlsx' || res.headers['content-disposition'].split('=')[1]) || '文件导出.xlsx'
|
const xlsxName = window.decodeURI(res.headers['content-disposition'].split('=')[1])
|
||||||
|
const fileName = xlsxName || `${filename}.xlsx`
|
||||||
if (res) {
|
if (res) {
|
||||||
const blob = new Blob([res.data], { type: 'charset=utf-8' })
|
const blob = new Blob([res.data], { type: 'charset=utf-8' })
|
||||||
const elink = document.createElement('a')
|
const elink = document.createElement('a')
|
||||||
|
|
Loading…
Reference in New Issue