Browse Source

出入库记录 导出

master
x_ying 3 years ago
parent
commit
16f5a80f49
  1. 2
      src/api/archivesManage/outInStorage.js
  2. 29
      src/views/archivesManage/outInStorage/outInHistory/index.vue

2
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'
})
}

29
src/views/archivesManage/outInStorage/outInHistory/index.vue

@ -2,7 +2,7 @@
<div>
<div class="head-container">
<!-- <crudOperation /> -->
<el-button v-permission="permission.download" :loading="crud.downloadLoading" :disabled="!selections.length" size="mini" icon="el-icon-download" @click="handleExport">导出</el-button>
<el-button v-permission="permission.download" :loading="crud.downloadLoading" :disabled="!selections.length" size="mini" icon="el-icon-download" @click="handleDownload">导出</el-button>
<el-select v-model="storageType" class="filter-item" style="width: 100px; height: 30px;margin:0 0 0 10px" @change="crud.toQuery">
<el-option v-for="item in storageTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
@ -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) {

Loading…
Cancel
Save