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 { Switch, FormControlLabel,InputLabel, Select, MenuItem,FormControl } from '@material-ui/core/index' import { styled } from '@material-ui/styles'; function HDReal({ style }) { const dispatch = useDispatch(); const tableRzFilter = useSelector(s => s.realview.tableRzFilter); const hdAutoRefresh = useSelector(s => s.realview.hdAutoRefresh); const [checked, setChecked] = React.useState(false); // 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 obj = { 0: '东干渠', 1: '西干渠', 2: '邓家河干渠' } const showData = Array(10).fill(0).map((o, i) => ({ id: `#${i + 1}`, type: obj[i % 2], status: '--', kd: (Math.random() * 100).toFixed(2), ll: (Math.random() * 100).toFixed(1) })) 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); } const CustomSwitch = styled(Switch)({ '& .MuiSwitch-switchBase': { color: '#fff', '&.Mui-checked': { color: '#1890ff', '& + .MuiSwitch-track': { backgroundColor: '#1890ff', opacity: 0.5, }, }, }, '& .MuiSwitch-track': { backgroundColor: 'rgba(255, 255, 255, 0.3)', }, }); const StyledFormControlLabel = styled(FormControlLabel)({ '& .MuiFormControlLabel-label': { color: '#fff' } }); const [dimension, setDimension] =useState('fqh'); return ( // toggleStType('sh')}>山洪 // toggleStType('sw')}>水文 // // } extra={ <> {/* showSetting(true)}> */} } > 渠道 目标流量(m³/s) 实际流量(m³/s) 执行状态 {/* 警戒水位 */} {showData.map((row) => (
{row.type}
{row.kd} {row.ll} {row.status} {/* {rzRender(row.rz, row.grz)} {rzRender(row.rz, row.wrz)} */}
))}
{ setting && showSetting(false)} /> }
setChecked(e.target.checked)} /> } label="多灌区模式" /> {checked &&
}
) } export default HDReal;