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

208 lines
6.9 KiB
JavaScript
Raw Normal View History

2025-05-22 16:04:47 +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';
2025-05-26 21:26:20 +08:00
import { Switch, FormControlLabel,InputLabel, Select, MenuItem,FormControl } from '@material-ui/core/index'
import { styled } from '@material-ui/styles';
2025-05-22 16:04:47 +08:00
function HDReal({ style }) {
const dispatch = useDispatch();
const tableRzFilter = useSelector(s => s.realview.tableRzFilter);
const hdAutoRefresh = useSelector(s => s.realview.hdAutoRefresh);
2025-05-26 21:26:20 +08:00
const [checked, setChecked] = React.useState(false);
2025-05-22 16:04:47 +08:00
// 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-26 16:37:17 +08:00
const obj = {
0: '东干渠',
1: '西干渠',
2025-05-26 21:26:20 +08:00
2: '邓家河干渠'
2025-05-26 16:37:17 +08:00
}
2025-05-22 16:04:47 +08:00
2025-05-26 21:26:20 +08:00
const showData = Array(10).fill(0).map((o, i) => ({
2025-05-22 16:04:47 +08:00
id: `#${i + 1}`,
2025-05-26 21:26:20 +08:00
type: obj[i % 2],
2025-05-22 16:04:47 +08:00
status: '--',
kd: (Math.random() * 100).toFixed(2),
2025-05-26 21:26:20 +08:00
ll: (Math.random() * 100).toFixed(1)
2025-05-22 16:04:47 +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,
});
}
}
const toggleStType = (type) => {
const visible = !tableRzFilter[type];
dispatch.realview.setTableRzFilter({ [type]: visible });
}
const toggleAutoRefresh = () => {
dispatch.realview.setHdAutoRefresh(!hdAutoRefresh);
}
2025-05-26 21:26:20 +08:00
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'
2025-05-22 16:04:47 +08:00
}
2025-05-26 21:26:20 +08:00
});
const [dimension, setDimension] =useState('fqh');
2025-05-22 16:04:47 +08:00
return (
<PanelBox
style={style}
2025-05-26 16:37:17 +08:00
title="调度监控"
2025-05-22 16:04:47 +08:00
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-26 21:26:20 +08:00
<TableContainer style={{ height: '100%', position: 'relative' }}>
2025-05-22 16:04:47 +08:00
<Table size="small" stickyHeader>
<TableHead>
<TableRow>
<DpTableCell style={{ width: '15%' }} align="left">渠道</DpTableCell>
<DpTableCell align="center" style={{ width: '30%' }}>目标流量(/s)</DpTableCell>
<DpTableCell style={{ width: '30%' }} align="center">实际流量(/s)</DpTableCell>
<DpTableCell align="center" style={{ width: '20%' }}>执行状态</DpTableCell>
{/* <DpTableCell align="right">警戒水位</DpTableCell> */}
</TableRow>
</TableHead>
<TableBody>
{showData.map((row) => (
<DpTableRow key={row.id}>
2025-05-26 21:26:20 +08:00
<DpTableCell component="th" scope="row">
2025-05-22 16:04:47 +08:00
<div
className="table-ellipsis cursor-pointer"
>{row.type}</div>
</DpTableCell>
<DpTableCell align="center">
2025-05-26 21:26:20 +08:00
{row.kd}
2025-05-22 16:04:47 +08:00
</DpTableCell>
<DpTableCell align="center">{row.ll}</DpTableCell>
<DpTableCell align="center">{row.status}</DpTableCell>
{/* {rzRender(row.rz, row.grz)}
{rzRender(row.rz, row.wrz)} */}
</DpTableRow>
))}
</TableBody>
</Table>
2025-05-26 21:26:20 +08:00
2025-05-22 16:04:47 +08:00
</TableContainer>
{
setting && <Setting onClose={() => showSetting(false)} />
}
2025-05-26 21:26:20 +08:00
<div style={{ position: 'absolute',color:'#fff',top:70,left:-280,display:'flex',alignItems:'center' }}>
<StyledFormControlLabel
control={
<CustomSwitch
checked={checked}
onChange={(e) => setChecked(e.target.checked)}
/>
}
label="多灌区模式"
/>
{checked &&<div style={{marginTop:"-15px"}}>
<FormControl sx={{ minWidth: 200, marginBottom: 2 }}>
<InputLabel id="analysis-select-label"></InputLabel>
<Select
labelId="analysis-select-label"
value={dimension}
label=""
onChange={(event) => {
const value = event.target.value;
setDimension(value);
}}
sx={{
color: '#fff',
'.MuiOutlinedInput-notchedOutline': {
borderColor: 'rgba(255, 255, 255, 0.3)',
},
'&:hover .MuiOutlinedInput-notchedOutline': {
borderColor: 'rgba(255, 255, 255, 0.6)',
},
'&.Mui-focused .MuiOutlinedInput-notchedOutline': {
borderColor: '#fff',
}
}}
>
<MenuItem value="fqh">浮桥河灌区</MenuItem>
<MenuItem value="shk">三河口水库灌区</MenuItem>
<MenuItem value="qjs">群建水库灌区</MenuItem>
<MenuItem value="dsb">大石板灌区</MenuItem>
</Select>
</FormControl>
</div>}
</div>
2025-05-22 16:04:47 +08:00
</PanelBox>
)
}
export default HDReal;