diff --git a/src/utils/request.js b/src/utils/request.js index 419f83ec..4dea91da 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -7,7 +7,7 @@ import isPlainObject from 'lodash/isPlainObject' const http = axios.create({ baseURL: window.SITE_CONFIG['apiURL'], - timeout: 1000 * 180, + timeout: 1000 * 300, withCredentials: true }) diff --git a/src/views/modules/base/resi.vue b/src/views/modules/base/resi.vue index 0959dc87..86c4e35f 100644 --- a/src/views/modules/base/resi.vue +++ b/src/views/modules/base/resi.vue @@ -457,38 +457,56 @@ export default { async uploadHttpRequest (file) { this.importLoading = true this.importBtnTitle = '正在上传中...' + this.$message({ + showClose: true, + message: '导入中,请到系统管理-导入记录中查看进度', + duration: 0 + }) const formData = new FormData() //FormData对象,添加参数只能通过append('key', value)的形式添加 formData.append('file', file.file) //添加文件对象 - await axios({ - url: window.SITE_CONFIG['apiURL'] + '/epmetuser/icresiuser/importExcel', - method: 'post', - data: formData, - timeout: '300000', - 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' }) - 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.getTableData() - }) - .catch(err => { + await this.$http + .post('/epmetuser/icresiuser/importExcel', formData).then(res => { + console.log('res-up', res) + if (res.data.code == 0 && res.data.msg == 'success') { + this.$message.success('导入成功') + this.getTableData() + } else this.$message.error(res.data.msg) + }).catch(err => { console.log('失败', err) file.onError() //上传失败的文件会从文件列表中删除 this.$message.error('导入失败') }) + // await axios({ + // url: window.SITE_CONFIG['apiURL'] + '/epmetuser/icresiuser/importExcel', + // method: 'post', + // data: formData, + // timeout: '300000', + // responseType: 'blob' + // }) + // .then((res) => { + // console.log('res-up', 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' }) + // // 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.getTableData() + // }) + // .catch(err => { + // console.log('失败', err) + // file.onError() //上传失败的文件会从文件列表中删除 + // this.$message.error('导入失败') + // }) this.importLoading = false this.importBtnTitle = '导入人员数据' this.$refs.upload.clearFiles() diff --git a/src/views/modules/communityParty/elegant/index.vue b/src/views/modules/communityParty/elegant/index.vue index e7d9257b..592cbeb1 100644 --- a/src/views/modules/communityParty/elegant/index.vue +++ b/src/views/modules/communityParty/elegant/index.vue @@ -374,36 +374,55 @@ export default { async uploadHttpRequest(file) { this.importLoading = true this.importBtnTitle = '正在上传中...' + this.$message({ + showClose: true, + message: '导入中,请到系统管理-导入记录中查看进度', + duration: 0 + }) const formData = new FormData() //FormData对象,添加参数只能通过append('key', value)的形式添加 formData.append('file', file.file) //添加文件对象 - await axios({ - url: window.SITE_CONFIG['apiURL'] + '/resi/partymember/icpartymemberstyle/import', - 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' }) - // 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.getTableData() - }) - .catch( err => { + this.$http + .post('/resi/partymember/icpartymemberstyle/import', formData).then(res => { + console.log('res-up', res) + if (res.data.code == 0 && res.data.msg == 'success') { + this.$message.success('导入成功') + this.getTableData() + } else { + this.$message.error(res.data.msg) + } + }).catch(err => { console.log('失败', err) file.onError() //上传失败的文件会从文件列表中删除 this.$message.error('导入失败') - }) + }) + // await axios({ + // url: window.SITE_CONFIG['apiURL'] + '/resi/partymember/icpartymemberstyle/import', + // 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' }) + // // 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.getTableData() + // }) + // .catch( err => { + // console.log('失败', err) + // file.onError() //上传失败的文件会从文件列表中删除 + // this.$message.error('导入失败') + // }) this.importLoading = false this.importBtnTitle = '导入人员数据' this.$refs.upload.clearFiles()