You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
612 lines
16 KiB
612 lines
16 KiB
<template>
|
|
<div>
|
|
<div class="div_search">
|
|
<div class="resi-cell">
|
|
<div class="resi-cell-label">房主姓名</div>
|
|
<div class="resi-cell-value">
|
|
<el-input v-model="ownerName"
|
|
class="resi-cell-input"
|
|
size="small"
|
|
clearable
|
|
placeholder="请输入内容">
|
|
</el-input>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="resi-cell">
|
|
<div class="resi-cell-label">房主手机</div>
|
|
<div class="resi-cell-value">
|
|
<el-input v-model="ownerPhone"
|
|
class="resi-cell-input"
|
|
size="small"
|
|
clearable
|
|
placeholder="请输入内容">
|
|
</el-input>
|
|
|
|
</div>
|
|
</div>
|
|
<el-button style="margin-left:10px"
|
|
type="primary"
|
|
size="small"
|
|
@click="handleSearch">查询</el-button>
|
|
</div>
|
|
<div class="div_btn">
|
|
<el-button style=""
|
|
type="yellow"
|
|
size="small"
|
|
@click="handleExport">导出</el-button>
|
|
<el-button style=""
|
|
type="green"
|
|
size="small"
|
|
@click="handleAdd">新增小区</el-button>
|
|
<div class="btn_upload"
|
|
v-if="agencyObj.level==='community'||agencyObj.level==='grid'">
|
|
<el-button style=""
|
|
type="blue"
|
|
size="small"
|
|
@click="handleExportModule('community')">下载小区模板</el-button>
|
|
|
|
<el-upload ref="upload_community"
|
|
style=""
|
|
:multiple='false'
|
|
:show-file-list='false'
|
|
:before-upload="((file)=>{beforeUpload(file, 'community')})"
|
|
action=""
|
|
accept=".xls,.xlsx"
|
|
: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">
|
|
<el-table :data="tableData"
|
|
border
|
|
:height="tableHeight"
|
|
v-loading="tableLoading"
|
|
:header-cell-style="{background:'#2195FE',color:'#FFFFFF'}"
|
|
style="width: 100%">
|
|
<el-table-column prop="neighborHoodName"
|
|
label="小区名称"
|
|
min-width="100">
|
|
</el-table-column>
|
|
<el-table-column prop="agencyName"
|
|
label="所属组织"
|
|
min-width="100">
|
|
</el-table-column>
|
|
<el-table-column prop="gridName"
|
|
label="所属网格"
|
|
min-width="120">
|
|
</el-table-column>
|
|
<el-table-column prop="address"
|
|
label="详细地址"
|
|
min-width="180">
|
|
</el-table-column>
|
|
<el-table-column prop="remark"
|
|
label="备注"
|
|
min-width="50">
|
|
</el-table-column>
|
|
<el-table-column label="操作"
|
|
fixed="right"
|
|
width="140"
|
|
header-align="center"
|
|
align="center"
|
|
class="operate">
|
|
<template slot-scope="scope">
|
|
|
|
<!-- <el-button type="text"
|
|
style="color:#feb349;text-decoration: underline;"
|
|
size="small"
|
|
@click="handleToNextLevel(scope.row)">进入</el-button> -->
|
|
<el-button type="text"
|
|
style="color:#1C6AFD;text-decoration: underline;"
|
|
size="small"
|
|
@click="handleDetail(scope.row)">查看</el-button>
|
|
<el-button type="text"
|
|
style="color:#00A7A9;text-decoration: underline;"
|
|
size="small"
|
|
@click="handleEdit(scope.row)">修改</el-button>
|
|
|
|
<el-button type="text"
|
|
style="color:#D51010;text-decoration: underline;"
|
|
size="small"
|
|
@click="handleDelete(scope.row)">删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<div>
|
|
<el-pagination @size-change="handleSizeChange"
|
|
@current-change="handleCurrentChange"
|
|
:current-page.sync="pageNo"
|
|
:page-sizes="[20, 50, 100, 200]"
|
|
:page-size="pageSize"
|
|
layout="sizes, prev, pager, next, total"
|
|
:total="total">
|
|
</el-pagination>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 修改弹出框 -->
|
|
<el-dialog :visible.sync="formShow"
|
|
:close-on-click-modal="false"
|
|
:close-on-press-escape="false"
|
|
:title="formTitle"
|
|
width="850px"
|
|
top="5vh"
|
|
@closed="diaClose">
|
|
<community-form ref="ref_form"
|
|
@dialogCancle="addFormCancle"
|
|
@dialogOk="addFormOk"></community-form>
|
|
</el-dialog>
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import CommunityForm from './communityForm'
|
|
|
|
import { requestPost } from "@/js/dai/request";
|
|
import { mapGetters } from 'vuex'
|
|
import { Loading } from 'element-ui' // 引入Loading服务
|
|
|
|
let loading // 加载动画
|
|
export default {
|
|
data () {
|
|
return {
|
|
loading: false,
|
|
total: 0,
|
|
pageSize: 20,
|
|
pageNo: 0,
|
|
tableLoading: true,
|
|
|
|
agencyObj: {},//树所选的组织对象
|
|
ownerName: '',
|
|
ownerPhone: '',
|
|
tableData: [],
|
|
|
|
//form相关
|
|
formShow: false,
|
|
formTitle: '新增小区',
|
|
|
|
files: "",
|
|
fileName: "",
|
|
uploadUlr: window.SITE_CONFIG['apiURL'] + '/gov/org/neighborhood/import'
|
|
|
|
}
|
|
},
|
|
components: {
|
|
CommunityForm
|
|
},
|
|
async mounted () {
|
|
|
|
},
|
|
computed: {
|
|
tableHeight () {
|
|
|
|
return (this.clientHeight - 300)
|
|
|
|
},
|
|
rowHeight () {
|
|
return (this.clientHeight - 200) + 'px'
|
|
},
|
|
...mapGetters(['clientHeight'])
|
|
},
|
|
methods: {
|
|
|
|
handleSearch () {
|
|
this.loadTable()
|
|
},
|
|
async loadTable (fromTree, treeObj) {
|
|
this.tableLoading = true
|
|
if (fromTree) {
|
|
this.agencyObj = treeObj
|
|
}
|
|
console.log(this.agencyObj)
|
|
const url = "/gov/org/neighborhood/neighborhoodlist"
|
|
|
|
let params = {
|
|
pageSize: this.pageSize,
|
|
pageNo: this.pageNo,
|
|
ownerName: this.ownerName,
|
|
ownerPhone: this.ownerPhone,
|
|
level: this.agencyObj.level,
|
|
id: this.agencyObj.id
|
|
}
|
|
|
|
const { data, code, msg } = await requestPost(url, params)
|
|
|
|
if (code === 0) {
|
|
this.total = data.total
|
|
this.tableData = data.list
|
|
} else {
|
|
this.$message.error(msg)
|
|
}
|
|
this.tableLoading = false
|
|
},
|
|
|
|
diaClose () {
|
|
this.$refs.ref_form.resetData()
|
|
this.formShow = false
|
|
},
|
|
|
|
handleDetail (row) {
|
|
this.formTitle = '小区详情'
|
|
this.formShow = true
|
|
this.$nextTick(() => {
|
|
this.$refs.ref_form.initForm('detail', row, this.agencyObj)
|
|
})
|
|
},
|
|
|
|
handleAdd () {
|
|
this.formTitle = '新增小区'
|
|
this.formShow = true
|
|
this.$nextTick(() => {
|
|
this.$refs.ref_form.initForm('add', null, this.agencyObj)
|
|
})
|
|
},
|
|
|
|
handleEdit (row) {
|
|
this.formTitle = '修改小区'
|
|
this.formShow = true
|
|
this.$nextTick(() => {
|
|
this.$refs.ref_form.initForm('edit', row, this.agencyObj)
|
|
})
|
|
},
|
|
|
|
handleToNextLevel (row) {
|
|
this.$emit('toNextLevel', row, 'community')
|
|
},
|
|
|
|
addFormCancle () {
|
|
this.formShow = false
|
|
},
|
|
addFormOk () {
|
|
this.formShow = false
|
|
this.loadTable()
|
|
this.$emit('refreshTree')
|
|
},
|
|
|
|
async handleDelete (row) {
|
|
|
|
this.$confirm("确认删除?", "提示", {
|
|
confirmButtonText: "确定",
|
|
cancelButtonText: "取消",
|
|
type: "warning"
|
|
})
|
|
.then(() => {
|
|
this.deleteCommunity(row)
|
|
})
|
|
.catch(err => {
|
|
if (err == "cancel") {
|
|
// this.$message({
|
|
// type: "info",
|
|
// message: "已取消删除"
|
|
// });
|
|
}
|
|
|
|
});
|
|
},
|
|
|
|
async deleteCommunity (row) {
|
|
const url = "/gov/org/neighborhood/neighborhooddel"
|
|
|
|
let params = {
|
|
neighborHoodId: row.neighborHoodId
|
|
}
|
|
|
|
const { data, code, msg } = await requestPost(url, params)
|
|
|
|
if (code === 0) {
|
|
this.$message({
|
|
type: "success",
|
|
message: "删除成功"
|
|
});
|
|
this.$emit('refreshTree')
|
|
this.loadTable()
|
|
} else {
|
|
this.$message.error(msg)
|
|
}
|
|
},
|
|
|
|
//导出表格
|
|
async handleExport () {
|
|
let title = this.agencyObj.label
|
|
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, downFileName) {
|
|
if (!data) {
|
|
return
|
|
}
|
|
|
|
var csvData = new Blob([data])
|
|
|
|
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
|
|
window.navigator.msSaveOrOpenBlob(csvData, downFileName);
|
|
}
|
|
// 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 = downFileName;
|
|
a.click();
|
|
a.remove();
|
|
window.URL.revokeObjectURL(url);
|
|
}
|
|
|
|
},
|
|
|
|
handleExportModule (type) {
|
|
let title = ''
|
|
let url = "/gov/org/neighborhood/exporttemplate"
|
|
if (type === 'community') {
|
|
title = '小区导入模板'
|
|
url = ''
|
|
|
|
} else if (type === 'building') {
|
|
title = '楼宇导入模板'
|
|
url = ''
|
|
|
|
} else if (type === 'room') {
|
|
title = '房间导入模板'
|
|
url = ''
|
|
}
|
|
|
|
let params = {}
|
|
|
|
app.ajax.exportFilePost(
|
|
url,
|
|
params,
|
|
(data, rspMsg) => {
|
|
|
|
this.download(data, title + '.xls')
|
|
},
|
|
(rspMsg, data) => {
|
|
this.$message.error(rspMsg);
|
|
}
|
|
);
|
|
},
|
|
|
|
// 上传文件之前的钩子
|
|
beforeUpload (file, type) {
|
|
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('请选择正确格式的文件')
|
|
this.files = null
|
|
this.fileName = ''
|
|
return false
|
|
} else {
|
|
this.fileName = file.name;
|
|
return true
|
|
}
|
|
|
|
},
|
|
// 上传文件个数超过定义的数量
|
|
handleExceed (files, fileList) {
|
|
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`)
|
|
},
|
|
|
|
async uploadFile (type) {
|
|
|
|
if (this.fileName == "") {
|
|
|
|
return false
|
|
}
|
|
this.loading = true
|
|
|
|
//清空上传列表
|
|
let url = ''
|
|
|
|
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'
|
|
|
|
}
|
|
window.app.ajax.post2(url, fileFormData,
|
|
(data, rspMsg) => {
|
|
if (data.code === 0 || data.code > 8000) {
|
|
// this.$message({
|
|
// type: "success",
|
|
// message: "导入成功"
|
|
// });
|
|
this.$message.success(rspMsg)
|
|
this.$emit('refreshTree')
|
|
this.loadTable()
|
|
} else {
|
|
this.$message.error(rspMsg)
|
|
}
|
|
},
|
|
(rspMsg, data) => {
|
|
|
|
this.$message.error(rspMsg)
|
|
}, { headers: { 'Content-Type': 'multipart/form-data' } })
|
|
|
|
|
|
|
|
},
|
|
|
|
handleSizeChange (val) {
|
|
this.pageSize = val
|
|
this.pageNo = 1
|
|
this.loadTable()
|
|
},
|
|
handleCurrentChange (val) {
|
|
this.pageNo = val
|
|
this.loadTable()
|
|
},
|
|
|
|
// 开启加载动画
|
|
startLoading () {
|
|
loading = Loading.service({
|
|
lock: true, // 是否锁定
|
|
text: '正在加载……', // 加载中需要显示的文字
|
|
background: 'rgba(0,0,0,.7)' // 背景颜色
|
|
})
|
|
},
|
|
// 结束加载动画
|
|
endLoading () {
|
|
// clearTimeout(timer);
|
|
if (loading) {
|
|
loading.close()
|
|
}
|
|
}
|
|
},
|
|
watch: {
|
|
filterText (val) {
|
|
this.$refs.tree.filter(val);
|
|
}
|
|
},
|
|
props: {
|
|
|
|
}
|
|
}
|
|
</script>
|
|
<style lang="scss" scoped >
|
|
@import "@/assets/scss/buttonstyle.scss";
|
|
.div_search {
|
|
display: flex;
|
|
|
|
.resi-cell {
|
|
display: flex;
|
|
align-items: center;
|
|
.resi-cell-label {
|
|
width: 70px;
|
|
box-sizing: border-box;
|
|
margin-right: 15px;
|
|
text-align: right;
|
|
// line-height: 32;
|
|
}
|
|
|
|
.resi-cell-input {
|
|
width: 180px;
|
|
}
|
|
}
|
|
}
|
|
|
|
.div_table {
|
|
margin-top: 20px;
|
|
}
|
|
.div_search {
|
|
display: flex;
|
|
|
|
.resi-cell {
|
|
display: flex;
|
|
align-items: center;
|
|
.resi-cell-label {
|
|
width: 70px;
|
|
box-sizing: border-box;
|
|
margin-right: 15px;
|
|
text-align: right;
|
|
// line-height: 32;
|
|
}
|
|
|
|
.resi-cell-input {
|
|
width: 180px;
|
|
}
|
|
}
|
|
}
|
|
|
|
.div_btn {
|
|
display: flex;
|
|
margin-top: 20px;
|
|
|
|
.btn_upload {
|
|
margin-left: 10px;
|
|
display: flex;
|
|
}
|
|
}
|
|
|
|
.el-row {
|
|
/* margin-bottom: 20px; */
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
margin-top: 10px;
|
|
margin-right: 50px;
|
|
}
|
|
</style>
|
|
|