|
|
@ -40,9 +40,24 @@ |
|
|
|
<el-button type="primary" |
|
|
|
size="small" |
|
|
|
@click="handleExportModule">下载小区模板</el-button> |
|
|
|
<el-button type="danger" |
|
|
|
|
|
|
|
<el-upload ref="upload" |
|
|
|
:multiple='false' |
|
|
|
:show-file-list='false' |
|
|
|
:before-upload="beforeUpload" |
|
|
|
action='' |
|
|
|
:limit="1" |
|
|
|
:on-exceed="handleExceed" |
|
|
|
:http-request="uploadFile"> |
|
|
|
<el-button style="margin-left:10px" |
|
|
|
plain |
|
|
|
icon="el-icon-upload2" |
|
|
|
type="primary" |
|
|
|
:disabled="loading">导入小区数据</el-button> |
|
|
|
</el-upload> |
|
|
|
<!-- <el-button type="danger" |
|
|
|
size="small" |
|
|
|
@click="handleInport">导入小区数据</el-button> |
|
|
|
@click="uploadFile">导入小区数据</el-button> --> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="div_table"> |
|
|
@ -246,8 +261,6 @@ export default { |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
async deleteCommunity (row) { |
|
|
@ -271,15 +284,151 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
handleExport () { |
|
|
|
|
|
|
|
//导出表格 |
|
|
|
async handleExport () { |
|
|
|
let title = this.agencyObj.label |
|
|
|
|
|
|
|
if (this.agencyObj.level === 'building') {//点击楼栋 |
|
|
|
title = title + '—房屋列表' |
|
|
|
|
|
|
|
} else if (this.agencyObj.level === 'neighbourHood') {//点击小区 |
|
|
|
title = title + '—楼栋列表' |
|
|
|
|
|
|
|
} else { |
|
|
|
title = title + '—小区列表' |
|
|
|
} |
|
|
|
|
|
|
|
const url = "/gov/org/neighborhood/exportneighborhoodinfo" |
|
|
|
let params = { |
|
|
|
ownerName: this.ownerName, |
|
|
|
ownerPhone: this.ownerPhone, |
|
|
|
level: this.agencyObj.level, |
|
|
|
id: this.agencyObj.id |
|
|
|
} |
|
|
|
|
|
|
|
app.ajax.exportFilePost( |
|
|
|
url, |
|
|
|
params, |
|
|
|
(data, rspMsg) => { |
|
|
|
|
|
|
|
this.download(data, title + '.xls') |
|
|
|
}, |
|
|
|
(rspMsg, data) => { |
|
|
|
this.$message.error(rspMsg); |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
// 下载文件 |
|
|
|
download (data, fileName) { |
|
|
|
if (!data) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
var csvData = new Blob([data]) |
|
|
|
|
|
|
|
if (window.navigator && window.navigator.msSaveOrOpenBlob) { |
|
|
|
window.navigator.msSaveOrOpenBlob(csvData, fileName); |
|
|
|
} |
|
|
|
// for Non-IE (chrome, firefox etc.) |
|
|
|
else { |
|
|
|
var a = document.createElement('a'); |
|
|
|
document.body.appendChild(a); |
|
|
|
a.style = 'display: none'; |
|
|
|
var url = window.URL.createObjectURL(csvData); |
|
|
|
a.href = url; |
|
|
|
a.download = fileName; |
|
|
|
a.click(); |
|
|
|
a.remove(); |
|
|
|
window.URL.revokeObjectURL(url); |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
handleExportModule () { |
|
|
|
let title = '' |
|
|
|
|
|
|
|
if (this.agencyObj.level === 'building') {//点击楼栋 |
|
|
|
title = '房屋模板' |
|
|
|
|
|
|
|
} else if (this.agencyObj.level === 'neighbourHood') {//点击小区 |
|
|
|
title = '楼栋模板' |
|
|
|
|
|
|
|
} else { |
|
|
|
title = '小区模板' |
|
|
|
} |
|
|
|
|
|
|
|
const url = "/gov/org/neighborhood/exporttemplate" |
|
|
|
let params = {} |
|
|
|
|
|
|
|
app.ajax.exportFilePost( |
|
|
|
url, |
|
|
|
params, |
|
|
|
(data, rspMsg) => { |
|
|
|
|
|
|
|
this.download(data, title + '.xls') |
|
|
|
}, |
|
|
|
(rspMsg, data) => { |
|
|
|
this.$message.error(rspMsg); |
|
|
|
} |
|
|
|
); |
|
|
|
}, |
|
|
|
|
|
|
|
// 上传文件之前的钩子 |
|
|
|
beforeUpload (file) { |
|
|
|
this.files = file; |
|
|
|
|
|
|
|
const isText = file.type === 'application/vnd.ms-excel' |
|
|
|
const isTextComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
|
|
|
|
|
|
|
if (!isText && !isTextComputer) { |
|
|
|
this.$message.error('请选择正确格式的文件') |
|
|
|
return false |
|
|
|
} else { |
|
|
|
this.fileName = file.name; |
|
|
|
return true |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
// 上传文件个数超过定义的数量 |
|
|
|
handleExceed (files, fileList) { |
|
|
|
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`) |
|
|
|
}, |
|
|
|
handleInport () { |
|
|
|
|
|
|
|
uploadFile () { |
|
|
|
this.loading = true |
|
|
|
|
|
|
|
if (this.fileName == "") { |
|
|
|
this.$message.warning('请选择要上传的文件!') |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
//清空上传列表 |
|
|
|
this.$refs['upload'].clearFiles() |
|
|
|
|
|
|
|
var url = '/gov/org/neighborhood/import' |
|
|
|
let fileFormData = new FormData(); |
|
|
|
fileFormData.append('fileName', this.files);//filename是键,file是值,就是要传的文件,test.zip是要传的文件名 |
|
|
|
|
|
|
|
app.ajax.importFilePut( |
|
|
|
url, |
|
|
|
fileFormData, |
|
|
|
(data, rspMsg) => { |
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
|
|
this.loading = false |
|
|
|
this.$message.success(rspMsg) |
|
|
|
this.loadTable() |
|
|
|
}) |
|
|
|
}, |
|
|
|
(rspMsg, data) => { |
|
|
|
this.loading = false |
|
|
|
this.$message.error('<p>' + rspMsg + '</p>'); |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|