mcfxkh-Web/src/views/Home/components/ActionDock/index.js

164 lines
6.6 KiB
JavaScript
Raw Normal View History

2025-05-20 09:43:10 +08:00
import React, { useMemo, useState } from 'react';
2025-05-19 14:26:18 +08:00
import clsx from 'clsx';
import './ActionDock.less';
import { useDispatch, useSelector } from 'react-redux';
import { makeStyles, Tooltip, Typography } from '@material-ui/core';
const VIEWS = [
2025-05-27 16:40:23 +08:00
2025-05-27 16:35:13 +08:00
{
id: 100, title: '防汛', img: '/assets/menu/防洪形势.png', children: [
2025-06-05 09:48:43 +08:00
// { id: 0, title: '防洪形势', img: '/assets/menu/防洪形势.png' },
2025-06-12 15:18:12 +08:00
{ id: 8, title: '防洪形势', img: '/assets/menu/防洪形势.png' },
// { id: 9, title: '防洪形势', img: '/assets/menu/防洪形势.png' },
2025-06-12 17:59:36 +08:00
{ id: 1, title: '监测数据', img: '/assets/menu/实时数据.png' },
// { id: 2, title: '水利设施', img: '/assets/menu/水利设施.png' },
2025-06-05 09:48:43 +08:00
{ id: 5, title: '预报', img: '/assets/menu/降雨中心.png' },
2025-06-13 09:58:28 +08:00
{ id: 6, title: '预警', img: '/assets/menu/病险水库.png' },
2025-06-04 20:41:04 +08:00
{ id: 4, title: '预演', img: '/assets/menu/预警分析.png' },
2025-06-13 09:58:28 +08:00
{ id: 3, title: '预案', img: '/assets/menu/辅助决策.png' },
{ id: 7, title: '调度', img: '/assets/menu/辅助决策.png' },
2025-05-27 16:35:13 +08:00
]
},
2025-06-11 11:08:10 +08:00
// { id: 200, title: '水库', img: '/assets/menu/水库专题.png',children:[
// { id: 207, title: '水库总览', img: '/assets/menu/水库管理.png' },
// // { id: 201, title: '雨情监测', img: '/assets/menu/雨情监测.png' },
// // { id: 202, title: '水情监测', img: '/assets/menu/水情监测.png' },
// { id: 203, title: '水库监测', img: '/assets/menu/安全监测.png' },
// // { id: 204, title: '视频监视', img: '/assets/menu/视频监视.png' },
// { id: 205, title: '防汛调度', img: '/assets/menu/防汛调度.png' },
// { id: 206, title: '巡查维养', img: '/assets/menu/水库管理.png' },
// ] },
{ id: 200, title: '水库', img: '/assets/menu/水库专题.png'},
2025-05-27 16:35:13 +08:00
{
id: 300, title: '水厂', img: '/assets/menu/水利设施.png', children: [
{ id: 301, title: '供水态势', img: '/assets/menu/降雨中心.png' },
2025-05-27 16:40:23 +08:00
{ id: 302, title: '水质安全', img: '/assets/menu/水情监测.png' },
{ id: 303, title: '水厂运行', img: '/assets/menu/水库管理.png' },
2025-05-27 16:35:13 +08:00
{ id: 306, title: '管网健康诊断', img: '/assets/menu/水利设施.png' },
{ id: 307, title: '应急指挥调度', img: '/assets/menu/病险水库.png' },
2025-06-09 15:44:06 +08:00
// { id: 305, title: '决策支持与报表', img: '/assets/menu/辅助决策.png' },
2025-05-27 16:35:13 +08:00
]
},
2025-05-21 09:14:48 +08:00
{
2025-05-22 16:13:42 +08:00
id: 400, title: '灌区', img: '/assets/menu/预警分析.png', children: [
2025-05-21 09:14:48 +08:00
{ id: 501, title: '灌区监测', img: '/assets/menu/防洪形势.png' },
{ id: 504, title: '水旱灾害防御', img: '/assets/menu/水利设施.png' },
2025-05-27 16:35:13 +08:00
// { id: 502, title: '预警信息管理', img: '/assets/menu/实时数据.png' },
{ id: 503, title: '水资源调度', img: '/assets/menu/病险水库.png' },
{ id: 505, title: '量测水管理', img: '/assets/menu/辅助决策.png' },
{ id: 506, title: '水政管理', img: '/assets/menu/预警分析.png' },
{ id: 507, title: '工程管理', img: '/assets/menu/降雨中心.png' },
// 图层控制
// 灌区监测
// 预警信息管理
// 水旱灾害防御
// 水资源调度
// 量测水管理
// 水政管理
// 工程管理
]
},
2025-05-19 14:26:18 +08:00
];
2025-05-20 09:43:10 +08:00
2025-05-19 14:26:18 +08:00
const useStylesBootstrap = makeStyles((theme) => ({
arrow: {
color: '#0004',
},
tooltip: {
backgroundColor: '#0008',
padding: '1rem',
top: '0.7rem'
},
}));
function BootstrapTooltip(props) {
const classes = useStylesBootstrap();
return <Tooltip arrow classes={classes} {...props} />;
}
export default function ActionDock({ }) {
const view = useSelector(s => s.map.view);
2025-05-27 16:35:13 +08:00
const [viewKey, setViewKey] = useState(null)
const viewItem = useMemo(() => viewKey ? VIEWS.filter(o => o.id === viewKey)[0].children : VIEWS, [viewKey, VIEWS])
2025-05-19 14:26:18 +08:00
const dispatch = useDispatch();
2025-06-13 09:28:51 +08:00
const removePoint = () => {
const map = window.__mapref;
const layer = map.getLayer('关联站点')
if (layer) {
map.removeLayer('关联站点');
map.removeSource('关联站点');
}
}
2025-05-20 09:43:10 +08:00
2025-05-19 14:26:18 +08:00
return (
<div className="dp-actiondock">
{
2025-05-27 16:35:13 +08:00
viewKey ?
<BootstrapTooltip key={999} title={<Typography variant="h6"><span style={{ color: '#fff' }}>返回</span></Typography>}>
<div className="dock-item" onClick={() => {
2025-06-12 15:18:12 +08:00
dispatch.map.setView(0) //这里不知道用哪个,等问好在弄
2025-05-27 16:35:13 +08:00
setViewKey(null)
dispatch.runtime.setScya(false)
dispatch.runtime.setGwtc(false)
2025-06-13 09:28:51 +08:00
removePoint()
2025-05-27 16:35:13 +08:00
}}>
<div className={clsx('button', { active: false })}>
<img width={40} style={{ marginLeft: '5px' }} src={'/assets/pump/退出.png'} />
</div>
2025-05-20 09:43:10 +08:00
</div>
2025-05-27 16:35:13 +08:00
</BootstrapTooltip>
: null
2025-05-20 09:43:10 +08:00
}
{
viewItem.map(o => (
2025-05-27 16:35:13 +08:00
<BootstrapTooltip key={o.id} title={<Typography variant="h6"><span style={{ color: '#fff' }}>{o.title}</span></Typography>}>
2025-05-20 09:43:10 +08:00
<div className="dock-item" onClick={() => {
2025-05-27 16:35:13 +08:00
if (o.children) {
2025-05-20 09:43:10 +08:00
//一级菜单
dispatch.map.setView(o.children[0].id)
setViewKey(o.id)
2025-05-27 16:35:13 +08:00
dispatch.runtime.setScya(false)
dispatch.runtime.setGwtc(false)
} else {
// 判断水厂资源调度切换图层
if (o.id == 307) {
dispatch.runtime.setScya(true)
} else {
dispatch.runtime.setScya(false)
}
// if (o.id == 307) {
// dispatch.runtime.setGwtc(true)
// } else {
// dispatch.runtime.setGwtc(true)
// }
2025-05-20 09:43:10 +08:00
//二级菜单
dispatch.map.setView(o.id)
2025-06-04 20:41:04 +08:00
if (o.id == 6) {
sessionStorage.setItem('point',o.id)
} else {
sessionStorage.setItem('point','')
}
2025-06-13 09:28:51 +08:00
removePoint()
2025-05-20 09:43:10 +08:00
}
}}>
2025-06-11 11:08:10 +08:00
<div className={clsx('button', { active: o.id===200?(view===207||view===203||view===205||view===206||view===200):view === o.id })}>
2025-05-27 10:27:32 +08:00
<img width={32} height={32} src={o.img} />
2025-05-19 14:26:18 +08:00
</div>
</div>
</BootstrapTooltip>
))
}
<div className="logo">
<a href="http://www.hbwhdc.cn" target="blank" style={{ color: '#fff', cursor: 'pointer' }}>@湖北纬皓端成科技有限公司</a>
<span style={{ marginRight: '1rem' }}></span>: 15697168180
</div>
</div>
)
}