Browse Source

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

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

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

@ -1,4 +1,5 @@
import request from '@/utils/request'
import qs from 'qs'
// 车辆销售(出库)列表
export function pagerList(data) {
@ -36,3 +37,14 @@ export function createPdf(data) {
})
}
// 导出
export function exportExcel(data) {
return request({
url: '/base/v1/basevehicleout/exportExcel',
method: 'post',
responseType: 'blob' , // 表明返回服务器返回的数据类型
data: data,
headers: { 'Content-Type': 'application/json' }
})
}

16
anrui-scm/anrui-scm-ui/src/utils/request.js

@ -77,14 +77,14 @@ service.interceptors.response.use(
}
return Promise.reject(new Error(res.message || 'Error'))
} else {
if (!res.success) {
Message({
message: res.msg || 'Error',
type: 'error',
showClose: true,
duration: 5 * 1000
})
}
if (!res.success && res.success !== null && res.success !== undefined) {
Message({
message: res.msg || 'Error',
type: 'error',
showClose: true,
duration: 5 * 1000
})
}
return res
}
},

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

@ -185,6 +185,12 @@
<span>{{ scope.row.innerName }}</span>
</template>
</el-table-column>
<el-table-column label="采购类型" align="center" width="120">
<template slot-scope="scope">
<span>{{ scope.row.manPurOrderTypeValue }}</span>
</template>
</el-table-column>
</el-table>
</div>
<div class="pages">
@ -220,7 +226,7 @@
</template>
<script>
import { pagerList, createPdf, delBySid } from '@/api/cheliang/cheliangxiaoshou'
import { pagerList, createPdf, delBySid, exportExcel } from '@/api/cheliang/cheliangxiaoshou'
import Pagination from '@/components/pagination'
import pageye from '@/components/pagination/pageye'
import ButtonBar from '@/components/ButtonBar'
@ -254,6 +260,13 @@ export default {
btnKey: 'doDel',
btnLabel: '删除'
},
{
type: 'success',
size: 'small',
icon: 'export',
btnKey: 'doExport',
btnLabel: '导出'
},
{
type: 'info',
size: 'small',
@ -353,6 +366,9 @@ export default {
case 'doDel':
this.doDel()
break
case 'doExport':
this.doExport()
break
case 'doClose':
this.doClose()
break
@ -498,6 +514,37 @@ export default {
return
}
},
//
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()
})
} else {
this.$message({ showClose: true, type: 'error', message: '请至少选择一条记录进行导出操作' })
return
}
},
resetState() {
this.viewState = 1
},

Loading…
Cancel
Save