diff --git a/src/api/archivesManage/outInStorage.js b/src/api/archivesManage/outInStorage.js index a91ac3e..e2d0775 100644 --- a/src/api/archivesManage/outInStorage.js +++ b/src/api/archivesManage/outInStorage.js @@ -35,7 +35,7 @@ export function grant(params) { // 出入库记录 导出 export function exportStorageLogList(params) { return request({ - url: 'api/storage/exportStorageLogList' + '?' + qs.stringify(params, { indices: false }), + url: 'api/storage/exportStorageLogList' + '?' + qs.stringify(params, { responseType: 'blob' }), method: 'get' }) } diff --git a/src/views/archivesManage/outInStorage/outInHistory/index.vue b/src/views/archivesManage/outInStorage/outInHistory/index.vue index f459c09..b19440b 100644 --- a/src/views/archivesManage/outInStorage/outInHistory/index.vue +++ b/src/views/archivesManage/outInStorage/outInHistory/index.vue @@ -2,7 +2,7 @@
- 导出 + 导出 @@ -77,7 +77,7 @@ import pagination from '@crud/Pagination' // import { exportFile } from '@/utils/index' import detailDialog from '../module/detailDialog.vue' // import { mapGetters } from 'vuex' -import { initCaseByArchives } from '@/api/archivesManage/outInStorage' +import { exportStorageLogList } from '@/api/archivesManage/outInStorage' // exportFile内容 export default { @@ -171,15 +171,30 @@ export default { } }, // 导出 - handleExport() { + handleDownload() { this.crud.downloadLoading = true - // exportFile(this.baseApi + '/api/storage/exportStorageLogList') - // console.log(this.baseApi) + this.downloadApi() + this.crud.downloadLoading = false + }, + // 导出接口调用 + async downloadApi() { const params = this.selections.map(item => { return item.id }) - initCaseByArchives(params).then(res => { + console.log(params, '======') + await exportStorageLogList({ logIds: params }).then(res => { + this.downloadExcel(res, '出入库记录.xls') console.log(res, '导出成功') }) - this.crud.downloadLoading = false + }, + downloadExcel(res, fileName) { + const content = res + const blob = new Blob([content]) + const elink = document.createElement('a') + elink.style.display = 'none' + elink.download = fileName + elink.href = URL.createObjectURL(blob) + document.body.appendChild(elink) + elink.click() + URL.revokeObjectURL(elink.href) // 释放URL }, // 双击 详情 handleDbClick(row) {