|
|
@ -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() |
|
|
|