Browse Source

导出功能修改

dev_web_online
陈薪名 2 years ago
parent
commit
c4771f20d2
  1. 1
      fe/PC/src/api/wms-api.js
  2. 14
      fe/PC/src/mixins/TableHeaderMixins.js
  3. 2
      fe/PC/src/mixins/mixins.js

1
fe/PC/src/api/wms-api.js

@ -81,6 +81,7 @@ export function postExport(data, url, special) {
url: _url, url: _url,
method: 'post', method: 'post',
data, data,
responseType: 'blob'
}) })
} }
//导出(详情内)-获取文件 blobName | 盘点计划 //导出(详情内)-获取文件 blobName | 盘点计划

14
fe/PC/src/mixins/TableHeaderMixins.js

@ -77,13 +77,7 @@ export const TableHeaderMixins = {
let _exportUrl = item.url ? item.url : this.URL; let _exportUrl = item.url ? item.url : this.URL;
let _special = (item.url && item.url.length > 0) ? true : false let _special = (item.url && item.url.length > 0) ? true : false
postExport(this.PageListParams, _exportUrl, _special).then(res => { postExport(this.PageListParams, _exportUrl, _special).then(res => {
fileStorage({blobName: res.blobName}).then( fileStorageRes => { this.blob(res, name)//使用前端导出名称
// this.downloadFile(fileStorageRes.bytes, name)//使用前端导出名称
this.downloadFile(fileStorageRes.bytes, fileStorageRes.fileName)//使用后端导出名称
}).catch( err => {
console.log(err)
})
this.Loading.appMainLoading = false this.Loading.appMainLoading = false
}).catch(err => { }).catch(err => {
this.Loading.appMainLoading = false this.Loading.appMainLoading = false
@ -99,11 +93,7 @@ export const TableHeaderMixins = {
params.route = this.URL + '/export' params.route = this.URL + '/export'
params.function = name params.function = name
postExport(params, this.URL).then(res => { postExport(params, this.URL).then(res => {
fileStorage({blobName: res.blobName}).then( fileStorageRes => { this.blob(res, name)//使用前端导出名称
this.downloadFile(fileStorageRes.bytes, fileStorageRes.fileName)
}).catch( err => {
console.log(err)
})
this.Loading.appMainLoading = false this.Loading.appMainLoading = false
}).catch(err => { }).catch(err => {
this.Loading.appMainLoading = false this.Loading.appMainLoading = false

2
fe/PC/src/mixins/mixins.js

@ -227,7 +227,7 @@ export const mixins = {
//导出存储-新 //导出存储-新
blob(res, fileName) { blob(res, fileName) {
let blob = new Blob([res], { let blob = new Blob([res], {
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8',
}) })
const href = URL.createObjectURL(blob) //创建新的URL表示指定的blob对象 const href = URL.createObjectURL(blob) //创建新的URL表示指定的blob对象
const a = document.createElement('a') //创建a标签 const a = document.createElement('a') //创建a标签

Loading…
Cancel
Save