Browse Source

导入导出

shibei_master
13176889840 4 years ago
parent
commit
6f55b619db
  1. 9
      src/views/modules/base/resi.vue
  2. 28
      src/views/modules/communityParty/elegant/index.vue

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

@ -350,7 +350,7 @@ export default {
})
.catch((err) => {
console.log('获取导出情失败', err)
this.$message.error('网络错误')
this.$message.error('获取导出失败')
})
this.exportBtnTitle = '导出'
this.exportBtn = false
@ -396,7 +396,7 @@ export default {
responseType: 'blob'
})
.then((res) => {
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' })
@ -409,11 +409,14 @@ export default {
aLink.click()
document.body.removeChild(aLink) //
window.URL.revokeObjectURL(url) //blob
}
this.getTableData()
})
.catch( err => {
console.log('失败', err)
err.onError() //
file.onError() //
this.$message.error('导入失败')
})
this.importLoading = false
this.importBtnTitle = '导入人员数据'

28
src/views/modules/communityParty/elegant/index.vue

@ -34,7 +34,7 @@
</div>
<div class="resi-row-btn">
<el-button type="success" @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-upload
ref="upload"
class="upload-demo"
@ -197,6 +197,8 @@ export default {
uploadUlr: window.SITE_CONFIG['apiURL'] + '/oss/file/uploadqrcodeV2',
importBtnTitle: '导入人员数据',
importLoading: false,
exportBtn: false,
exportBtnTitle: '导出',
tableLoading: false,
btnLoading: false,
uploading: false,
@ -325,20 +327,20 @@ 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'] + '/resi/partymember/icpartymemberstyle/import',
method: 'post',
data: formData,
responseType: 'blob'
})
.then((res) => {
this.importLoading = false
this.importBtnTitle = '导入人员数据'
// 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' })
@ -355,17 +357,23 @@ export default {
})
.catch( err => {
console.log('失败', err)
param.onError() //
file.onError() //
this.$message.error('导入失败')
})
this.importLoading = false
this.importBtnTitle = '导入人员数据'
this.$refs.upload.clearFiles()
},
handleExport() {
async handleExport() {
this.exportBtn = true
this.exportBtnTitle = '正在导出...'
let params = {
agencyId: this.$store.state.user.agencyId,
pageSize: 9999,
pageNo: this.currentPage
}
// .post('epmetuser/icresiuser/exportExcel', params)
axios({
await axios({
url: window.SITE_CONFIG['apiURL'] + '/resi/partymember/icpartymemberstyle/export',
// url: 'epmetuser/icresiuser/exportExcel',
method: 'post',
@ -389,8 +397,10 @@ export default {
})
.catch((err) => {
console.log('获取导出情失败', err)
return this.$message.error('网络错误')
this.$message.error('获取导出失败')
})
this.exportBtn = false
this.exportBtnTitle = '导出'
},
beforeImgUpload (file) {
const isPNG = (file.type === 'image/png') || (file.type === 'image/jpeg')

Loading…
Cancel
Save