mcfxkh-Web/src/views/Home/panels/Gwsllc/index.js

203 lines
5.2 KiB
JavaScript
Raw Normal View History

2025-05-27 16:35:13 +08:00
import React, { useMemo, useState } from 'react';
import useRequest from '../../../../utils/useRequest';
import PanelBox from '../../components/PanelBox';
import Table from '@material-ui/core/Table';
import TableContainer from '@material-ui/core/TableContainer';
import TableBody from '@material-ui/core/TableBody';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import DpTableCell from '../../../../layouts/mui/DpTableCell';
import DpTableRow from '../../../../layouts/mui/DpTableRow';
import { useDispatch, useSelector } from 'react-redux';
import useRefresh from '../../../../utils/useRefresh';
import { HDRealPromise } from '../../../../models/_/real';
import clsx from 'clsx';
import { renderHDRz } from '../../../../utils/renutils';
import Setting from './Setting';
import { InfoPopNames } from '../../InfoPops';
import config from '../../../../config';
import moment from 'moment';
import showData from './constant'
import ReactECharts from 'echarts-for-react';
function rzRender(rz, base) {
return (
<DpTableCell align="right" style={{ color: rz >= base ? 'red' : '#fff' }}>
{typeof base === 'number' ? base.toFixed(2) : ''}
</DpTableCell>
);
}
function HDReal({ style }) {
const dispatch = useDispatch();
const tableRzFilter = useSelector(s => s.realview.tableRzFilter);
const hdAutoRefresh = useSelector(s => s.realview.hdAutoRefresh);
const t = useRefresh(hdAutoRefresh ? 60 * 1000 : 0);
// let { data } = useRequest(HDRealPromise.get, t);
const [setting, showSetting] = useState(false);
// const showData = useMemo(() => {
// if (!data) {
// return [];
// }
// let ret = [];
// data.forEach(o => {
// if (!tableRzFilter[o.type]) {
// return;
// }
// o.status = Math.floor(Math.random() * (4 - 0 + 1)) + 0
// o.kd = (Math.random() * 100).toFixed(2);
// o.ll = (Math.random() * 100).toFixed(1);
// ret.push(o);
// });
// return ret;
// }, [data, tableRzFilter]);
const randomMinutes = Math.floor(Math.random() * 60) + 1;
const format = 'YYYY-MM-DD HH:mm';
const showData = [
{
stnm: '监测点1',
press: '0.52',
flow: 200,
hg:90
},
{
stnm: '监测点2',
press: '0.52',
flow: 200,
hg:90
},{
stnm: '监测点3',
press: '0.52',
flow: 200,
hg:90
}
]
const flyTo = (record) => {
dispatch.map.setLayerVisible({'TrsqLayer':true})
const { lgtd, lttd } = record;
if (lgtd && lttd) {
dispatch.runtime.setFeaturePop({ type: '墒情站', properties: record, coordinates: [lgtd, lttd] });
dispatch.runtime.setCameraTarget({
center: [lgtd, lttd + config.poiPositionOffsetY.hd],
zoom: config.poiPositionZoom.hd,
pitch: config.poiPitch,
});
}
}
const toggleStType = (type) => {
const visible = !tableRzFilter[type];
dispatch.realview.setTableRzFilter({ [type]: visible });
}
const toggleAutoRefresh = () => {
dispatch.realview.setHdAutoRefresh(!hdAutoRefresh);
}
const option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
2025-05-27 17:30:31 +08:00
data: ['数量分布', '里程分布'],
2025-05-27 16:35:13 +08:00
textStyle: {
color: '#fff'
},
top: 10
},
grid: {
top:'13%',
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'category',
data: ['福田镇', '龙池桥镇', '木子店镇', '宋埠镇', '黄土岗镇', '铁门岗镇', '乘马岗镇', '白果镇', '张家畈镇', '顺河镇'],
axisLine: {
lineStyle: {
color: '#fff'
}
},
axisLabel: {
color: '#fff',
interval: 0,
rotate: 45
}
},
yAxis: {
type: 'value',
name: '数量',
nameTextStyle: {
color: '#fff'
},
axisLine: {
lineStyle: {
color: '#fff'
}
},
axisLabel: {
color: '#fff'
},
splitLine: {
lineStyle: {
type: 'dashed',
color: 'rgba(255,255,255,0.2)'
}
}
},
series: [
{
2025-05-27 17:30:31 +08:00
name: '数量分布',
2025-05-27 16:35:13 +08:00
type: 'bar',
data: [2050, 2250, 1300, 2100, 1950, 1100, 2150, 2400, 1950, 2100],
itemStyle: {
color: '#36a4eb'
},
barWidth: '20%'
},
{
name: '里程分布',
type: 'bar',
data: [1100, 1300, 1200, 1300, 1000, 1100, 1200, 1100, 1000, 1600],
itemStyle: {
color: '#4b5cc4'
},
barWidth: '20%'
}
]
};
return (
<PanelBox
style={style}
title="数量及里程分布"
color="green"
extra={
<>
{/* <i style={{ marginRight: '0.5rem', color: hdAutoRefresh ? '#00deff' : '#aaa' }} className="ionicons loop cursor-pointer" onClick={toggleAutoRefresh}></i> */}
{/* <i className="ionicons gear cursor-pointer" onClick={() => showSetting(true)}></i> */}
</>
}
>
<ReactECharts
option={option}
style={{ height: '400px', width: '100%' }}
/>
{
setting && <Setting onClose={() => showSetting(false)} />
}
</PanelBox>
)
}
export default HDReal;