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'; function rzRender(rz, base) { return ( = base ? 'red' : '#fff' }}> {typeof base === 'number' ? base.toFixed(2) : ''} ); } 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 showData =[ { id: 'DEV001', name: '1#闸门水位计', location: '东干渠首', errorType: '数据异常', time: '2024-01-20 14:30:25', status: '未处理' }, { id: 'DEV002', name: '2#流量计', location: '西分干渠', errorType: '通讯中断', time: '2024-01-20 13:15:40', status: '处理中' }, { id: 'DEV003', name: '3#水质监测仪', location: '南支渠', errorType: '电量不足', time: '2024-01-20 12:45:10', status: '未处理' }, { id: 'DEV004', name: '4#压力传感器', location: '北干渠', errorType: '设备离线', time: '2024-01-20 11:20:35', status: '已处理' }, { id: 'DEV005', name: '5#自动控制阀', location: '中心泵站', errorType: '控制故障', time: '2024-01-20 10:55:15', status: '处理中' } ]; 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, }); } } const toggleStType = (type) => { const visible = !tableRzFilter[type]; dispatch.realview.setTableRzFilter({ [type]: visible }); } const toggleAutoRefresh = () => { dispatch.realview.setHdAutoRefresh(!hdAutoRefresh); } return ( // toggleStType('sh')}>山洪 // toggleStType('sw')}>水文 // // } extra={ <> {/* */} {/* showSetting(true)}> */} } > 设备名称 位置 异常类型 报警时间 {/* 警戒水位 */} {showData.map((row) => (
{row.name}
{row.location} {row.errorType}
{row.time}
{/* {rzRender(row.rz, row.grz)} {rzRender(row.rz, row.wrz)} */}
))}
{ setting && showSetting(false)} /> }
) } export default HDReal;