Browse Source

导入样式

shibei_master
13176889840 4 years ago
parent
commit
5da691802a
  1. 2
      src/utils/request.js
  2. 68
      src/views/modules/base/resi.vue
  3. 65
      src/views/modules/communityParty/elegant/index.vue

2
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
})

68
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() //FormDataappend('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
}
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()
})
.catch(err => {
} 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()

65
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() //FormDataappend('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.$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()
})
.catch( err => {
} 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()

Loading…
Cancel
Save