Browse Source

居民数据导出

jly/task002
tianqian 2 years ago
parent
commit
996f94e0b4
  1. 84
      src/views/modules/base/census/people.vue

84
src/views/modules/base/census/people.vue

@ -0,0 +1,84 @@
<template>
<div class="mode-block resi-container">
<el-button @click="exportHandle" class="diy-button--reset" size="small" :loading="exportLoading">导出</el-button>
</div>
</template>
<script>
import {
mapGetters
} from "vuex";
import {
dateFormats
} from '@/utils/index'
export default {
data() {
return {
exportLoading: false,
}
},
components: {
// AddOrUpdate
},
created() {},
watch: {},
computed: {
...mapGetters(["clientHeight", "iframeHeight"]),
tableHeight() {
const h = this.clientHeight - 330 + this.iframeHeigh;
const _h = this.clientHeight - 330;
return this.$store.state.inIframe ? h : _h;
},
},
methods: {
exportHandle() {
const url = '/epmetuser/icresiuser/exportResiForLangchao'
// this.dataForm.type = 1
this.exportLoading = true
this.$http({
method: 'Get',
url,
responseType: 'blob',
data: []
}).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
// this.exportLoading = false
} else this.$message.error('下载失败')
this.exportLoading = false
}).catch(err => {
console.log('err', err)
this.exportLoading = false
return this.$message.error('网络错误')
})
},
deepTree(arr) {
if (Array.isArray(arr)) {
return arr.map(item => {
return {
...item,
subAgencyList: item.subAgencyList.length > 0 && this.deepTree(item.subAgencyList) ||
null
}
})
}
}
}
}
</script>
<style>
</style>
Loading…
Cancel
Save