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

727 lines
18 KiB

4 years ago
<template>
4 years ago
<div style="position: relative">
4 years ago
<!-- 组织路由 -->
4 years ago
<div class="div_top">
4 years ago
<div class="router_line"></div>
4 years ago
<div class="div_router">
4 years ago
<span class="router_parents"
4 years ago
v-for="(item,index) in runAgencyArray"
@click="handleClickAgency(index)"
4 years ago
:key="index">{{item.name}}<span class="arrow">></span></span>
4 years ago
<span class="router_child">{{orgData.name}}</span>
</div>
4 years ago
</div>
<people-search v-if="orgLevel==='search'"
@toSubAgency="toSubAgency"
ref="ref_search"></people-search>
<people v-else-if="orgLevel==='people'"
:userId="selUserId"
ref="ref_people"></people>
4 years ago
<div v-else
class="div_content">
4 years ago
<!-- <basic-info-community ref="ref_community"></basic-info-community> -->
<basic-info-community v-if="orgLevel==='neighborHood'"
4 years ago
ref="ref_community"></basic-info-community>
<div v-else
id="map"
class="div_map">
</div>
4 years ago
4 years ago
<div class="div_data">
4 years ago
<div class="div_search">
4 years ago
<el-input size="mini"
@focus="handleSearch"
4 years ago
WarningColor='warning'
placeholder="请输入姓名">
4 years ago
<i slot="prefix"
class="icon">
<img src="../../../../assets/img/modules/visual/sousuo.png"
alt />
</i>
</el-input>
<div class="btn"
@click="handleSearch">搜索</div>
4 years ago
</div>
4 years ago
<div class="div_info">
<el-scrollbar style="height:100%">
<div class="info_tip">
<img src="../../../../assets/img/shuju/title-tip.png"
alt />
<div class="tip_title">分类列表</div>
</div>
<div class="info_list">
<div v-for="(item,index) in listDatashow"
:key="index"
class="item">
<div class="list_item">
<div v-for="(colItem,colIndex) in item"
:key="colIndex"
class="list_item_col">
<img :src="colItem.dataIcon"
alt />
<div class="item_content">
<div class="item_label">{{colItem.label}}</div>
<div class="item_count">{{colItem.count}}</div>
</div>
</div>
</div>
<div :class="['item_line',{'last_line':index==(listDatashow.length-1)}]"></div>
</div>
</div>
</el-scrollbar>
</div>
4 years ago
</div>
</div>
</div>
</template>
<script>
import 'ol/ol.css'
import { Map, View } from 'ol'
import TileLayer from 'ol/layer/Tile.js';
import XYZ from 'ol/source/XYZ.js';
import VectorLayer from 'ol/layer/Vector.js';
import VectorSource from 'ol/source/Vector.js';
import GeoJSON from 'ol/format/GeoJSON.js';
4 years ago
import { defaults as defaultInteractions, Select, DoubleClickZoom } from 'ol/interaction.js';
import { Circle as CircleStyle, Fill, Stroke, Style, Text } from 'ol/style.js';
4 years ago
import { mapGetters } from "vuex";
import { Loading } from 'element-ui'; //引入Loading服务
import { requestPost } from "@/js/dai/request";
4 years ago
import BasicInfoCommunity from "./basicInfoCommunity";
import PeopleSearch from "./peopleSearch";
import People from "./people";
4 years ago
4 years ago
let loading;//加载动画
4 years ago
let x = 1500
let y = 700
4 years ago
let map;
let mapView;
let gaodeMapLayer;//背景地图图层
let polygonLayer;//变电站标注图层
let polygonSource;//变电站标注多边形
let select;//选中标注
4 years ago
4 years ago
//变电站标注的文字样式
var createTextStyle = function (feature) {
return new Text({
textAlign: undefined,
font: "bold 18px Arial",
//fontFamily: "Courier New, monospace",
fontWeight: "bold",
text: feature.values_.name,
//text: "变电站名称",
fill: new Fill({ color: "#007ab9" }),
stroke: new Stroke({ color: "#ffffff", width: 3 }),
offsetY: 0,
overflow: true,
});
};
//变电站标注样式
var polygonStyleFunction = (function () {
return function (feature) {
return new Style({
fill: new Fill({
color: [255, 255, 255, 0.3]
}),
stroke: new Stroke({
color: [0, 153, 255, 1],
width: 3
}),
text: createTextStyle(feature)
});;
};
})()
const vueGis = {
name: 'HomeMap',
data () {
return {
centerPoint: [],//中心点位置
zoom: 14,//缩放范围:区14
minZoom: 1,//最小缩放
orgData: {},//当前组织对象
orgId: '',
orgLevel: '',
subAgencyArray: [],//下拉框数据
4 years ago
//右侧搜索
searchName: "",
4 years ago
//右侧列表
4 years ago
listData: [],//得到的数据
listDatashow: [],//处理成一行两列的数据
listData1: [
{
id: "1",
label: "党员",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dabing.png')
},
{
id: "2",
label: "低保人员",
count: 30000,
dataIcon: ''
},
{
id: "3",
label: "保障房人员",
count: 3,
dataIcon: ''
},
{
id: "4",
label: "失业人员",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dibao.png')
},
{
id: "5",
label: "失业人员",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dibao.png')
},
{
id: "6",
label: "失业人员",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dibao.png')
},
{
id: "7",
label: "失业人员",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dibao.png')
},
{
id: "8",
label: "失业人员",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dibao.png')
},
{
id: "9",
label: "失业人员",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dibao.png')
},
{
id: "10",
label: "失业人员",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dibao.png')
},
{
id: "11",
label: "失业人员",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dibao.png')
},
{
id: "12",
label: "失业人员",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dibao.png')
},
{
id: "13",
label: "失业人员3",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dibao.png')
},
{
id: "14",
label: "失业人员2",
count: 300,
dataIcon: require('../../../../assets/img/modules/visual/dibao.png')
},
],
4 years ago
4 years ago
//下钻层级记录
runNum: 0,
4 years ago
runAgencyArray: [],
selUserId: '',
4 years ago
}
},
async mounted () {
//加载组织数据
await this.loadOrgData()
//初始化地图
this.initMap()
//添加标注图层
this.addPolygonLayer()
//加载当前园区的标注
4 years ago
this.loadPolygon(this.subAgencyArray)
4 years ago
4 years ago
await this.loadList()
4 years ago
},
methods: {
4 years ago
handleSearch () {
4 years ago
this.toSubAgency('search')
4 years ago
},
4 years ago
//获取右侧infolist数据
async loadList () {
// const url = "/epmetuser/statsresiwarn/list"
const url = "http://yapi.elinkservice.cn/mock/245/epmetuser/statsresiwarn/list"
let params = {
id: this.orgId,
level: this.orgLevel
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
// this.listData = data
this.listData = this.listData1
this.listDatashow = []
let itemArray = []
this.listData.forEach((item, index) => {
if (!item.dataIcon) {
item.dataIcon = require('../../../../assets/img/modules/visual/dibao.png')
}
if (index % 2 === 0) {//偶数
itemArray.push(item)
} else {
itemArray.push(item)
this.listDatashow.push(itemArray)
itemArray = []
}
});
} else {
this.$message.error(msg)
}
},
//下钻到下一级 type点击的类型:polygon 点击多边形(分为点击组织/小区) search 点击搜索 people 点击详情
async toSubAgency (type, e, searchName) {
4 years ago
//点击小区neighborHood显示楼栋,点击非小区,进入下一级地图
this.runNum++
this.runAgencyArray.push(this.orgData)
if (type === 'people') {
this.orgLevel = 'people'
this.selUserId = e
this.orgId = ''
this.orgData = {
id: '',
level: 'people',
name: '人员档案'
4 years ago
}
this.searchName = searchName
} else if (type === 'search') {
this.orgLevel = 'search'
this.orgId = ''
this.orgData = {
id: '',
level: 'search',
name: '搜索'
}
this.$nextTick(() => {
// ref_tree 元素的ref value 绑定的node-key
this.$refs.ref_search.loadList();
});
4 years ago
} else {
this.subAgencyArray.forEach(item => {
if (item.id === e.selected[0].id_) {
this.orgId = item.id
this.orgLevel = item.level
this.orgData = item
}
});
if (this.orgLevel === 'neighborHood') {
this.$nextTick(() => {
// 小区id,小区名称
this.$refs.ref_community.initData('', '南山111小区');
});
} else {
this.refreshMap(true)
}
4 years ago
}
4 years ago
},
//刷新地图
async refreshMap (isRefreshView) {
4 years ago
4 years ago
//加载组织数据
await this.loadOrgData()
//加载当前园区的标注
4 years ago
await this.loadPolygon(this.subAgencyArray)
4 years ago
//重置地图中心点
if (isRefreshView) {
this.setMapLocation()
mapView.setCenter(this.centerPoint);
mapView.setZoom(this.zoom);
}
4 years ago
await this.loadList()
4 years ago
},
4 years ago
//返回所选组织
handleClickAgency (index) {
const cutNum = this.runAgencyArray.length - index//要减去的长度
this.runNum = this.runNum - cutNum
this.orgData = this.runAgencyArray[index]
4 years ago
for (let i = 0; i < cutNum; i++) {
this.runAgencyArray.pop()
4 years ago
}
4 years ago
this.orgId = this.orgData.id
this.orgLevel = this.orgData.level
if (this.orgLevel === 'people') {
} else if (this.orgLevel === 'search') {
this.$nextTick(() => {
debugger
// ref_tree 元素的ref value 绑定的node-key
this.$refs.ref_search.loadByName(this.searchName);
});
4 years ago
} else if (this.orgLevel === 'neighborHood') {//显示小区
4 years ago
} else {
this.refreshMap(true)
}
4 years ago
},
//加载组织数据
async loadOrgData () {
4 years ago
4 years ago
const url = "/gov/org/agency/maporg"
let params = {
orgId: this.orgId,
level: this.orgLevel
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
4 years ago
4 years ago
this.orgData = data
4 years ago
this.orgId = this.orgData.id
this.orgLevel = this.orgData.level
4 years ago
if (data.children && data.children.length > 0) {
this.subAgencyArray = data.children
4 years ago
} else {
this.subAgencyArray = []
4 years ago
}
} else {
this.$message.error(msg)
}
},
//加载当前园区的标注
4 years ago
loadPolygon (subAgencyArray) {
4 years ago
polygonSource.clear()//清空变电站标注
let featureData = []//标注数据
4 years ago
if (subAgencyArray && subAgencyArray.length > 0) {//判断是否存在下级标注
4 years ago
let oneData = {}
4 years ago
subAgencyArray.forEach(agencyItem => {
4 years ago
if (agencyItem.coordinates && agencyItem.coordinates !== '') {//如果有坐标
oneData = {
type: 'Feature',
id: agencyItem.id,
properties: {
id: agencyItem.id,
level: agencyItem.level,
name: agencyItem.name
},
geometry: {
type: 'Polygon',
coordinates: [],
},
}
let coorArray = agencyItem.coordinates.split(',')//坐标数组
let itemArray = []//单个点位的[lon,lat],数组
let polygonArray = []//整个多边形的[[lon,lat],[lon,lat],[lon,lat]]数组
coorArray.forEach((item, index) => {
itemArray.push(item)
if (index % 2 == 0) {//偶
} else {//奇
polygonArray.push(itemArray)
itemArray = []
}
});
oneData.geometry.coordinates.push(polygonArray)
featureData.push(oneData)
}
});
}
if (featureData && featureData.length > 0) {
var geojsonObject = {
'type': 'FeatureCollection',
'features': featureData
};
let feature = (new GeoJSON()).readFeatures(geojsonObject)
polygonSource.addFeatures(feature)
}
},
4 years ago
4 years ago
//设置地图定位的中心点和缩放级别
setMapLocation () {
this.centerPoint = []
if (this.orgData.longitude && this.orgData.latitude) {
this.centerPoint.push(this.orgData.longitude)
this.centerPoint.push(this.orgData.latitude)
}
this.setZoom(this.orgData.agencyLevel)
},
//根据组织层级设置缩放级别
setZoom (agencyLevel) {
if (agencyLevel === 'district') {
this.zoom = 14
} else if (agencyLevel === 'street') {
this.zoom = 15
} else if (agencyLevel === 'community') {
this.zoom = 16
}
},
initMap () {
this.setMapLocation()
gaodeMapLayer = new TileLayer({
title: "地图",
source: new XYZ({
//指定url瓦片
url: 'http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}',
wrapX: true//x方向平铺,也可以选择false
}),
zIndex: 20
});
mapView = new View({
//中心点坐标
center: this.centerPoint,
// projection: 'EPSG:3857',
projection: 'EPSG:4326',
zoom: this.zoom,
minZoom: this.minZoom
}),
//初始化map和地图底图
//创建地图容器
map = new Map({
layers: [gaodeMapLayer],
//加载瓦片图层数据
view: mapView,
target: 'map'
//目标加载到map中
})
map.on('singleclick', function (e) {
console.log(e.coordinate)
// console.log(transform(e.coordinate, 'EPSG:3857', 'EPSG:4326'));
})
//去除双击放大效果
const dblClickInteraction = map
.getInteractions()
.getArray()
.find(interaction => {
return interaction instanceof DoubleClickZoom;
});
map.removeInteraction(dblClickInteraction);
},
//添加变电站标注图层
addPolygonLayer () {
polygonSource = new VectorSource({
//features: (new GeoJSON()).readFeatures(geojsonObject)
});
polygonLayer = new VectorLayer({
source: polygonSource,
style: polygonStyleFunction,
zIndex: 50
});
//选中多边形后的样式
var overlayStyle = (function () {
return function (feature) {
var styles = {};
styles['Polygon'] = [
new Style({
stroke: new Stroke({
color: '#ec9000',
width: 2
})
}),
new Style({
fill: new Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
}),
new Style({
text: createTextStyle(feature)
})
];
styles['MultiPolygon'] = styles['Polygon'];
return styles[feature.getGeometry().getType()];
};
})();
select = new Select({
style: overlayStyle
});
map.addLayer(polygonLayer)
map.addInteraction(select);
select.on('select', e => {
this.toSubAgency('polygon', e)
4 years ago
});
},
//开启加载动画
startLoading () {
loading = Loading.service({
lock: true, //是否锁定
text: '正在加载……', //加载中需要显示的文字
background: 'rgba(0,0,0,.7)' //背景颜色
});
},
//结束加载动画
endLoading () {
//clearTimeout(timer);
if (loading) {
loading.close();
}
},
},
props: {
4 years ago
// vueFlag: {
// type: String,
// default: "alarm"
// }
4 years ago
},
computed: {
mapHeight () {
4 years ago
return this.clientHeight - 120;
4 years ago
},
4 years ago
// zoom: {
// get () {
// //根据不同屏幕分辨率,控制zoom大小
// if (this.clientHeight < 900) {
// return 2.3
// } else {
// return 2.8
// }
// },
// set (value) {
// }
// },
4 years ago
...mapGetters(["clientHeight"])
},
components: { BasicInfoCommunity, PeopleSearch, People },
4 years ago
}
export default vueGis;
</script>
4 years ago
<style
lang="scss"
src="@/assets/scss/modules/visual/basicInfoMain.scss"
scoped
></style>
4 years ago
4 years ago
<style lang=scss>
4 years ago
.ol-overlaycontainer-stopevent {
display: none;
}
4 years ago
.el-input__inner[WarningColor="warning"] {
background-color: #011168;
border-radius: 4px 0 0 4px;
height: 56px;
border: none;
box-shadow: 0 0 10px inset #1a5afd;
padding-left: 70px;
font-size: 18px;
font-family: PingFang SC;
font-weight: 400;
color: #ffffff;
opacity: 0.7;
}
4 years ago
.el-scrollbar__wrap {
overflow-x: hidden !important;
}
4 years ago
</style>