Browse Source

居民信息上传问题

shibei_master
13176889840 4 years ago
parent
commit
73f1ca1537
  1. 27
      src/views/modules/base/resi.vue

27
src/views/modules/base/resi.vue

@ -9,7 +9,7 @@
<el-card class="resi-card-table">
<div class="resi-row-btn">
<el-button type="success" size="small" @click="handleAdd">新增</el-button>
<el-button type="warning" size="small" @click="handleExport">导出</el-button>
<el-button type="warning" size="small" :loading="exportBtn" @click="handleExport">{{exportBtnTitle}}</el-button>
<!-- <el-button type="primary" size="small">下载人口模板</el-button> -->
<el-upload
ref="upload"
@ -216,6 +216,8 @@ export default {
},
data() {
return {
exportBtn: false,
exportBtnTitle: '导出',
importBtnTitle: '导入人员数据',
importLoading: false,
rowVisible: false,
@ -314,14 +316,16 @@ export default {
window.URL.revokeObjectURL(url)
}
},
handleExport() {
async handleExport() {
this.exportBtn = true
this.exportBtnTitle = '正在导出...'
let params = {
formCode: 'resi_base_info',
conditions: this.conditions
}
// .post('epmetuser/icresiuser/exportExcel', params)
axios({
await axios({
url: window.SITE_CONFIG['apiURL'] + '/epmetuser/icresiuser/exportExcel',
// url: 'epmetuser/icresiuser/exportExcel',
method: 'post',
@ -329,6 +333,7 @@ export default {
responseType: 'blob'
})
.then(res => {
console.log('resllll', res)
let fileName = window.decodeURI(res.headers["content-disposition"].split(";")[1].split("=")[1])
console.log('filename', fileName)
@ -345,8 +350,10 @@ export default {
})
.catch((err) => {
console.log('获取导出情失败', err)
return this.$message.error('网络错误')
this.$message.error('网络错误')
})
this.exportBtnTitle = '导出'
this.exportBtn = false
},
//
handleExcelSuccess (res, file) {
@ -377,20 +384,19 @@ export default {
}
return fileType && isLt1M
},
uploadHttpRequest(file) {
async uploadHttpRequest(file) {
this.importLoading = true
this.importBtnTitle = '正在上传中...'
const formData = new FormData() //FormDataappend('key', value)
formData.append('file', file.file) //
axios({
await axios({
url: window.SITE_CONFIG['apiURL'] + '/epmetuser/icresiuser/importExcel',
method: 'post',
data: formData,
responseType: 'blob'
})
.then((res) => {
this.importLoading = false
this.importBtnTitle = '导入人员数据'
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' })
@ -407,8 +413,11 @@ export default {
})
.catch( err => {
console.log('失败', err)
param.onError() //
err.onError() //
})
this.importLoading = false
this.importBtnTitle = '导入人员数据'
this.$refs.upload.clearFiles()
},
handleClick(tab, event) {
console.log(tab, event)

Loading…
Cancel
Save