Browse Source

导出

shibei_master
zhangyuan 3 years ago
parent
commit
8fcdf95cf5
  1. 37
      src/views/modules/plugins/stats/factagencyuserhousedaily.vue

37
src/views/modules/plugins/stats/factagencyuserhousedaily.vue

@ -47,10 +47,10 @@
</el-card> </el-card>
<el-card class="resi-card-table"> <el-card class="resi-card-table">
<div class="resi-row-btn"> <div class="resi-row-btn">
<el-button @click="handleTotal" <el-button @click="totalHandle"
class="diy-button--add" class="diy-button--add"
size="small">总计</el-button> size="small">总计</el-button>
<el-button @click="handleChu" <el-button @click="exportHandle"
class="diy-button--reset" class="diy-button--reset"
size="small">导出</el-button> size="small">导出</el-button>
</div> </div>
@ -121,7 +121,8 @@ export default {
getDataListURL: '/data/stats/factAgencyUserHouseDaily/page', getDataListURL: '/data/stats/factAgencyUserHouseDaily/page',
getDataListIsPage: true, getDataListIsPage: true,
deleteURL: '/data/stats/factAgencyUserHouseDaily', deleteURL: '/data/stats/factAgencyUserHouseDaily',
deleteIsBatch: true deleteIsBatch: true,
exportURL: '/data/stats/factAgencyUserHouseDaily/export'
}, },
optionsA: [], optionsA: [],
totalVisible: false, totalVisible: false,
@ -151,7 +152,7 @@ export default {
} }
}, },
methods: { methods: {
handleTotal () { totalHandle () {
this.tableData = [] this.tableData = []
this.$http this.$http
.get('/data/stats/factAgencyUserHouseDaily/total',{params: this.dataForm}) .get('/data/stats/factAgencyUserHouseDaily/total',{params: this.dataForm})
@ -168,6 +169,34 @@ export default {
}) })
this.totalVisible = true this.totalVisible = true
}, },
exportHandle () {
const url = this.mixinViewModuleOptions.exportURL
this.$http({
method: 'GET',
url,
responseType: 'blob',
params: this.dataForm
}).then(res => {
// this.download(res.data, title + '.xls')
if (res.headers["content-disposition"]) {
let fileName = window.decodeURI(res.headers["content-disposition"].split(";")[1].split("=")[1])
console.log('filename', fileName)
let blob = new Blob([res.data], { type: 'application/vnd.ms-excel' })
var url = window.URL.createObjectURL(blob)
var aLink = document.createElement('a')
aLink.style.display = 'none'
aLink.href = url
aLink.setAttribute('download', fileName)
document.body.appendChild(aLink)
aLink.click()
document.body.removeChild(aLink) //
window.URL.revokeObjectURL(url) //blob
} else this.$message.error('下载失败')
}).catch(err => {
console.log('err', err)
return this.$message.error('网络错误')
})
},
cascaderClick (nodeData) { cascaderClick (nodeData) {
this.dataForm.agencyId = nodeData.agencyId; this.dataForm.agencyId = nodeData.agencyId;
this.dataForm.level = nodeData.level this.dataForm.level = nodeData.level

Loading…
Cancel
Save