|
|
@ -31,33 +31,70 @@ |
|
|
|
@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" |
|
|
|
<div class="btn_upload" |
|
|
|
v-if="agencyObj.level==='community'||agencyObj.level==='grid'"> |
|
|
|
<el-button style="" |
|
|
|
type="blue" |
|
|
|
size="small" |
|
|
|
@click="handleExportModule">下载小区模板</el-button> |
|
|
|
@click="handleExportModule('community')">下载小区模板</el-button> |
|
|
|
|
|
|
|
<el-upload ref="upload" |
|
|
|
<el-upload ref="upload_community" |
|
|
|
style="" |
|
|
|
:multiple='false' |
|
|
|
:show-file-list='false' |
|
|
|
:before-upload="beforeUpload" |
|
|
|
:before-upload="((file)=>{beforeUpload(file, 'community')})" |
|
|
|
action="" |
|
|
|
accept=".xls,.xlsx" |
|
|
|
:limit="1" |
|
|
|
:on-exceed="handleExceed" |
|
|
|
:http-request="uploadFile"> |
|
|
|
:http-request="(()=>{uploadFile( 'community')})"> |
|
|
|
<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('building')">下载楼宇模板</el-button> |
|
|
|
|
|
|
|
<el-upload style="" |
|
|
|
ref="upload_building" |
|
|
|
:multiple='false' |
|
|
|
:show-file-list='false' |
|
|
|
:before-upload="((file)=>{beforeUpload(file, 'building')})" |
|
|
|
action="" |
|
|
|
accept=".xls,.xlsx" |
|
|
|
:http-request="(()=>{uploadFile( 'building')})"> |
|
|
|
<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('room')">下载房屋模板</el-button> |
|
|
|
|
|
|
|
<el-upload style="" |
|
|
|
ref="upload_room" |
|
|
|
:multiple='false' |
|
|
|
:show-file-list='false' |
|
|
|
:before-upload="((file)=>{beforeUpload(file, 'room')})" |
|
|
|
action="" |
|
|
|
accept=".xls,.xlsx" |
|
|
|
:http-request="(()=>{uploadFile( 'room')})"> |
|
|
|
<el-button style="margin-left:10px" |
|
|
|
size="small" |
|
|
|
type="red">导入房屋数据</el-button> |
|
|
|
</el-upload> |
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="div_table"> |
|
|
@ -203,9 +240,9 @@ export default { |
|
|
|
if (fromTree) { |
|
|
|
this.agencyObj = treeObj |
|
|
|
} |
|
|
|
|
|
|
|
console.log(this.agencyObj) |
|
|
|
const url = "/gov/org/neighborhood/neighborhoodlist" |
|
|
|
// const url = "http://yapi.elinkservice.cn/mock/245/gov/org/neighborhood/neighborhoodlist" |
|
|
|
|
|
|
|
let params = { |
|
|
|
pageSize: this.pageSize, |
|
|
|
pageNo: this.pageNo, |
|
|
@ -338,7 +375,7 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
// 下载文件 |
|
|
|
download (data, fileName) { |
|
|
|
download (data, downFileName) { |
|
|
|
if (!data) { |
|
|
|
return |
|
|
|
} |
|
|
@ -346,7 +383,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 +392,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); |
|
|
@ -363,11 +400,22 @@ export default { |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
handleExportModule () { |
|
|
|
handleExportModule (type) { |
|
|
|
let title = '' |
|
|
|
title = '小区模板' |
|
|
|
let url = "" |
|
|
|
if (type === 'community') { |
|
|
|
title = '小区导入模板' |
|
|
|
url = '/gov/org/neighborhood/exporttemplate' |
|
|
|
|
|
|
|
} else if (type === 'building') { |
|
|
|
title = '楼宇导入模板' |
|
|
|
url = '/gov/org/building/exporttemplate' |
|
|
|
|
|
|
|
} else if (type === 'room') { |
|
|
|
title = '房间导入模板' |
|
|
|
url = '/gov/org/house/exporttemplate' |
|
|
|
} |
|
|
|
|
|
|
|
const url = "/gov/org/neighborhood/exporttemplate" |
|
|
|
let params = {} |
|
|
|
|
|
|
|
app.ajax.exportFilePost( |
|
|
@ -384,7 +432,7 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
// 上传文件之前的钩子 |
|
|
|
beforeUpload (file) { |
|
|
|
beforeUpload (file, type) { |
|
|
|
this.files = file; |
|
|
|
|
|
|
|
const isText = file.type === 'application/vnd.ms-excel' |
|
|
@ -392,6 +440,8 @@ export default { |
|
|
|
|
|
|
|
if (!isText && !isTextComputer) { |
|
|
|
this.$message.error('请选择正确格式的文件') |
|
|
|
this.files = null |
|
|
|
this.fileName = '' |
|
|
|
return false |
|
|
|
} else { |
|
|
|
this.fileName = file.name; |
|
|
@ -404,36 +454,65 @@ export default { |
|
|
|
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`) |
|
|
|
}, |
|
|
|
|
|
|
|
async uploadFile () { |
|
|
|
this.loading = true |
|
|
|
async uploadFile (type) { |
|
|
|
|
|
|
|
if (this.fileName == "") { |
|
|
|
this.$message.warning('请选择要上传的文件!') |
|
|
|
|
|
|
|
return false |
|
|
|
} |
|
|
|
this.loading = true |
|
|
|
|
|
|
|
//清空上传列表 |
|
|
|
this.$refs['upload'].clearFiles() |
|
|
|
let url = '' |
|
|
|
|
|
|
|
var url = '/gov/org/neighborhood/import' |
|
|
|
let fileFormData = new FormData(); |
|
|
|
fileFormData.append('file', this.files);//filename是键,file是值,就是要传的文件,test.zip是要传的文件名 |
|
|
|
fileFormData.append('orgId', this.agencyObj.id);//filename是键,file是值,就是要传的文件,test.zip是要传的文件名 |
|
|
|
fileFormData.append('orgType', this.agencyObj.level === 'grid' ? 'grid' : 'agency');//filename是键,file是值,就是要传的文件,test.zip是要传的文件名 |
|
|
|
|
|
|
|
if (type === 'community') { |
|
|
|
this.$refs['upload_community'].clearFiles() |
|
|
|
url = '/gov/org/icneighborhood/neighborhoodimport' |
|
|
|
|
|
|
|
|
|
|
|
} else if (type === 'building') { |
|
|
|
this.$refs['upload_building'].clearFiles() |
|
|
|
url = '/gov/org/building/buildingimport' |
|
|
|
|
|
|
|
|
|
|
|
} else if (type === 'room') { |
|
|
|
this.$refs['upload_room'].clearFiles() |
|
|
|
url = '/gov/org/house/houseimport' |
|
|
|
|
|
|
|
} |
|
|
|
this.startLoading() |
|
|
|
window.app.ajax.post2(url, fileFormData, |
|
|
|
(data, rspMsg) => { |
|
|
|
this.endLoading() |
|
|
|
if (data.code === 0 || data.code > 8000) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { data, code, msg } = await requestPost(url, fileFormData) |
|
|
|
if (code === 0) { |
|
|
|
this.$message({ |
|
|
|
type: "success", |
|
|
|
message: "导入成功" |
|
|
|
}); |
|
|
|
this.$emit('refreshTree') |
|
|
|
this.loadTable() |
|
|
|
} else { |
|
|
|
this.$message.error(msg) |
|
|
|
} |
|
|
|
this.showMessage(rspMsg) |
|
|
|
}, |
|
|
|
(rspMsg, data) => { |
|
|
|
this.endLoading() |
|
|
|
this.$message.error(rspMsg) |
|
|
|
}, { headers: { 'Content-Type': 'multipart/form-data' } }) |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
showMessage (msg) { |
|
|
|
this.$alert(msg, '操作结果', { |
|
|
|
confirmButtonText: '关闭', |
|
|
|
callback: action => { |
|
|
|
this.$emit('refreshTree') |
|
|
|
this.loadTable() |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
handleSizeChange (val) { |
|
|
|
this.pageSize = val |
|
|
|
this.pageNo = 1 |
|
|
@ -516,7 +595,13 @@ export default { |
|
|
|
} |
|
|
|
|
|
|
|
.div_btn { |
|
|
|
display: flex; |
|
|
|
margin-top: 20px; |
|
|
|
|
|
|
|
.btn_upload { |
|
|
|
margin-left: 10px; |
|
|
|
display: flex; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.el-row { |
|
|
|