Browse Source

Merge branch 'dev-shuju' into test

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

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

@ -350,7 +350,7 @@ export default {
}) })
.catch((err) => { .catch((err) => {
console.log('获取导出情失败', err) console.log('获取导出情失败', err)
this.$message.error('网络错误') this.$message.error('获取导出失败')
}) })
this.exportBtnTitle = '导出' this.exportBtnTitle = '导出'
this.exportBtn = false this.exportBtn = false
@ -396,24 +396,27 @@ export default {
responseType: 'blob' responseType: 'blob'
}) })
.then((res) => { .then((res) => {
if (res.headers["content-disposition"]) {
let fileName = window.decodeURI(res.headers["content-disposition"].split(";")[1].split("=")[1]) let fileName = window.decodeURI(res.headers["content-disposition"].split(";")[1].split("=")[1])
console.log('filename', fileName) console.log('filename', fileName)
let blob = new Blob([res.data], { type: 'application/vnd.ms-excel' }) let blob = new Blob([res.data], { type: 'application/vnd.ms-excel' })
var url = window.URL.createObjectURL(blob) var url = window.URL.createObjectURL(blob)
var aLink = document.createElement('a') var aLink = document.createElement('a')
aLink.style.display = 'none' aLink.style.display = 'none'
aLink.href = url aLink.href = url
aLink.setAttribute('download', fileName) aLink.setAttribute('download', fileName)
document.body.appendChild(aLink) document.body.appendChild(aLink)
aLink.click() aLink.click()
document.body.removeChild(aLink) // document.body.removeChild(aLink) //
window.URL.revokeObjectURL(url) //blob window.URL.revokeObjectURL(url) //blob
}
this.getTableData() this.getTableData()
}) })
.catch( err => { .catch( err => {
console.log('失败', err) console.log('失败', err)
err.onError() // file.onError() //
this.$message.error('导入失败')
}) })
this.importLoading = false this.importLoading = false
this.importBtnTitle = '导入人员数据' this.importBtnTitle = '导入人员数据'

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

@ -34,7 +34,7 @@
</div> </div>
<div class="resi-row-btn"> <div class="resi-row-btn">
<el-button type="success" @click="handleAdd">新增</el-button> <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 <el-upload
ref="upload" ref="upload"
class="upload-demo" class="upload-demo"
@ -197,6 +197,8 @@ export default {
uploadUlr: window.SITE_CONFIG['apiURL'] + '/oss/file/uploadqrcodeV2', uploadUlr: window.SITE_CONFIG['apiURL'] + '/oss/file/uploadqrcodeV2',
importBtnTitle: '导入人员数据', importBtnTitle: '导入人员数据',
importLoading: false, importLoading: false,
exportBtn: false,
exportBtnTitle: '导出',
tableLoading: false, tableLoading: false,
btnLoading: false, btnLoading: false,
uploading: false, uploading: false,
@ -325,20 +327,20 @@ export default {
} }
return fileType && isLt1M return fileType && isLt1M
}, },
uploadHttpRequest(file) { async uploadHttpRequest(file) {
this.importLoading = true this.importLoading = true
this.importBtnTitle = '正在上传中...' this.importBtnTitle = '正在上传中...'
const formData = new FormData() //FormDataappend('key', value) const formData = new FormData() //FormDataappend('key', value)
formData.append('file', file.file) // formData.append('file', file.file) //
axios({ await axios({
url: window.SITE_CONFIG['apiURL'] + '/resi/partymember/icpartymemberstyle/import', url: window.SITE_CONFIG['apiURL'] + '/resi/partymember/icpartymemberstyle/import',
method: 'post', method: 'post',
data: formData, data: formData,
responseType: 'blob' responseType: 'blob'
}) })
.then((res) => { .then((res) => {
this.importLoading = false // this.importLoading = false
this.importBtnTitle = '导入人员数据' // this.importBtnTitle = ''
// let fileName = window.decodeURI(res.headers["content-disposition"].split(";")[1].split("=")[1]) // let fileName = window.decodeURI(res.headers["content-disposition"].split(";")[1].split("=")[1])
// console.log('filename', fileName) // console.log('filename', fileName)
// let blob = new Blob([res.data], { type: 'application/vnd.ms-excel' }) // let blob = new Blob([res.data], { type: 'application/vnd.ms-excel' })
@ -355,17 +357,23 @@ export default {
}) })
.catch( err => { .catch( err => {
console.log('失败', 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 = { let params = {
agencyId: this.$store.state.user.agencyId, agencyId: this.$store.state.user.agencyId,
pageSize: 9999, pageSize: 9999,
pageNo: this.currentPage pageNo: this.currentPage
} }
// .post('epmetuser/icresiuser/exportExcel', params) // .post('epmetuser/icresiuser/exportExcel', params)
axios({ await axios({
url: window.SITE_CONFIG['apiURL'] + '/resi/partymember/icpartymemberstyle/export', url: window.SITE_CONFIG['apiURL'] + '/resi/partymember/icpartymemberstyle/export',
// url: 'epmetuser/icresiuser/exportExcel', // url: 'epmetuser/icresiuser/exportExcel',
method: 'post', method: 'post',
@ -389,8 +397,10 @@ export default {
}) })
.catch((err) => { .catch((err) => {
console.log('获取导出情失败', err) console.log('获取导出情失败', err)
return this.$message.error('网络错误') this.$message.error('获取导出失败')
}) })
this.exportBtn = false
this.exportBtnTitle = '导出'
}, },
beforeImgUpload (file) { beforeImgUpload (file) {
const isPNG = (file.type === 'image/png') || (file.type === 'image/jpeg') const isPNG = (file.type === 'image/png') || (file.type === 'image/jpeg')

Loading…
Cancel
Save