import React, { Fragment, useRef, useMemo,useEffect,useState } from 'react'; import { Table, Card, Modal, Form, Input, Button, Row,Col, Timeline, message, Tabs,Image } from 'antd'; import { useSelector } from 'react-redux'; import ToolBar from './toolbar'; import apiurl from '../../../../service/apiurl'; import usePageTable from '../../../../components/crud/usePageTable2'; import { createCrudService } from '../../../../components/crud/_'; import { exportFile } from '../../../../utils/tools.js'; import { httppost2, httppost5 } from '../../../../utils/request'; import { ylFontColor } from '../../../../utils/dictType' import "./index.less" const url = "http://223.75.53.141:9102/test.by-lyf.tmp" const Page = () => { const role = useSelector(state => state.auth.role); const [searchVal, setSearchVal] = useState(false) const columns = [ { title: '日期', key: 'date', dataIndex: 'date', width: 200, align: "center", fixed: "left" }, ...Array(12).fill(0).map((item,index) => ({ title: `${index+1}月`, key: `drpM${index+1}`, dataIndex: `drpM${index+1}`, width: 90, align: "center", render: (text, record) => {text ?? '-'} })) ]; const width = useMemo(() => columns.reduce((total, cur) => total + (cur.width), 0), [columns]); const [data, setData] = useState([]) const [staData, setStaData] = useState({}) const getData = async (params) => { try { const res = await httppost2(apiurl.rcgl.btbb.rjswnbb.page, params) if (res.code == 200) { setData(res.data) } } catch (error) { console.log(error); } } const exportExcel = () => { let params = { ...searchVal, } httppost5(apiurl.rcgl.btbb.rjswnbb.export, params).then(res => { exportFile(`日均水位年报表.xlsx`,res.data) }) } const getStaData = async (params) => { let obj = {}; try { const res = await httppost2(apiurl.rcgl.btbb.rjswnbb.sta, params) if (res.code == 200) { res.data.list?.forEach(item => { if (!obj[item.date]) { let arr = Object.keys(item) arr.splice(0,2) obj[item.date] = arr.map(o => ({[o]:item[o]})) } }) setStaData({...res.data,list:obj}) } } catch (error) { console.log(error); } } useEffect(() => { if (searchVal) { const params = { ...searchVal, }; getData(params) getStaData(params) } }, [searchVal]) return ( <>
( <>

小玉潭水库{searchVal?.year}年日平均水位年报表

单位:m
)} columns={columns} rowKey="date" dataSource={data} pagination={false} scroll={{ x: width, y: "calc( 100vh - 600px )" }} summary={(pageData) => { return(
平均
{staData?.list?.["平均"]?.map((item, index) => ( {item[`drpM${index + 1}`]} ) )}
最高
{staData?.list?.["最高"]?.map((item, index) => ( {item[`drpM${index + 1}`]} ) )}
月统计
最高日期
{staData?.list?.["最高日期"]?.map((item, index) => ( {item[`drpM${index + 1}`]} ) )}
最低
{staData?.list?.["最低"]?.map((item, index) => ( {item[`drpM${index + 1}`]} ) )}
最低日期
{staData?.list?.["最低日期"]?.map((item, index) => ( {item[`drpM${index + 1}`]} ) )}
年统计 最高水位 {staData?.max} 最低水位 {staData?.min} 平均水位 {staData?.avg}
) }} /> ); } export default Page;