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.

499 lines
15 KiB

3 years ago
<template>
<div style="position: relative;" v-loading='fullscreenLoading'>
<div class='opensearch' @click='openSearch = true' v-if="!openSearch">
查询
</div>
<div class='mapsearch' v-else>
<span class="closeSearch" @click='openSearch = false'>
<i class="el-icon-arrow-right"></i>
</span>
<div style="display: flex;justify-content: flex-start;flex-wrap: wrap;margin-bottom:10px">
3 years ago
<Input v-model="select.name" style="width: 65px;margin-right: 10px;" placeholder="姓名" />
<el-select class='street' v-model="select.street" placeholder="街道" clearable>
<el-option v-for="item in streetList" :key="item.value" :label="item.value" :value="item.value">
</el-option>
3 years ago
</el-select>
<el-select class='street' v-model="select.disabilitytype" placeholder="残疾类别" clearable>
<el-option v-for="item in typeList" :key="item.value" :label="item.value" :value="item.value">
</el-option>
</el-select>
<el-select class='street' v-model="select.disabilitylevel" placeholder="残疾等级" clearable>
<el-option v-for="item in levelList" :key="item.value" :label="item.value" :value="item.value">
</el-option>
</el-select>
<Button type="primary" @click="getindex"></Button>
</div>
<div>
<Table :width="482" :max-height='280' @on-row-click='movetoperson' :height='280' highlight-row
ref="currentRowTable" :columns="columns" :data="mapList" />
<Page :current="select.page" :total="select.total" size="small" show-total show-elevator
style="padding-top: 14px;display: flex;justify-content: center;" @on-change="pageChange" />
</div>
</div>
3 years ago
<div class="map" id="map" :style="{'height':mapHeight+'px'}"></div>
<div ref='infoWindow' id="infoWindow">
<i @click='closeWin' class="el-icon-close"></i>
<div v-for="item in openData">
<p>姓名<span>{{item.name}}</span></p>
3 years ago
<p>现居住地<span>{{item.reside}}</span></p>
3 years ago
<p class="showInfo" @click="showInfo(item.id)"></p>
3 years ago
</div>
</div>
</div>
</template>
<script>
import {
getparameter
} from "@/api/system/dictionary";
3 years ago
import {
3 years ago
index,
save
3 years ago
} from "@/api/system/baseForm.js"
import {
Message
3 years ago
} from 'element-ui'
3 years ago
export default {
data() {
return {
3 years ago
zoom: 11,
3 years ago
center: [119.597897, 31.723247],
3 years ago
mapHeight: 0,
map: null,
makerList: [],
3 years ago
infoWindow: null,
openData: [],
3 years ago
// markerList: [],
ispage:false,
3 years ago
mapList: [],
fullscreenLoading: false,
3 years ago
streetList: [],
typeList:[],
levelList:[],
openSearch: false,
select: {
page_size: 50,
page: 1,
3 years ago
street: '',
disabilitylevel:'',
disabilitytype:'',
name: '',
table_name: 'records',
show_relation: ['admin', 'department'],
total: 0
},
columns: [{
title: '姓名',
3 years ago
key: 'name',
render:(h,params)=>{
return h('i',{
attrs:{
class:'el-icon-position'
}
},params.row.name)
}
}, {
title: '所属街道',
3 years ago
key: 'jiedao',
3 years ago
}, {
title: '残疾类别',
key: 'disabilitytype',
}, {
title: '残疾等级',
key: 'disabilitylevel',
}]
3 years ago
}
},
3 years ago
mounted() {
// typeList:[],
// levelList:[],
3 years ago
this.initHeight()
3 years ago
this.getLabel()
3 years ago
this.$nextTick(function() {
this.mapInit()
})
3 years ago
if (this.$route.query?.street) {
this.select.street = this.$route.query.street
this.openSearch = true
this.getindex()
}else{
this.getindex()
}
3 years ago
},
methods: {
3 years ago
// openFullScreen() {
// this.fullscreenLoading = true;
// setTimeout(() => {
// this.fullscreenLoading = false;
// }, 2000);
3 years ago
// },
async getLabel() {
let numbers = {
number:['streetList','disabilitylevelList','disabilitytypeList']
}
const res = await getparameter(numbers);
for(var k of res){
this.streetList = k.number=='streetList'?k.detail:this.streetList
this.typeList = k.number=='disabilitytypeList'?k.detail:this.typeList
this.levelList = k.number=='disabilitylevelList'?k.detail:this.levelList
}
},
3 years ago
async initHeight() {
3 years ago
let winHeight = document.body.clientHeight
this.mapHeight = winHeight - 50 - 20
},
// 初始化地图,并加载行政区域
3 years ago
async mapInit() {
3 years ago
this.map = new AMap.Map("map", {
center: this.center,
mapStyle: "amap://styles/bfb1bb3feb0db7082367abca96b8d214", // 设置地图的显示样式
zoom: this.zoom
});
// 行政区域加载
let that = this
let adcode = ['320413'];
this.areaBG(this.map, adcode);
this.infoWindow = new AMap.InfoWindow({
isCustom: true,
autoMove: true,
avoid: [20, 20, 20, 20],
content: this.$refs.infoWindow,
closeWhenClickMap: true,
offset: new AMap.Pixel(-10, -10)
3 years ago
})
},
// 加载金坛区
areaBG(map, adcode) {
AMap.service('AMap.DistrictSearch', function() {
let opts = {
subdistrict: 1, // 返回下一级行政区
extensions: 'all', // 返回行政区边界坐标组等具体信息
level: 'city', // 查询行政级别为市
// adcode:'320413'
};
// 实例化DistrictSearch
let district = new AMap.DistrictSearch(opts);
district.setLevel('district');
// 行政区查询
district.search(`${adcode}`, function(status, result) {
// 获取边界信息
let bounds = result.districtList[0].boundaries;
let polygons = [];
if (bounds) {
for (let i = 0, l = bounds.length; i < l; i++) {
// 生成行政区划polygon
let polygon = new AMap.Polygon({
map: map,
strokeWeight: 1,
path: bounds[i],
fillOpacity: 0.2,
fillColor: 'rgba(71,228,194,1)',
strokeColor: '#147d38'
});
polygons.push(polygon);
}
}
});
});
},
3 years ago
// 增加点位
3 years ago
setMapMarker() {
var that = this
3 years ago
// console.log("123",m.longitude, m.latitude)
// console.log('456',gcj02towgs84(m.longitude, m.latitude))
that.map.remove(that.makerList)
that.makerList = []
// this.map.clearMap();
let list = this.mapList.map((m) => {
return {
id: m.id, //数据id
name: m.name, //数据名称
reside: m.reside,
// lnglat: [m.lon, m.lat],//经纬度数据
lnglat: [m.longitude, m.latitude], //这里我是转化一下数据返回的是84坐标系需要转成高德坐标系否则会有偏差
style: 0, //渲染的样式下标,关联第一步创建的样式对象数组的数据
};
});
// this.$nextTick(() => {
// var mass = new AMap.MassMarks(list, {
// opacity: 0.8,
// zIndex: 111,
// cursor: 'pointer',
// style: {
// url: 'https://webapi.amap.com/images/mass/mass1.png',
// anchor: new AMap.Pixel(6, 6),
// size: new AMap.Size(11, 11),
// zIndex: 999,
// }
// });
// // var marker = new AMap.Marker({
// // content: ' ',
// // map: this.map,
// // });
// mass.on('mouseover', function(e) {
// console.log("e", e)
// that.openData = []
// // marker.setPosition(e.data.lnglat);
// // marker.setLabel({
// // content: e.data.name
// // })
// that.openData.push(e.data)
// that.infoWindow.open(that.map, e.data.lnglat)
// });
// // marker.on('click', (e) => {
// // this.openData = []
// // if (e.target.w.extData === item.id) {
// // this.openData.push(item)
// // }
// // this.infoWindow.open(this.map, e.target.getPosition())
// // }),
// mass.setMap(this.map);
// })
this.mapList.forEach((item, index) => {
3 years ago
// 遍历生成多个标记点
if (!item.longitude || !item.latitude) {
return
}
3 years ago
let marker = new AMap.Text({
map: this.map,
text: item.name,
zIndex: 9999999,
offset: new AMap.Pixel(-13, -30),
3 years ago
position: [item.longitude, item.latitude],
3 years ago
clickable: true,
extData: item.id,
style: {
'border': '1px solid red',
'padding': '0px 5px'
}
})
marker.on('click', (e) => {
this.openData = []
if (e.target.w.extData === item.id) {
this.openData.push(item)
}
this.infoWindow.open(this.map, e.target.getPosition())
}),
this.makerList.push(marker)
3 years ago
});
this.map.add(this.makerList)
3 years ago
},
closeWin() {
this.infoWindow.close()
},
showInfo(id) {
3 years ago
this.$router.push({
path: "/record/personinfo",
query: {
id: id
}
})
},
pageChange(e) {
3 years ago
this.select.page = e
this.ispage = true
this.getindex()
},
movetoperson(row, index) {
this.openData = []
3 years ago
this.openData.push(row)
if(row.longitude && row.latitude){
this.map.panTo([row.longitude, row.latitude])
this.infoWindow.open(this.map, [row.longitude, row.latitude])
}else{
this.map.panTo(this.center)
this.infoWindow.open(this.map, this.center)
}
},
3 years ago
async getindex() {
if(!this.ispage){
this.select.page = 1
}
3 years ago
this.fullscreenLoading = true;
this.mapList = []
// this.map.remove(this.marker)
3 years ago
let res = await index({
page_size: this.select.page_size,
page: this.select.page,
table_name: this.select.table_name,
show_relation: this.select.show_relation,
filter: [{
"key": "name",
"op": "like",
"value": this.select.name
}, {
3 years ago
"key": "jiedao",
"op": "eq",
"value": this.select.street
3 years ago
},{
"key": "disabilitytype",
"op": "eq",
"value": this.select.disabilitytype
},{
"key": "disabilitylevel",
"op": "eq",
"value": this.select.disabilitylevel
}],
3 years ago
})
3 years ago
this.select.total = res.total
3 years ago
this.ispage = false
3 years ago
if(res.data.length<1){
Message({
type: 'warning',
message: '暂无数据'
})
this.fullscreenLoading = false;
return
}
3 years ago
let _data = []
let _nolng = [] //只有地址没有经纬度
for (var k of res.data) {
if (k.longitude && k.latitude) {
_data.push(k)
} else {
if (k.reside == null || k.reside == '') {
// return
} else {
_nolng.push(k)
3 years ago
}
}
}
3 years ago
// return
this.mapList = _data
var geocoder = null
3 years ago
let that = this
if(_nolng.length>0){
AMap.plugin("AMap.Geocoder", function() {
geocoder = new AMap.Geocoder({
city: '常州' // city 指定进行编码查询的城市支持传入城市名、adcode 和 citycode
})
_nolng.map((k, index) => {
geocoder.getLocation(k.reside, function(status, result) {
if (status === 'complete' && result.info === 'OK') {
// result中对应详细地理坐标信息
k.longitude = result.geocodes[0].location.lng
k.latitude = result.geocodes[0].location.lat
3 years ago
// save({
// table_name: that.select.table_name,
// ...k
// })
3 years ago
}
if (index == _nolng.length - 1) {
that.mapList.push(..._nolng)
that.setMapMarker()
that.fullscreenLoading = false;
}
})
})
// for (let k of _nolng) {
// }
})
}else{
that.setMapMarker()
that.fullscreenLoading = false;
}
// setTimeout(function() {
// that.mapList.push(..._nolng)
// that.setMapMarker()
// that.fullscreenLoading = false;
// }, 5000);
3 years ago
3 years ago
3 years ago
},
3 years ago
}
}
</script>
<style scoped>
#infoWindow {
position: relative;
}
#infoWindow>div {
background: #fff;
border: 1px solid red;
padding: 10px;
width: 180px;
}
/deep/ #infoWindow .el-icon-close {
position: absolute;
top: 5px;
right: 5px;
cursor: pointer;
}
.showInfo {
text-align: center;
cursor: pointer;
color: #147d38;
3 years ago
}
.opensearch {
position: absolute;
top: 10px;
right: 10px;
z-index: 99;
color: #fff;
width: 50px;
height: 50px;
background: #147d38;
border-radius: 50px;
text-align: center;
line-height: 50px;
cursor: pointer;
font-weight: bold;
}
.mapsearch {
position: absolute;
top: 10px;
right: 10px;
z-index: 99;
background: #fff;
padding: 10px;
}
.closeSearch{
position: absolute;
top: 40%;
left: -20px;
/* border: 1px solid red; */
width: 40px;
height: 40px;
border-radius: 40px 0 0 40px;
text-align: center;
line-height: 40px;
font-size: 22px;
background: #fff;
z-index: 99;
cursor: pointer;
}
.street {
3 years ago
margin-right: 10px;
width:105px
}
/deep/ .street .el-input__inner {
height: 32px;
}
/deep/ .street .el-select__caret {
line-height: 32px;
}
3 years ago
</style>