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

197 lines
7.2 KiB
JavaScript
Raw Normal View History

2025-05-29 11:46:29 +08:00
import React, { useMemo, useState, useEffect } from 'react';
2025-05-27 16:35:13 +08:00
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 { DatePicker } from 'antd';
import moment from 'moment';
import './index.less'
const { RangePicker } = DatePicker;
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]);
2025-05-29 11:46:29 +08:00
const showData = Array(1).fill(0).map((o, i) => ({
2025-05-27 16:35:13 +08:00
date: '2025-05-26',
event: '侵占河道',
type: '侵占河道',
status: '待处理',
2025-05-29 11:46:29 +08:00
place: '浮桥河灌区'
2025-05-27 16:35:13 +08:00
}))
const flyTo = (record) => {
const { lgtd, lttd } = record;
if (lgtd && lttd) {
dispatch.runtime.setFeaturePop({ type: InfoPopNames.RealHDPop, properties: record, coordinates: [lgtd, lttd] });
dispatch.runtime.setCameraTarget({
center: [lgtd, lttd + config.poiPositionOffsetY.hd],
zoom: config.poiPositionZoom.hd,
pitch: config.poiPitch,
});
}
}
2025-05-29 11:46:29 +08:00
const data = [
2025-05-27 16:35:13 +08:00
{ name: '福田镇中心区', leakage: '1258.6', supply: '3526.8', rate: 35.6 },
{ name: '木子店镇区', leakage: '986.3', supply: '2832.7', rate: 34.8 },
{ name: '龙池桥镇区', leakage: '1485.5', supply: '4482.5', rate: 33.1 },
{ name: '宋埠镇区', leakage: '1284.8', supply: '4029.5', rate: 31.9 },
{ name: '黄土岗镇区', leakage: '186.2', supply: '698.2', rate: 26.7 },
{ name: '铁门岗镇区', leakage: '984.2', supply: '3994.4', rate: 24.6 },
{ name: '乘马岗镇区', leakage: '300.6', supply: '1250.5', rate: 24.0 },
{ name: '白果镇区', leakage: '1129.0', supply: '6422.6', rate: 17.6 },
{ name: '张家畈镇区', leakage: '444.8', supply: '2661.8', rate: 16.7 },
{ name: '顺河镇区', leakage: '749.3', supply: '4490.1', rate: 16.7 }
];
const toggleStType = (type) => {
const visible = !tableRzFilter[type];
dispatch.realview.setTableRzFilter({ [type]: visible });
}
const [params, setParams] = useState({ tm: [] })
const toggleAutoRefresh = () => {
dispatch.realview.setHdAutoRefresh(!hdAutoRefresh);
}
2025-05-29 11:46:29 +08:00
const searchTm = (e) => {
setParams({
...params,
stm: e[0].format("YYYY-MM-DD HH:mm"),
etm: e[1].format("YYYY-MM-DD HH:mm"),
tm: e,
})
};
useEffect(() => {
let options = "";
options = {
etm: moment().add(1, 'hour').set({ minute: 0, second: 0 }).format("YYYY-MM-DD HH:mm"),
stm: moment().subtract(7, 'days').add(1, 'hour').set({ minute: 0, second: 0 }).format("YYYY-MM-DD HH:mm"),
tm: [
moment().subtract(7, 'days').add(1, 'hour').set({ minute: 0, second: 0 }),
moment().add(1, 'hour').set({ minute: 0, second: 0 }),
],
}
setParams(options)
}, [])
2025-05-27 16:35:13 +08:00
return (
<PanelBox
style={style}
title="漏损排行榜"
color="green"
// tabs={
// <span className="button-group">
// <span className={clsx({ active: tableRzFilter.sh })} onClick={() => toggleStType('sh')}>山洪</span>
// <span className={clsx({ active: tableRzFilter.sw })} onClick={() => toggleStType('sw')}>水文</span>
// </span>
// }
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> */}
</>
}
>
2025-05-29 11:46:29 +08:00
<div className='tm' style={{ position: "relative", zIndex: 999999, color: "#fff", width: "60%", margin: '10px' }}>
<RangePicker
// width="100%"
className='time-picker'
style={{
flex: 1,
background: "transparent",
border: "none",
color: "#fff",
}}
onChange={searchTm}
allowClear
format="YYYY-MM-DD HH:mm"
showTime={{
format: 'HH:mm',
}}
value={params.tm}
getPopupContainer={trigger => trigger.parentElement}
/>
</div>
<TableContainer style={{ height: '80%', marginTop: '10px' }}>
2025-05-27 16:35:13 +08:00
<Table size="small" stickyHeader>
<TableHead>
<TableRow >
<DpTableCell style={{ width: '30%' }} align="center">DMA分区名称</DpTableCell>
<DpTableCell style={{ width: '25%' }} align="center">漏水量()</DpTableCell>
<DpTableCell align="center" style={{ width: '25%' }}>供水量</DpTableCell>
<DpTableCell align="center" style={{ width: '20%' }}>漏损率(%)</DpTableCell>
</TableRow>
</TableHead>
<TableBody>
{data.map((row) => (
<DpTableRow key={row.id} onClick={() => flyTo(row)}>
<DpTableCell align="center">
<div
className="table-ellipsis cursor-pointer"
>{row.name}</div>
</DpTableCell>
<DpTableCell align="center">{row.leakage}</DpTableCell>
<DpTableCell align="center">{row.supply}</DpTableCell>
<DpTableCell align="center">{row.rate}</DpTableCell>
{/* {rzRender(row.rz, row.grz)}
{rzRender(row.rz, row.wrz)} */}
</DpTableRow>
))}
</TableBody>
</Table>
</TableContainer>
{
setting && <Setting onClose={() => showSetting(false)} />
}
2025-05-29 11:46:29 +08:00
<img src={`${process.env.PUBLIC_URL}/assets/tl.png`} alt="" style={{position:'absolute',width:130,height:220,left:-200,top:670}}/>
2025-05-27 16:35:13 +08:00
</PanelBox>
)
}
export default HDReal;