市北互联平台前端仓库
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.

743 lines
21 KiB

4 years ago
<template>
<div>
3 years ago
4 years ago
<div class="div_btn">
4 years ago
<el-button style=""
4 years ago
class="diy-button--add"
4 years ago
size="small"
@click="handleAdd">新增小区</el-button>
4 years ago
<div class="btn_upload"
v-if="showImportBtn">
<el-button style=""
4 years ago
class="diy-button--export"
4 years ago
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"
4 years ago
class="diy-button--delete">导入小区数据</el-button>
</el-upload>
<el-button style=";margin-left:10px"
4 years ago
class="diy-button--export"
4 years ago
size="small"
3 years ago
@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"
3 years ago
class="diy-button--delete">导入楼栋数据</el-button>
</el-upload>
<el-button style=";margin-left:10px"
4 years ago
class="diy-button--export"
4 years ago
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"
4 years ago
class="diy-button--delete">导入房屋数据</el-button>
</el-upload>
</div>
4 years ago
<el-button style="margin-left:10px"
class="diy-button--reset"
size="small"
@click="handleExport">导出</el-button>
3 years ago
<el-button v-if="agencyObj.level == 'community'"
style="margin-left:10px"
class="diy-button--qrcode"
size="small"
@click="handleDownQr(agencyObj, 'community')">社区二维码</el-button>
3 years ago
<el-button style="float:left;margin-left:10px"
class="diy-button--more"
size="small"
@click="deleteBatch">批量删除</el-button>
4 years ago
</div>
3 years ago
<div class="div_table_item">
<el-table ref="ref_table"
:data="tableData"
4 years ago
border
4 years ago
:height="tableHeight"
v-loading="tableLoading"
:header-cell-style="{background:'#2195FE',color:'#FFFFFF'}"
style="width: 100%"
3 years ago
:show-overflow-tooltip="true"
@select-all="selectAll"
@selection-change="selectionChange">
<el-table-column type="selection"
:selectable="checkSelect"
width="55">
</el-table-column>
4 years ago
<el-table-column prop="neighborHoodName"
label="小区名称"
min-width="100">
3 years ago
<!-- <template slot-scope="scope">
<a class="name-a" @click="handleDetail(scope.row)">
{{ scope.row.neighborHoodName }}
</a>
</template> -->
4 years ago
</el-table-column>
<el-table-column prop="agencyName"
label="所属组织"
min-width="100">
4 years ago
</el-table-column>
<el-table-column prop="gridName"
label="所属网格"
min-width="120">
4 years ago
</el-table-column>
4 years ago
<!-- <el-table-column prop="总单元数"
label="所属网格"
min-width="80">
</el-table-column>
<el-table-column prop="总户数"
label="所属网格"
min-width="80">
</el-table-column> -->
4 years ago
<el-table-column prop="address"
label="详细地址"
min-width="180">
4 years ago
</el-table-column>
3 years ago
4 years ago
<el-table-column label="操作"
fixed="right"
width="140"
4 years ago
header-align="center"
align="center"
class="operate">
<template slot-scope="scope">
<!-- <el-button type="text"
4 years ago
style="color:#feb349;text-decoration: underline;"
size="small"
@click="handleToNextLevel(scope.row)">进入</el-button> -->
3 years ago
<!-- <el-button type="text"
class="div-table-button--qr"
size="small"
@click="handleDownQr(scope.row, 'neighborHood')">二维码</el-button> -->
4 years ago
<el-button type="text"
4 years ago
class="div-table-button--detail"
4 years ago
size="small"
@click="handleDetail(scope.row)">查看</el-button>
<el-button v-if="scope.row.showBtn"
type="text"
4 years ago
class="div-table-button--edit"
4 years ago
size="small"
@click="handleEdit(scope.row)">修改</el-button>
<el-button v-if="scope.row.showBtn"
type="text"
4 years ago
class="div-table-button--delete"
4 years ago
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"
4 years ago
:page-sizes="[20, 50, 100, 200]"
4 years ago
:page-size="pageSize"
4 years ago
layout="sizes, prev, pager, next, total"
4 years ago
:total="total">
</el-pagination>
</div>
4 years ago
</div>
<!-- 修改弹出框 -->
<el-dialog :visible.sync="formShow"
:close-on-click-modal="false"
:close-on-press-escape="false"
:title="formTitle"
width="850px"
4 years ago
top="5vh"
4 years ago
class="dialog-h"
4 years ago
@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服务
3 years ago
import axios from 'axios'
4 years ago
let loading // 加载动画
export default {
data () {
return {
importBuildingLoading: false,
importRoomLoading: false,
importCommunityLoading: false,
4 years ago
total: 0,
pageSize: 20,
4 years ago
pageNo: 0,
tableLoading: true,
3 years ago
showImportBtn: false,//是否显示操作按钮,根据登录人所属组织判断
4 years ago
agencyObj: {},//树所选的组织对象
3 years ago
4 years ago
tableData: [],
4 years ago
validTableDataNum: 0,//有效的数据数量,即有权限操作的数据数量
selection: [],
4 years ago
showDeletBtn: false,
4 years ago
4 years ago
//form相关
formShow: false,
formTitle: '新增小区',
files: "",
fileName: "",
uploadUlr: window.SITE_CONFIG['apiURL'] + '/gov/org/neighborhood/import'
}
},
components: {
CommunityForm
},
async mounted () {
},
computed: {
4 years ago
tableHeight () {
3 years ago
return this.$store.state.inIframe ? this.clientHeight - 310 + this.iframeHeight : this.clientHeight - 310
4 years ago
},
...mapGetters(['clientHeight', 'iframeHeight'])
4 years ago
},
methods: {
3 years ago
4 years ago
async loadTable (fromTree, treeObj) {
console.log(111, this.staffAgencyId)
this.tableLoading = true
4 years ago
if (fromTree) {
this.agencyObj = treeObj
if (this.agencyObj.level === 'community') {//只有社区和网格显示操作按钮
if (this.agencyObj.id === this.staffAgencyId) {//如果所选树的组织id和登录人员id相同,有权限
this.showImportBtn = true
} else {
this.showImportBtn = false
}
} else if (this.agencyObj.level === 'grid') {//网格下
if (this.agencyObj.pid === this.staffAgencyId) {//如果所选树的父级组织id和登录人员id相同,有权限
this.showImportBtn = true
} else {
this.showImportBtn = false
}
} else {
this.showImportBtn = false
}
4 years ago
}
4 years ago
const url = "/gov/org/neighborhood/neighborhoodlist"
4 years ago
4 years ago
let params = {
pageSize: this.pageSize,
pageNo: this.pageNo,
3 years ago
4 years ago
level: this.agencyObj.level,
id: this.agencyObj.id
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
4 years ago
this.validTableDataNum = 0
4 years ago
this.total = data.total
data.list.forEach(item => {
if (item.agencyId === this.staffAgencyId) {
item.showBtn = true
4 years ago
this.validTableDataNum++
} else {
item.showBtn = false
}
});
4 years ago
this.tableData = data.list
} else {
this.$message.error(msg)
}
this.tableLoading = false
4 years ago
},
checkSelect (row, index) {
let isChecked = false;
if (row.showBtn) { // 判断里面是否存在某个参数
isChecked = true
} else {
isChecked = false
}
return isChecked
},
4 years ago
diaClose () {
this.$refs.ref_form.resetData()
4 years ago
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
4 years ago
this.$nextTick(() => {
this.$refs.ref_form.initForm('edit', row, this.agencyObj)
})
4 years ago
},
4 years ago
handleToNextLevel (row) {
this.$emit('toNextLevel', row, 'community')
},
4 years ago
addFormCancle () {
this.formShow = false
},
addFormOk () {
this.formShow = false
this.loadTable()
this.$emit('refreshTree')
},
3 years ago
deleteBatch () {
if (this.selection.length > 0) {
this.$confirm("确认删除选择的小区?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.deleteCommunityBatch()
})
.catch(err => {
if (err == "cancel") {
// this.$message({
// type: "info",
// message: "已取消删除"
// });
}
});
} else {
this.$message.warning('请先选择要删除的小区')
}
},
selectAll (selection) {
4 years ago
this.selection = selection
},
selectionChange (selection) {
this.selection = selection
4 years ago
},
4 years ago
async handleDelete (row) {
this.$confirm("确认删除?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.deleteCommunity(row)
})
.catch(err => {
if (err == "cancel") {
// this.$message({
// type: "info",
// message: "已取消删除"
// });
}
});
},
async deleteCommunityBatch () {
let ids = []
console.log(this.selection)
this.selection.forEach(element => {
ids.push(element.neighborHoodId)
});
const url = "/gov/org/house/delete"
let params = {
type: 'neighborHood',
ids: ids
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
this.$message({
type: "success",
message: "删除成功"
});
this.$emit('refreshTree')
this.loadTable()
} else if (code > 8000) {
this.$message({
showClose: true,
message: msg,
duration: 0
})
this.$emit('refreshTree')
this.loadTable()
} else {
this.$message.error(msg)
}
},
4 years ago
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)
}
},
3 years ago
async handleDownQr (row, type) {
// const url = window.SITE_CONFIG['apiURL'] + `/gov/org/icneighborhood/createQrCode/${row.neighborHoodId}`
const url = '/gov/org/agency/create-qrcode'
const _id = type == 'community' ? row.id : row.neighborHoodId
const params = {
id: _id,
type
}
await axios({
method: 'POST',
url: window.SITE_CONFIG['apiURL'] + url,
data: params,
responseType: 'blob'
}).then(res => {
console.log('res----1r', res)
if (res.headers["content-disposition"]) {
let fileName = window.decodeURI(res.headers["content-disposition"].split(";")[1].split("=")[1])
console.log('filename', fileName)
this.download(res.data, fileName) //释放掉blob对象
} else this.$message.error('下载失败')
// this.download(res.data, '1.png')
})
},
4 years ago
//导出表格
async handleExport () {
let title = this.agencyObj.label
title = title + '—小区列表'
const url = "/gov/org/neighborhood/exportneighborhoodinfo"
let params = {
3 years ago
4 years ago
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);
}
);
},
// 下载文件
4 years ago
download (data, downFileName) {
4 years ago
if (!data) {
return
}
var csvData = new Blob([data])
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
4 years ago
window.navigator.msSaveOrOpenBlob(csvData, downFileName);
4 years ago
}
// 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;
4 years ago
a.download = downFileName;
4 years ago
a.click();
a.remove();
window.URL.revokeObjectURL(url);
}
},
4 years ago
handleExportModule (type) {
4 years ago
let title = ''
let url = ""
4 years ago
if (type === 'community') {
title = '小区导入模板'
url = '/gov/org/neighborhood/exporttemplate'
4 years ago
} else if (type === 'building') {
3 years ago
title = '楼栋导入模板'
url = '/gov/org/building/exporttemplate'
4 years ago
} else if (type === 'room') {
title = '房间导入模板'
url = '/gov/org/house/exporttemplate'
4 years ago
}
4 years ago
let params = {}
app.ajax.exportFilePost(
url,
params,
(data, rspMsg) => {
this.download(data, title + '.xls')
},
(rspMsg, data) => {
this.$message.error(rspMsg);
}
);
},
// 上传文件之前的钩子
4 years ago
beforeUpload (file, type) {
4 years ago
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('请选择正确格式的文件')
4 years ago
this.files = null
this.fileName = ''
4 years ago
return false
} else {
this.fileName = file.name;
return true
}
},
// 上传文件个数超过定义的数量
handleExceed (files, fileList) {
this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`)
},
4 years ago
async uploadFile (type) {
4 years ago
if (this.fileName == "") {
this.$message.warning('请选择要上传的文件!')
4 years ago
return false
}
this.$message({
showClose: true,
message: '导入中,请到系统管理-导入记录中查看进度',
duration: 0
})
4 years ago
//清空上传列表
4 years ago
let url = ''
4 years ago
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是要传的文件名
4 years ago
if (type === 'community') {
this.importCommunityLoading = true
4 years ago
this.$refs['upload_community'].clearFiles()
url = '/gov/org/icneighborhood/neighborhoodimport'
} else if (type === 'building') {
this.$refs['upload_building'].clearFiles()
url = '/gov/org/building/buildingimport'
this.importBuildingLoading = true
4 years ago
} else if (type === 'room') {
this.$refs['upload_room'].clearFiles()
url = '/gov/org/house/houseimport'
this.importRoomLoading = true
4 years ago
}
window.app.ajax.post2(url, fileFormData,
(data, rspMsg) => {
if (data.code === 0 && data.msg == 'success') {
4 years ago
// this.$message.success('导入成功')
} else {
4 years ago
// this.$message({
// showClose: true,
// message: rspMsg,
// duration: 0,
// type: "error"
// })
// this.$message.error(rspMsg)
}
this.$emit('refreshTree')
this.loadTable()
// this.showMessage(rspMsg)
if (type === 'community') {
this.importCommunityLoading = false
} else if (type === 'building') {
this.importBuildingLoading = false
} else if (type === 'room') {
this.importRoomLoading = false
}
},
(rspMsg, data) => {
if (type === 'community') {
this.importCommunityLoading = false
} else if (type === 'building') {
this.importBuildingLoading = false
} else if (type === 'room') {
this.importRoomLoading = false
}
// this.$message.error(rspMsg)
}, { headers: { 'Content-Type': 'multipart/form-data' } })
4 years ago
4 years ago
4 years ago
},
showMessage (msg) {
this.$alert(msg, '操作结果', {
confirmButtonText: '关闭',
callback: action => {
this.$emit('refreshTree')
this.loadTable()
}
});
},
4 years ago
handleSizeChange (val) {
this.pageSize = val
this.pageNo = 1
this.loadTable()
4 years ago
},
handleCurrentChange (val) {
this.pageNo = val
this.loadTable()
4 years ago
},
// 开启加载动画
startLoading () {
loading = Loading.service({
lock: true, // 是否锁定
text: '正在加载……', // 加载中需要显示的文字
background: 'rgba(0,0,0,.7)' // 背景颜色
})
},
// 结束加载动画
endLoading () {
// clearTimeout(timer);
if (loading) {
loading.close()
}
}
},
watch: {
4 years ago
selection (val) {
if (val.length > 0) {
this.showDeletBtn = true
} else {
this.showDeletBtn = false
}
4 years ago
}
},
props: {
staffAgencyId: {
type: String,
default: '',
},
4 years ago
}
}
</script>
<style lang="scss" scoped >
@import "@/assets/scss/modules/visual/communityManage.scss";
4 years ago
</style>
4 years ago
<style >
.el-message.is-closable .el-message__content {
line-height: 20px;
}
</style>
4 years ago