Browse Source

完善车辆销售台账--导出

master
yunuo970428 2 years ago
parent
commit
3cc477d783
  1. 2
      anrui-scm/anrui-scm-ui/src/api/cheliang/cheliangxiaoshou.js
  2. 49
      anrui-scm/anrui-scm-ui/src/views/cheliang/cheliangxiaoshou/cheliangxiaoshouguanli.vue

2
anrui-scm/anrui-scm-ui/src/api/cheliang/cheliangxiaoshou.js

@ -42,7 +42,7 @@ export function exportExcel(data) {
return request({
url: '/base/v1/basevehicleout/exportExcel',
method: 'post',
responseType: 'blob' , // 表明返回服务器返回的数据类型
responseType: 'blob', // 表明返回服务器返回的数据类型
data: data,
headers: { 'Content-Type': 'application/json' }
})

49
anrui-scm/anrui-scm-ui/src/views/cheliang/cheliangxiaoshou/cheliangxiaoshouguanli.vue

@ -515,34 +515,29 @@ export default {
},
//
doExport() {
if (this.sids.length > 0) {
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
exportExcel(this.sids).then((resp) => {
loading.close()
const blob = new Blob([resp], {
type: 'application/vnd.ms-excel'
})
const fileName = '车辆销售台账表' + '.xls'
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'nonde'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href)
document.body.removeChild(elink)
}).catch(() => {
loading.close()
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
exportExcel(this.listQuery.params).then((resp) => {
loading.close()
const blob = new Blob([resp], {
type: 'application/vnd.ms-excel'
})
} else {
this.$message({ showClose: true, type: 'error', message: '请至少选择一条记录进行导出操作' })
return
}
const fileName = '车辆销售台账表' + '.xls'
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'nonde'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href)
document.body.removeChild(elink)
}).catch(() => {
loading.close()
})
},
resetState() {
this.viewState = 1

Loading…
Cancel
Save