import React, { useState } from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Paper, Checkbox, TextField } from '@material-ui/core'; import { Empty } from 'antd' const useStyles = makeStyles((theme) => ({ root: { backgroundColor: 'transparent', color: '#c9d1d9', padding: theme.spacing(2), }, title: { color: '#58a6ff', marginBottom: theme.spacing(2), fontSize: '1rem', display: 'flex', alignItems: 'center', '&::before': { content: '""', width: 4, height: 16, backgroundColor: '#58a6ff', marginRight: theme.spacing(1), }, }, table: { backgroundColor: 'transparent', '& .MuiTableCell-root': { borderColor: '#30363d', color: '#c9d1d9', padding: theme.spacing(1), }, }, addButton: { backgroundColor: '#1f6feb', color: '#ffffff', border: 'none', padding: '4px 12px', borderRadius: 6, cursor: 'pointer', '&:hover': { backgroundColor: '#388bfd', }, }, checkboxLabel: { display: 'flex', alignItems: 'center', gap: theme.spacing(1), }, weightInput: { width: 80, '& .MuiInputBase-root': { color: '#c9d1d9', backgroundColor: '#21262d', }, }, })); const SchemeOptimization = ({loadFa}) => { const classes = useStyles(); const [reservoirs, setReservoirs] = useState([ { name: '浮标河水库', safeLevel: 64.80, storage: 16110, maxOutflow: 20.00 }, { name: '明山水库', safeLevel: 93.00, storage: 5116, maxOutflow: 20.00 }, ]); const [schemes, setSchemes] = useState([ { id: 1, floodArea: 0.15, duration: 1320.0, households: 20, population: 100 }, { id: 2, floodArea: 0.12, duration: 1235.0, households: 20, population: 100 }, { id: 3, floodArea: 0.14, duration: 1350.0, households: 20, population: 100 }, ]); const checkData = [ { id:1, name: '最小化下游最大流量', checked: true, }, { id:2, name: '最小化水库最高水位', checked:true }, { id:3, name: '最大化防洪库容利用率', checked:false }, { id:4, name: '最小化淹没损失', checked:false }, { id:5, name: '最小化调度操作次数', checked:false } ] const [data, setData] = useState(checkData) const changeSw = (e, id) => { const checked = e.target.checked const data1 = data.map(item => { if (item.id == id) { item.checked = checked; } return item }) setData(data1) } const [inputData, setInputData] = useState('') const inputChange = (e, i) =>{ const val = e.target.value setInputData(val) } const [renderT, setRenderT] = useState(false) const fasc = () => { if (inputData) { setRenderT(true) } } return (
约束条件配置
水库名称 安全水位(m) 防洪库容(万m³) 最大泄量(m³/s) 操作 {reservoirs.map((reservoir) => ( {reservoir.name} {reservoir.safeLevel} {reservoir.storage} {reservoir.maxOutflow} × ))}
优化目标设置及权重分配
{ data.map(item => (
changeSw(e,item.id)}/> {item.name} { item.checked && inputChange(e,item.id)} /> }
)) }
方案预览区
方案 淹没面积(km²) 淹没历时(min) 影响户数 影响人口 操作 {renderT ?schemes.map((scheme) => ( 方案{scheme.id} {scheme.floodArea} {scheme.duration} {scheme.households} {scheme.population} )) : null // 暂无数据} /> }
); }; export default SchemeOptimization;