Browse Source

dfds

shibei_master
dai 4 years ago
parent
commit
78e27b469f
  1. 1
      src/assets/scss/main-shuju.scss
  2. 381
      src/router/index.js
  3. 2
      src/views/main-shuju/main.vue
  4. 525
      src/views/modules/visual/warning/index.vue

1
src/assets/scss/main-shuju.scss

@ -346,6 +346,7 @@ body {
}
&:focus,
&:hover {
color: #fff;
background-color: transparent !important;
.navbar__icon-menu {

381
src/router/index.js

@ -1,115 +1,116 @@
import Vue from 'vue'
import Router from 'vue-router'
import http from '@/utils/request'
import {
isURL
} from '@/utils/validate'
import store from '@/js/store'
import Vue from "vue";
import Router from "vue-router";
import http from "@/utils/request";
import { isURL } from "@/utils/validate";
import store from "@/js/store";
Vue.use(Router)
Vue.use(Router);
// 页面路由(独立页面)
export const pageRoutes = [{
path: '/404',
component: () => import('@/views/pages/404'),
name: '404',
export const pageRoutes = [
{
path: "/404",
component: () => import("@/views/pages/404"),
name: "404",
meta: {
title: '404未找到'
title: "404未找到",
},
beforeEnter(to, from, next) {
// 拦截处理特殊业务场景
// 如果, 重定向路由包含__双下划线, 为临时添加路由
if (/__.*/.test(to.redirectedFrom)) {
return next(to.redirectedFrom.replace(/__.*/, ''))
}
next()
return next(to.redirectedFrom.replace(/__.*/, ""));
}
next();
},
},
{
path: '/login',
component: () => import('@/views/pages/login'),
name: 'login',
path: "/login",
component: () => import("@/views/pages/login"),
name: "login",
meta: {
title: '登录'
}
title: "登录",
},
},
{
path: '/',
name: 'index',
path: "/",
name: "index",
redirect: {
name: 'indexWork'
name: "indexWork",
},
meta: {
title: '首页'
}
title: "首页",
},
},
{
path: '/indexWork',
component: () => import('@/views/pages/indexWork'),
name: 'indexWork',
path: "/indexWork",
component: () => import("@/views/pages/indexWork"),
name: "indexWork",
meta: {
title: '工作端首页'
}
}
]
title: "工作端首页",
},
},
];
// 模块路由(基于主入口布局页面)
export const moduleRoutes = {
path: '/main',
component: () => import('@/views/main'),
name: 'main',
path: "/main",
component: () => import("@/views/main"),
name: "main",
redirect: {
name: 'home'
name: "home",
},
meta: {
title: '主入口布局'
title: "主入口布局",
},
children: [{
path: '/home',
component: () => import('@/views/modules/home'),
name: 'home',
children: [
{
path: "/home",
component: () => import("@/views/modules/home"),
name: "home",
meta: {
title: '主页',
isTab: true
}
}
]
}
title: "主页",
isTab: true,
},
},
],
};
// 模块路由(基于主入口布局页面) 可视化数据
export const moduleShujuRoutes = {
path: '/main-shuju',
component: () => import('@/views/main-shuju/main'),
name: 'main-shuju',
path: "/main-shuju",
component: () => import("@/views/main-shuju/main"),
name: "main-shuju",
redirect: {
name: 'home2'
name: "home2",
},
meta: {
title: '主入口布局'
title: "主入口布局",
},
children: [{
path: '/home2',
component: () => import('@/views/modules/home'),
name: 'home2',
children: [
{
path: "/home2",
component: () => import("@/views/modules/home"),
name: "home2",
meta: {
title: '主页2',
isTab: true
}
}
]
}
title: "主页2",
isTab: true,
},
},
],
};
export function addDynamicRoute(routeParams, router) {
// 组装路由名称, 并判断是否已添加, 如是: 则直接跳转
var routeName = routeParams.routeName
var dynamicRoute = window.SITE_CONFIG['dynamicRoutes'].filter(
var routeName = routeParams.routeName;
var dynamicRoute = window.SITE_CONFIG["dynamicRoutes"].filter(
(item) => item.name === routeName
)[0]
)[0];
if (dynamicRoute) {
return router.push({
name: routeName,
params: routeParams.params
})
params: routeParams.params,
});
}
// 否则: 添加并全局变量保存, 再跳转
dynamicRoute = {
@ -117,43 +118,45 @@ export function addDynamicRoute(routeParams, router) {
component: () => import(`@/views/modules/${routeParams.path}`),
name: routeName,
meta: {
...window.SITE_CONFIG['contentTabDefault'],
...window.SITE_CONFIG["contentTabDefault"],
menuId: routeParams.menuId,
title: `${routeParams.title}`
}
}
router.addRoutes([{
title: `${routeParams.title}`,
},
};
router.addRoutes([
{
...moduleRoutes,
name: `main-dynamic__${dynamicRoute.name}`,
children: [dynamicRoute]
}])
window.SITE_CONFIG['dynamicRoutes'].push(dynamicRoute)
children: [dynamicRoute],
},
]);
window.SITE_CONFIG["dynamicRoutes"].push(dynamicRoute);
router.push({
name: dynamicRoute.name,
params: routeParams.params
})
params: routeParams.params,
});
}
const router = new Router({
mode: 'hash',
mode: "hash",
scrollBehavior: () => ({
y: 0
y: 0,
}),
routes: pageRoutes.concat(moduleRoutes, moduleShujuRoutes)
})
routes: pageRoutes.concat(moduleRoutes, moduleShujuRoutes),
});
router.beforeEach((to, from, next) => {
// 添加动态(菜单)路由
// 已添加或者当前路由为页面路由, 可直接访问
if (
window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] ||
window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] ||
fnCurrentRouteIsPageRoute(to, pageRoutes)
) {
return next()
return next();
}
const customerId = localStorage.getItem('customerId')
console.log('customerId:', customerId)
const customerId = localStorage.getItem("customerId");
console.log("customerId:", customerId);
// if(customerId==='1e68188b8f7e9ab15658c164bd5b3676'){
// // if(customerId==='45687aa479955f9d06204d415238f7cc'){
// const menuList=[
@ -204,74 +207,66 @@ router.beforeEach((to, from, next) => {
// // next({ ...to, replace: true })
// next({ ...to, replace: true })
// }else{
http
.get('/gov/access/menu/nav')
.then(({
data: res
}) => {
.get("/oper/access/menu/nav")
.then(({ data: res }) => {
if (res.code !== 0) {
// Vue.prototype.$message.error(res.msg)
return next({
name: 'login'
})
name: "login",
});
}
window.SITE_CONFIG['menuList'] = res.data
fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList'])
window.SITE_CONFIG["menuShujuList"] = [
{
icon: "icon-setting",
id: "2",
name: "基础信息",
url: "visual/basicinfo/basicInfoMain",
},
{
icon: "icon-setting",
id: "3",
name: "人员预警",
url: "visual/warning/index",
},
];
fnAddDynamicMenuRoutes2(window.SITE_CONFIG["menuShujuList"]);
// next({ ...to, replace: true })
next({
...to,
replace: true
})
replace: true,
});
})
.catch(() => {
next({
name: 'login'
})
})
// }
// localStorage.getItem('customerId')
// 1e68188b8f7e9ab15658c164bd5b3676
name: "login",
});
});
http
.get('/oper/access/menu/nav')
.then(({
data: res
}) => {
.get("/gov/access/menu/nav")
.then(({ data: res }) => {
if (res.code !== 0) {
// Vue.prototype.$message.error(res.msg)
return next({
name: 'login'
})
}
window.SITE_CONFIG['menuShujuList'] = [
{
icon: "icon-setting",
id: "2",
name: "基础信息",
url: "shequ/index"
},
{
icon: "icon-setting",
id: "3",
name: "人员预警",
url: "base/resi"
name: "login",
});
}
]
fnAddDynamicMenuRoutes2(window.SITE_CONFIG['menuShujuList'])
window.SITE_CONFIG["menuList"] = res.data;
fnAddDynamicMenuRoutes(window.SITE_CONFIG["menuList"]);
// next({ ...to, replace: true })
next({
...to,
replace: true
})
replace: true,
});
})
.catch(() => {
next({
name: 'login'
})
})
})
name: "login",
});
});
});
/**
* 判断当前路由是否为页面路由
@ -279,16 +274,16 @@ router.beforeEach((to, from, next) => {
* @param {*} pageRoutes 页面路由
*/
function fnCurrentRouteIsPageRoute(route, pageRoutes = []) {
var temp = []
var temp = [];
for (var i = 0; i < pageRoutes.length; i++) {
if (route.path === pageRoutes[i].path) {
return true
return true;
}
if (pageRoutes[i].children && pageRoutes[i].children.length >= 1) {
temp = temp.concat(pageRoutes[i].children)
temp = temp.concat(pageRoutes[i].children);
}
}
return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false
return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false;
}
/**
@ -297,107 +292,109 @@ function fnCurrentRouteIsPageRoute(route, pageRoutes = []) {
* @param {*} routes 递归创建的动态(菜单)路由
*/
function fnAddDynamicMenuRoutes(menuList = [], routes = []) {
var temp = []
var temp = [];
for (var i = 0; i < menuList.length; i++) {
if (menuList[i].children && menuList[i].children.length >= 1) {
temp = temp.concat(menuList[i].children)
continue
temp = temp.concat(menuList[i].children);
continue;
}
// 组装路由
var route = {
path: '',
path: "",
component: null,
name: '',
name: "",
meta: {
...window.SITE_CONFIG['contentTabDefault'],
...window.SITE_CONFIG["contentTabDefault"],
menuId: menuList[i].id,
title: menuList[i].name
}
}
title: menuList[i].name,
},
};
// eslint-disable-next-line
let URL = (menuList[i].url || '').replace(/{{([^}}]+)?}}/g, (s1, s2) =>
let URL = (menuList[i].url || "").replace(/{{([^}}]+)?}}/g, (s1, s2) =>
eval(s2)
) // URL支持{{ window.xxx }}占位符变量
); // URL支持{{ window.xxx }}占位符变量
if (isURL(URL)) {
route['path'] = route['name'] = `i-${menuList[i].id}`
route['meta']['iframeURL'] = URL
route["path"] = route["name"] = `i-${menuList[i].id}`;
route["meta"]["iframeURL"] = URL;
} else {
URL = URL.replace(/^\//, '').replace(/_/g, '-')
route['path'] = route['name'] = URL.replace(/\//g, '-')
route['component'] = () => import(`@/views/modules/${URL}`)
URL = URL.replace(/^\//, "").replace(/_/g, "-");
route["path"] = route["name"] = URL.replace(/\//g, "-");
route["component"] = () => import(`@/views/modules/${URL}`);
}
routes.push(route)
routes.push(route);
}
if (temp.length >= 1) {
return fnAddDynamicMenuRoutes(temp, routes)
return fnAddDynamicMenuRoutes(temp, routes);
}
// 添加路由
router.addRoutes([{
router.addRoutes([
{
...moduleRoutes,
name: 'main-dynamic-menu',
children: routes
name: "main-dynamic-menu",
children: routes,
},
{
path: '*',
path: "*",
redirect: {
name: '404'
}
}
])
window.SITE_CONFIG['dynamicMenuRoutes'] = routes
window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = true
name: "404",
},
},
]);
window.SITE_CONFIG["dynamicMenuRoutes"] = routes;
window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] = true;
}
function fnAddDynamicMenuRoutes2(menuList = [], routes = []) {
var temp = []
var temp = [];
for (var i = 0; i < menuList.length; i++) {
if (menuList[i].children && menuList[i].children.length >= 1) {
temp = temp.concat(menuList[i].children)
continue
temp = temp.concat(menuList[i].children);
continue;
}
// 组装路由
var route = {
path: '',
path: "",
component: null,
name: '',
name: "",
meta: {
...window.SITE_CONFIG['contentTabDefault'],
...window.SITE_CONFIG["contentTabDefault"],
menuId: menuList[i].id,
title: menuList[i].name
}
}
title: menuList[i].name,
},
};
// eslint-disable-next-line
let URL = (menuList[i].url || '').replace(/{{([^}}]+)?}}/g, (s1, s2) =>
let URL = (menuList[i].url || "").replace(/{{([^}}]+)?}}/g, (s1, s2) =>
eval(s2)
) // URL支持{{ window.xxx }}占位符变量
); // URL支持{{ window.xxx }}占位符变量
if (isURL(URL)) {
route['path'] = route['name'] = `i-${menuList[i].id}`
route['meta']['iframeURL'] = URL
route["path"] = route["name"] = `i-${menuList[i].id}`;
route["meta"]["iframeURL"] = URL;
} else {
URL = URL.replace(/^\//, '').replace(/_/g, '-')
route['path'] = route['name'] = URL.replace(/\//g, '-')
route['component'] = () => import(`@/views/modules/${URL}`)
URL = URL.replace(/^\//, "").replace(/_/g, "-");
route["path"] = route["name"] = URL.replace(/\//g, "-");
route["component"] = () => import(`@/views/modules/${URL}`);
}
routes.push(route)
routes.push(route);
}
if (temp.length >= 1) {
return fnAddDynamicMenuRoutes2(temp, routes)
return fnAddDynamicMenuRoutes2(temp, routes);
}
// 添加路由
router.addRoutes([{
router.addRoutes([
{
...moduleShujuRoutes,
name: 'main-dynamic-menu-shuju',
children: routes
name: "main-dynamic-menu-shuju",
children: routes,
},
{
path: '*',
path: "*",
redirect: {
name: '404'
}
}
])
window.SITE_CONFIG['dynamicMenuRoutesShuju'] = routes
window.SITE_CONFIG['dynamicMenuRoutesShujuHasAdded'] = true
name: "404",
},
},
]);
window.SITE_CONFIG["dynamicMenuRoutesShuju"] = routes;
window.SITE_CONFIG["dynamicMenuRoutesShujuHasAdded"] = true;
}
export default router
export default router;

2
src/views/main-shuju/main.vue

@ -154,4 +154,4 @@ export default {
}
</script>
<style lang="scss" src="@/assets/scss/main-shuju.scss"></style>
<style lang="scss" src="@/assets/scss/main-shuju.scss" scoped></style>

525
src/views/modules/visual/warning/index.vue

@ -0,0 +1,525 @@
<template>
<div calss="div_main"
style="position: relative">
<!-- 组织路由 -->
<div>
<div class="router_line"></div>
<div class="div_router">
<span class="router_parents"
v-for="(item,index) in runAgency"
:key="index">{{item.name}}<span class="arrow">></span></span>
<span class="router_child">{{orgData.name}}</span>
</div>
</div>
<div class="div_content">
<div id="map"
class="div_map"
:style="{height:mapHeight+'px'}"></div>
<div class="div_data">
<div class="div_search">
<el-input style="width:200px"
v-model="name"
placeholder="请输入姓名"></el-input>
<el-button style="margin-left:10px"
type="primary"
icon="el-icon-plus"
@click="handleSearch">搜索</el-button>
</div>
</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';
import { defaults as defaultInteractions, Select, DoubleClickZoom } from 'ol/interaction.js';
import { Circle as CircleStyle, Fill, Stroke, Style, Text } from 'ol/style.js';
import { mapGetters } from "vuex";
import { Loading } from 'element-ui'; //Loading
import { requestPost } from "@/js/dai/request";
let loading;//
let x = 1500
let y = 700
let map;
let mapView;
let gaodeMapLayer;//
let polygonLayer;//
let polygonSource;//
let select;//
//
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: [],//
selPolygonId: '',//id
selPolygon: {},
//
name: "",
//
runNum: 0,
runAgency: [],
}
},
async mounted () {
//
await this.loadOrgData()
//
this.initMap()
//
this.addPolygonLayer()
//
this.loadPolygon(this.subAgencyArray)
},
methods: {
handleSearch () {
},
//
async refreshMap (isRefreshView) {
//
await this.loadOrgData()
//
await this.loadPolygon(this.subAgencyArray)
//
if (isRefreshView) {
this.setMapLocation()
mapView.setCenter(this.centerPoint);
mapView.setZoom(this.zoom);
}
},
//
handleBack () {
this.runNum--
this.runAgency.pop()
if (this.runNum === 0) {
this.orgId = ''
this.orgLevel = ''
} else {
this.orgId = this.runAgency[this.runAgency.length - 1].id
this.orgLevel = this.runAgency[this.runAgency.length - 1].level
}
this.refreshMap(true)
},
//
async loadOrgData () {
const url = "/gov/org/agency/maporg"
// const url = "http://yapi.elinkservice.cn/mock/245/gov/org/agency/maporg"
let params = {
orgId: this.orgId,
level: this.orgLevel
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
this.orgData = data
this.runAgency.push(data)
if (data.children && data.children.length > 0) {
this.subAgencyArray = data.children
}
} else {
this.$message.error(msg)
}
},
//
loadPolygon (subAgencyArray) {
polygonSource.clear()//
let featureData = []//
if (subAgencyArray && subAgencyArray.length > 0) {//
let oneData = {}
subAgencyArray.forEach(agencyItem => {
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)
}
},
//
toSubAgency (e) {
console.log(e)
//
this.subAgencyArray.forEach(item => {
if (item.id === e.selected[0].id_) {
this.selPolygonId = item.id
this.selPolygon = item
this.orgId = item.id
this.orgLevel = item.level
}
});
this.runNum++
this.runAgency.push(this.selPolygon)
this.refreshMap(true)
},
//
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//xfalse
}),
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(e)
});
},
//
startLoading () {
loading = Loading.service({
lock: true, //
text: '正在加载……', //
background: 'rgba(0,0,0,.7)' //
});
},
//
endLoading () {
//clearTimeout(timer);
if (loading) {
loading.close();
}
},
},
props: {
vueFlag: {
type: String,
default: "alarm"
}
},
computed: {
mapHeight () {
return this.clientHeight - 120;
},
// zoom: {
// get () {
// //zoom
// if (this.clientHeight < 900) {
// return 2.3
// } else {
// return 2.8
// }
// },
// set (value) {
// }
// },
...mapGetters(["clientHeight"])
},
components: {},
}
export default vueGis;
</script>
<style lang="scss">
.div_main {
background-color: #12a3ff;
}
.router_line {
width: 106px;
height: 1px;
border: 1px solid #000000;
/* opacity: 0.09; */
}
.div_router {
margin-top: 5px;
.router_parents {
color: #a0c3d9;
font-size: 8px;
.arrow {
padding: 0 5px;
}
}
.router_child {
color: #ffffff;
font-size: 8px;
}
}
.div_search {
text-align: center;
margin-top: 20px;
width: 100%;
display: flex;
justify-content: center;
}
.div_content {
margin-top: 10px;
padding: 10px 10px;
display: flex;
}
.div_map {
width: 100%;
}
.div_data {
flex: 0 0 400px;
margin-left: 20px;
background-color: rgb(233, 235, 235);
border-radius: 5px;
}
</style>
<style>
.ol-overlaycontainer-stopevent {
display: none;
}
</style>
Loading…
Cancel
Save