|
|
@ -31,23 +31,42 @@ |
|
|
|
@click="handleSearch">查询</el-button> |
|
|
|
</div> |
|
|
|
<div class="div_btn"> |
|
|
|
<el-button style="float:left" |
|
|
|
<el-button style="" |
|
|
|
type="yellow" |
|
|
|
size="small" |
|
|
|
@click="handleExport">导出</el-button> |
|
|
|
<el-button style="float:left" |
|
|
|
<el-button style="" |
|
|
|
type="green" |
|
|
|
size="small" |
|
|
|
@click="handleAdd">新增小区</el-button> |
|
|
|
<el-button style="float:left" |
|
|
|
<el-button style="" |
|
|
|
type="blue" |
|
|
|
size="small" |
|
|
|
@click="handleExportModule">下载小区模板</el-button> |
|
|
|
|
|
|
|
<el-upload ref="upload" |
|
|
|
style="" |
|
|
|
:multiple='false' |
|
|
|
:show-file-list='false' |
|
|
|
:before-upload="beforeUpload" |
|
|
|
:before-upload="((file)=>{beforeUpload(file, 'community')})" |
|
|
|
action="" |
|
|
|
accept=".xls,.xlsx" |
|
|
|
:http-request="uploadFile"> |
|
|
|
<el-button style="margin-left:10px" |
|
|
|
size="small" |
|
|
|
type="red">导入小区数据</el-button> |
|
|
|
</el-upload> |
|
|
|
|
|
|
|
<el-button style=";margin-left:10px" |
|
|
|
type="blue" |
|
|
|
size="small" |
|
|
|
@click="handleExportModule">下载楼宇模板</el-button> |
|
|
|
|
|
|
|
<el-upload style="" |
|
|
|
ref="upload" |
|
|
|
:multiple='false' |
|
|
|
:show-file-list='false' |
|
|
|
:before-upload="((file)=>{beforeUpload(file, 'building')})" |
|
|
|
action="" |
|
|
|
accept=".xls,.xlsx" |
|
|
|
:limit="1" |
|
|
@ -55,7 +74,26 @@ |
|
|
|
:http-request="uploadFile"> |
|
|
|
<el-button style="margin-left:10px" |
|
|
|
size="small" |
|
|
|
type="red">导入小区数据</el-button> |
|
|
|
type="red">导入楼宇数据</el-button> |
|
|
|
</el-upload> |
|
|
|
<el-button style=";margin-left:10px" |
|
|
|
type="blue" |
|
|
|
size="small" |
|
|
|
@click="handleExportModule">下载房屋模板</el-button> |
|
|
|
|
|
|
|
<el-upload style="" |
|
|
|
ref="upload" |
|
|
|
:multiple='false' |
|
|
|
:show-file-list='false' |
|
|
|
:before-upload="((file)=>{beforeUpload(file, 'room')})" |
|
|
|
action="" |
|
|
|
accept=".xls,.xlsx" |
|
|
|
:limit="1" |
|
|
|
:on-exceed="handleExceed" |
|
|
|
:http-request="uploadFile"> |
|
|
|
<el-button style="margin-left:10px" |
|
|
|
size="small" |
|
|
|
type="red">导入房屋数据</el-button> |
|
|
|
</el-upload> |
|
|
|
|
|
|
|
</div> |
|
|
@ -338,7 +376,7 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
// 下载文件 |
|
|
|
download (data, fileName) { |
|
|
|
download (data, downFileName) { |
|
|
|
if (!data) { |
|
|
|
return |
|
|
|
} |
|
|
@ -346,7 +384,7 @@ export default { |
|
|
|
var csvData = new Blob([data]) |
|
|
|
|
|
|
|
if (window.navigator && window.navigator.msSaveOrOpenBlob) { |
|
|
|
window.navigator.msSaveOrOpenBlob(csvData, fileName); |
|
|
|
window.navigator.msSaveOrOpenBlob(csvData, downFileName); |
|
|
|
} |
|
|
|
// for Non-IE (chrome, firefox etc.) |
|
|
|
else { |
|
|
@ -355,7 +393,7 @@ export default { |
|
|
|
a.style = 'display: none'; |
|
|
|
var url = window.URL.createObjectURL(csvData); |
|
|
|
a.href = url; |
|
|
|
a.download = fileName; |
|
|
|
a.download = downFileName; |
|
|
|
a.click(); |
|
|
|
a.remove(); |
|
|
|
window.URL.revokeObjectURL(url); |
|
|
@ -384,7 +422,7 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
// 上传文件之前的钩子 |
|
|
|
beforeUpload (file) { |
|
|
|
beforeUpload (file, type) { |
|
|
|
this.files = file; |
|
|
|
|
|
|
|
const isText = file.type === 'application/vnd.ms-excel' |
|
|
@ -392,6 +430,8 @@ export default { |
|
|
|
|
|
|
|
if (!isText && !isTextComputer) { |
|
|
|
this.$message.error('请选择正确格式的文件') |
|
|
|
this.files = null |
|
|
|
this.fileName = '' |
|
|
|
return false |
|
|
|
} else { |
|
|
|
this.fileName = file.name; |
|
|
@ -401,16 +441,17 @@ export default { |
|
|
|
}, |
|
|
|
// 上传文件个数超过定义的数量 |
|
|
|
handleExceed (files, fileList) { |
|
|
|
|
|
|
|
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`) |
|
|
|
}, |
|
|
|
|
|
|
|
async uploadFile () { |
|
|
|
this.loading = true |
|
|
|
|
|
|
|
if (this.fileName == "") { |
|
|
|
this.$message.warning('请选择要上传的文件!') |
|
|
|
|
|
|
|
return false |
|
|
|
} |
|
|
|
this.loading = true |
|
|
|
|
|
|
|
//清空上传列表 |
|
|
|
this.$refs['upload'].clearFiles() |
|
|
@ -420,6 +461,7 @@ export default { |
|
|
|
fileFormData.append('file', this.files);//filename是键,file是值,就是要传的文件,test.zip是要传的文件名 |
|
|
|
|
|
|
|
const { data, code, msg } = await requestPost(url, fileFormData) |
|
|
|
|
|
|
|
if (code === 0) { |
|
|
|
this.$message({ |
|
|
|
type: "success", |
|
|
@ -428,7 +470,8 @@ export default { |
|
|
|
this.$emit('refreshTree') |
|
|
|
this.loadTable() |
|
|
|
} else { |
|
|
|
this.$message.error(msg) |
|
|
|
// debugger |
|
|
|
// this.$message.error(msg) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -516,6 +559,7 @@ export default { |
|
|
|
} |
|
|
|
|
|
|
|
.div_btn { |
|
|
|
display: flex; |
|
|
|
margin-top: 20px; |
|
|
|
} |
|
|
|
|
|
|
|