1 changed files with 84 additions and 0 deletions
@ -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…
Reference in new issue