|
|
@ -31,18 +31,31 @@ |
|
|
|
@click="handleSearch">查询</el-button> |
|
|
|
</div> |
|
|
|
<div class="div_btn"> |
|
|
|
<el-button type="warning" |
|
|
|
<el-button style="float:left" |
|
|
|
type="warning" |
|
|
|
size="small" |
|
|
|
@click="handleExport">导出</el-button> |
|
|
|
<el-button type="success" |
|
|
|
<el-button style="float:left" |
|
|
|
type="success" |
|
|
|
size="small" |
|
|
|
@click="handleAdd">新增房屋</el-button> |
|
|
|
<el-button type="primary" |
|
|
|
<el-button style="float:left" |
|
|
|
type="primary" |
|
|
|
size="small" |
|
|
|
@click="handleExportModule">下载房屋模板</el-button> |
|
|
|
<el-button type="danger" |
|
|
|
size="small" |
|
|
|
@click="handleInport">导入房屋数据</el-button> |
|
|
|
<el-upload ref="upload" |
|
|
|
:multiple='false' |
|
|
|
:show-file-list='false' |
|
|
|
:before-upload="beforeUpload" |
|
|
|
action="" |
|
|
|
accept=".xls,.xlsx" |
|
|
|
:limit="1" |
|
|
|
:on-exceed="handleExceed" |
|
|
|
:http-request="uploadFile"> |
|
|
|
<el-button style="margin-left:10px" |
|
|
|
size="small" |
|
|
|
type="danger">导入小区数据</el-button> |
|
|
|
</el-upload> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="div_table"> |
|
|
@ -125,7 +138,7 @@ |
|
|
|
:close-on-click-modal="false" |
|
|
|
:close-on-press-escape="false" |
|
|
|
:title="formTitle" |
|
|
|
width="800px" |
|
|
|
width="900px" |
|
|
|
@closed="diaClose"> |
|
|
|
<room-form ref="ref_form" |
|
|
|
@dialogCancle="addFormCancle" |
|
|
@ -286,18 +299,125 @@ export default { |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
handleExport () { |
|
|
|
//导出表格 |
|
|
|
async handleExport () { |
|
|
|
let title = this.agencyObj.label |
|
|
|
title = title + '—房屋列表' |
|
|
|
|
|
|
|
const url = "/gov/org/house/exporthouseinfo" |
|
|
|
let params = { |
|
|
|
ownerName: this.ownerName, |
|
|
|
ownerPhone: this.ownerPhone, |
|
|
|
buildingId: 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 |
|
|
|
} |
|
|
|
|
|
|
|
handleExportModule () { |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
handleInport () { |
|
|
|
|
|
|
|
handleExportModule () { |
|
|
|
let title = '' |
|
|
|
title = '房屋模板' |
|
|
|
|
|
|
|
const url = "/gov/org/house/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 个文件,请删除后继续上传`) |
|
|
|
}, |
|
|
|
|
|
|
|
async uploadFile () { |
|
|
|
this.loading = true |
|
|
|
|
|
|
|
if (this.fileName == "") { |
|
|
|
this.$message.warning('请选择要上传的文件!') |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
//清空上传列表 |
|
|
|
this.$refs['upload'].clearFiles() |
|
|
|
|
|
|
|
var url = '/gov/org/house/import' |
|
|
|
let fileFormData = new FormData(); |
|
|
|
fileFormData.append('file', this.files);//filename是键,file是值,就是要传的文件,test.zip是要传的文件名 |
|
|
|
|
|
|
|
const { data, code, msg } = await requestPost(url, fileFormData) |
|
|
|
if (code === 0) { |
|
|
|
|
|
|
|
this.$emit('refreshTree') |
|
|
|
this.loadTable() |
|
|
|
} else { |
|
|
|
this.$message.error(msg) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
handleSizeChange (val) { |
|
|
|
console.log(`每页 ${val} 条`) |
|
|
|