Browse Source

Merge branch 'dev-shuju' into test

shibei_master
13176889840 4 years ago
parent
commit
dcbaab0429
  1. 27
      src/views/modules/base/resi.vue

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

@ -9,7 +9,7 @@
<el-card class="resi-card-table"> <el-card class="resi-card-table">
<div class="resi-row-btn"> <div class="resi-row-btn">
<el-button type="success" size="small" @click="handleAdd">新增</el-button> <el-button type="success" size="small" @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-button type="primary" size="small">下载人口模板</el-button> --> <!-- <el-button type="primary" size="small">下载人口模板</el-button> -->
<el-upload <el-upload
ref="upload" ref="upload"
@ -216,6 +216,8 @@ export default {
}, },
data() { data() {
return { return {
exportBtn: false,
exportBtnTitle: '导出',
importBtnTitle: '导入人员数据', importBtnTitle: '导入人员数据',
importLoading: false, importLoading: false,
rowVisible: false, rowVisible: false,
@ -314,14 +316,16 @@ export default {
window.URL.revokeObjectURL(url) window.URL.revokeObjectURL(url)
} }
}, },
handleExport() { async handleExport() {
this.exportBtn = true
this.exportBtnTitle = '正在导出...'
let params = { let params = {
formCode: 'resi_base_info', formCode: 'resi_base_info',
conditions: this.conditions conditions: this.conditions
} }
// .post('epmetuser/icresiuser/exportExcel', params) // .post('epmetuser/icresiuser/exportExcel', params)
axios({ await axios({
url: window.SITE_CONFIG['apiURL'] + '/epmetuser/icresiuser/exportExcel', url: window.SITE_CONFIG['apiURL'] + '/epmetuser/icresiuser/exportExcel',
// url: 'epmetuser/icresiuser/exportExcel', // url: 'epmetuser/icresiuser/exportExcel',
method: 'post', method: 'post',
@ -329,6 +333,7 @@ export default {
responseType: 'blob' responseType: 'blob'
}) })
.then(res => { .then(res => {
console.log('resllll', res) console.log('resllll', res)
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)
@ -345,8 +350,10 @@ export default {
}) })
.catch((err) => { .catch((err) => {
console.log('获取导出情失败', err) console.log('获取导出情失败', err)
return this.$message.error('网络错误') this.$message.error('网络错误')
}) })
this.exportBtnTitle = '导出'
this.exportBtn = false
}, },
// //
handleExcelSuccess (res, file) { handleExcelSuccess (res, file) {
@ -377,20 +384,19 @@ 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'] + '/epmetuser/icresiuser/importExcel', url: window.SITE_CONFIG['apiURL'] + '/epmetuser/icresiuser/importExcel',
method: 'post', method: 'post',
data: formData, data: formData,
responseType: 'blob' responseType: 'blob'
}) })
.then((res) => { .then((res) => {
this.importLoading = false
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' })
@ -407,8 +413,11 @@ export default {
}) })
.catch( err => { .catch( err => {
console.log('失败', err) console.log('失败', err)
param.onError() // err.onError() //
}) })
this.importLoading = false
this.importBtnTitle = '导入人员数据'
this.$refs.upload.clearFiles()
}, },
handleClick(tab, event) { handleClick(tab, event) {
console.log(tab, event) console.log(tab, event)

Loading…
Cancel
Save