2024-09-20 15:02:50 +08:00
|
|
|
import React, { Fragment, useRef, useMemo,useEffect,useState } from 'react';
|
|
|
|
|
import { Table, Card,Modal,Form,Input,Button,Row,Col,message } from 'antd';
|
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
import ToolBar from './toolbar';
|
|
|
|
|
import apiurl from '../../../../service/apiurl';
|
|
|
|
|
import { exportFile } from '../../../../utils/tools.js';
|
|
|
|
|
import { httppost2,httppost5 } from '../../../../utils/request';
|
|
|
|
|
import "./index.less"
|
2025-03-28 17:31:43 +08:00
|
|
|
import MyTable from './table'
|
2024-09-20 15:02:50 +08:00
|
|
|
const Page = () => {
|
|
|
|
|
const role = useSelector(state => state.auth.role);
|
|
|
|
|
|
|
|
|
|
const [searchVal, setSearchVal] = useState(false)
|
|
|
|
|
const [dataSource, setDataSource] = useState([])
|
|
|
|
|
const [trData, setTrData] = useState([])
|
|
|
|
|
const [table2Data, setTable2Data] = useState([])
|
|
|
|
|
const [loading, setLoading] = useState(false)
|
2025-04-10 14:27:15 +08:00
|
|
|
const [wyObj, setWyObj] = useState(false)
|
2025-09-01 17:55:23 +08:00
|
|
|
const wyList = ["e","n","u"]
|
2024-09-20 15:02:50 +08:00
|
|
|
const columns1 = [
|
2025-03-28 17:31:43 +08:00
|
|
|
{ title: '序号', key: 'inx', dataIndex: 'inx', width: 150, align:"center"},
|
2024-09-20 15:02:50 +08:00
|
|
|
];
|
|
|
|
|
const columns2 = [
|
2025-03-28 17:31:43 +08:00
|
|
|
{ title: '监测日期', key: 'tm', dataIndex: 'tm', width: 250, align:"center" },
|
2024-09-20 15:02:50 +08:00
|
|
|
];
|
2025-04-10 14:27:15 +08:00
|
|
|
|
|
|
|
|
const demoColumns = [
|
|
|
|
|
columns1[0],
|
|
|
|
|
columns2[0],
|
|
|
|
|
{
|
|
|
|
|
title: 'WY-01',
|
|
|
|
|
width: 100,
|
|
|
|
|
align: "center",
|
|
|
|
|
children: {
|
|
|
|
|
title: "X",
|
|
|
|
|
key: `X_WY-01`,
|
|
|
|
|
dataIndex: `X_WY-01`,
|
|
|
|
|
width: 100,
|
|
|
|
|
align: "center",
|
|
|
|
|
render: (rec, record) => <span>{rec ?? "-"}</span>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
2024-09-20 15:02:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
const getDmTree = async() => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await httppost2(apiurl.gcaqjc.sjtjcx.ndwytjb.list)
|
|
|
|
|
setTrData(res.data)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const newCols = useMemo(() => {
|
2025-04-10 14:27:15 +08:00
|
|
|
if (trData.length > 0 && wyObj) {
|
2024-09-20 15:02:50 +08:00
|
|
|
let dm = trData?.map(item => (
|
|
|
|
|
{
|
2025-09-01 17:55:23 +08:00
|
|
|
title: item.cd,
|
2024-09-20 15:02:50 +08:00
|
|
|
width: 100,
|
|
|
|
|
align: "center",
|
|
|
|
|
children: wyList?.map(s => ({
|
|
|
|
|
title: s,
|
2025-09-01 17:55:23 +08:00
|
|
|
key: `${s}_${item.cd}`,
|
|
|
|
|
dataIndex: `${s}_${item.cd}`,
|
2024-09-20 15:02:50 +08:00
|
|
|
width: 100,
|
|
|
|
|
align: "center",
|
|
|
|
|
render: (rec, record) => <span>{rec?? "-"}</span>
|
|
|
|
|
}))
|
|
|
|
|
}
|
|
|
|
|
))
|
2025-04-10 14:27:15 +08:00
|
|
|
|
|
|
|
|
const newDm = dm.filter(item => item.title == wyObj.wy)
|
|
|
|
|
return [...columns1,...columns2, ...newDm]
|
2024-09-20 15:02:50 +08:00
|
|
|
}
|
|
|
|
|
|
2025-04-10 14:27:15 +08:00
|
|
|
}, [trData,wyObj])
|
2024-09-20 15:02:50 +08:00
|
|
|
|
|
|
|
|
const getTableData = async (params) => {
|
|
|
|
|
setLoading(true)
|
|
|
|
|
try {
|
|
|
|
|
const res = await httppost2(apiurl.gcaqjc.sjtjcx.ndwytjb.page, params)
|
|
|
|
|
setLoading(false)
|
|
|
|
|
let newArr = [];
|
|
|
|
|
let newData = res.data?.map((s, i) => {
|
|
|
|
|
newArr.push(s.list?.map((c, i) => ({
|
2025-09-02 17:27:53 +08:00
|
|
|
[c.cd]: (c.value || c.value == 0) ? c.value : '-',
|
2025-09-01 17:55:23 +08:00
|
|
|
[`e_${c.cd}`]:c.de ,
|
|
|
|
|
[`n_${c.cd}`]:c.dn ,
|
|
|
|
|
[`u_${c.cd}`]:c.du ,
|
2024-09-20 15:02:50 +08:00
|
|
|
tm: c.tm,
|
|
|
|
|
})))
|
|
|
|
|
return {
|
|
|
|
|
tm: s.tm,
|
|
|
|
|
inx:i+1
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let filterData = newArr?.filter(s => s.length > 0).flat()
|
|
|
|
|
let result = newData?.map(s => {
|
|
|
|
|
let tm1 = s.tm;
|
|
|
|
|
let r = filterData.filter(t => {
|
|
|
|
|
return t.tm == tm1
|
|
|
|
|
})
|
|
|
|
|
let obj = {};
|
|
|
|
|
r.forEach(s1 => {
|
|
|
|
|
obj = {...s1,...obj}
|
|
|
|
|
})
|
|
|
|
|
return {
|
|
|
|
|
...s,
|
|
|
|
|
...obj,
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-04-10 14:27:15 +08:00
|
|
|
// const demo = [{tm:"2025-01-01",inx:1,"H_WY-03":0.87,"X_WY-01":0.1}]
|
2024-09-20 15:02:50 +08:00
|
|
|
setDataSource(result)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const width = useMemo(() => {
|
|
|
|
|
if (newCols?.length > 0) {
|
|
|
|
|
return newCols?.reduce((total, cur) => total + (cur.width), 0)
|
|
|
|
|
}
|
|
|
|
|
}, [newCols]);
|
2025-03-28 17:31:43 +08:00
|
|
|
console.log('width',width);
|
|
|
|
|
|
2024-09-20 15:02:50 +08:00
|
|
|
const exportExcel = () => {
|
|
|
|
|
let params = {
|
|
|
|
|
...searchVal,
|
2025-09-01 17:55:23 +08:00
|
|
|
stationCodes: [trData.find(s => s.cd == wyObj.wy)?.cd],
|
2024-09-20 15:02:50 +08:00
|
|
|
type:2,
|
|
|
|
|
id:1
|
|
|
|
|
}
|
|
|
|
|
httppost5(apiurl.gcaqjc.sjtjcx.ndwytjb.export, params).then(res => {
|
|
|
|
|
exportFile(`年度位移统计表.xlsx`,res.data)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const getTable2Data = async (params) => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await httppost2(apiurl.gcaqjc.sjtjcx.ndwytjb.list1, params)
|
2025-04-14 15:00:53 +08:00
|
|
|
setTable2Data(res.data)
|
|
|
|
|
// const list = []
|
|
|
|
|
// for(let i=0; i<24*3; i++){
|
|
|
|
|
// list.push({
|
|
|
|
|
// maxValue:'',
|
|
|
|
|
// maxTm:'',
|
|
|
|
|
// minValue:'',
|
|
|
|
|
// minTm:'',
|
|
|
|
|
// diff:'',
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
// setTable2Data(list)
|
2024-09-20 15:02:50 +08:00
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (trData && trData.length > 0) {
|
2025-09-18 15:26:22 +08:00
|
|
|
const {wy} = wyObj
|
2024-09-20 15:02:50 +08:00
|
|
|
const params = {
|
|
|
|
|
...searchVal,
|
2025-09-18 15:26:22 +08:00
|
|
|
stationCodes: [wy],
|
2024-09-20 15:02:50 +08:00
|
|
|
};
|
|
|
|
|
getTableData(params)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}, [searchVal,trData])
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (trData && trData?.length > 0) {
|
|
|
|
|
let params = {
|
|
|
|
|
...searchVal,
|
2025-09-01 17:55:23 +08:00
|
|
|
stationCodes:[trData.find(s => s.cd == wyObj.wy)?.cd],
|
2024-09-20 15:02:50 +08:00
|
|
|
}
|
|
|
|
|
getTable2Data(params)
|
|
|
|
|
}
|
2025-09-02 17:27:53 +08:00
|
|
|
}, [trData,wyObj,searchVal])
|
2024-09-20 15:02:50 +08:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
getDmTree()
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div className='content-root clearFloat xybm' style={{paddingRight:"10px",paddingBottom:"0"}}>
|
|
|
|
|
<div className='lf CrudAdcdTreeTableBox' style={{ width: "100%" }}>
|
|
|
|
|
<Card className='nonebox'>
|
|
|
|
|
<ToolBar
|
|
|
|
|
setSearchVal={setSearchVal}
|
2025-04-10 14:27:15 +08:00
|
|
|
list={trData}
|
|
|
|
|
setWyObj={setWyObj}
|
2024-09-20 15:02:50 +08:00
|
|
|
exportFile={exportExcel}
|
|
|
|
|
role={role}
|
|
|
|
|
/>
|
|
|
|
|
</Card>
|
|
|
|
|
<div className="ant-card-body" style={{ padding: "20px 0 0 0" }}>
|
2025-04-10 14:27:15 +08:00
|
|
|
<Table
|
2024-09-20 15:02:50 +08:00
|
|
|
columns={newCols}
|
|
|
|
|
rowKey="inx"
|
|
|
|
|
loading={loading}
|
|
|
|
|
scroll={{ x: width, y: "calc( 100vh - 500px )" }}
|
|
|
|
|
dataSource={dataSource}
|
|
|
|
|
pagination={false}
|
|
|
|
|
summary={(pageData) => {
|
|
|
|
|
return(
|
|
|
|
|
<Table.Summary fixed>
|
|
|
|
|
<Table.Summary.Row>
|
|
|
|
|
<Table.Summary.Cell index={0} align='center' ></Table.Summary.Cell>
|
|
|
|
|
<Table.Summary.Cell index={1} align='center'>最大值</Table.Summary.Cell>
|
|
|
|
|
{table2Data?.length > 0 && table2Data.map((item,i) =>
|
|
|
|
|
<Table.Summary.Cell index={i +1} align='center'>{item?.maxValue ?? "-"}</Table.Summary.Cell>)}
|
|
|
|
|
</Table.Summary.Row>
|
|
|
|
|
<Table.Summary.Row>
|
|
|
|
|
<Table.Summary.Cell index={0} align='center' ></Table.Summary.Cell>
|
|
|
|
|
<Table.Summary.Cell index={1} align='center'>日期</Table.Summary.Cell>
|
|
|
|
|
{table2Data?.length > 0 && table2Data.map((item,i) =>
|
|
|
|
|
<Table.Summary.Cell index={i +1} align='center'>{item?.maxTm?? "-"}</Table.Summary.Cell>)}
|
|
|
|
|
</Table.Summary.Row>
|
|
|
|
|
<Table.Summary.Row >
|
|
|
|
|
<Table.Summary.Cell index={0} align='center' className='total-col'>全年度特征值统计</Table.Summary.Cell>
|
|
|
|
|
<Table.Summary.Cell index={1} align='center'>最小值</Table.Summary.Cell>
|
|
|
|
|
{table2Data?.length > 0 && table2Data.map((item,i) =>
|
|
|
|
|
<Table.Summary.Cell index={i +1} align='center'>{item?.minValue ?? "-"}</Table.Summary.Cell>)}
|
|
|
|
|
</Table.Summary.Row>
|
|
|
|
|
<Table.Summary.Row>
|
|
|
|
|
<Table.Summary.Cell index={0} align='center' ></Table.Summary.Cell>
|
|
|
|
|
<Table.Summary.Cell index={1} align='center'>日期</Table.Summary.Cell>
|
|
|
|
|
{table2Data?.length > 0 && table2Data.map((item,i) =>
|
|
|
|
|
<Table.Summary.Cell index={i +1} align='center'>{item?.minTm?? "-"}</Table.Summary.Cell>)}
|
|
|
|
|
</Table.Summary.Row>
|
|
|
|
|
<Table.Summary.Row>
|
|
|
|
|
<Table.Summary.Cell index={0} align='center' ></Table.Summary.Cell>
|
|
|
|
|
<Table.Summary.Cell index={1} align='center'>年变幅</Table.Summary.Cell>
|
|
|
|
|
{table2Data?.length > 0 && table2Data.map((item,i) =>
|
|
|
|
|
<Table.Summary.Cell index={i +1} align='center'>{item?.diff?? "-"}</Table.Summary.Cell>)}
|
|
|
|
|
</Table.Summary.Row>
|
|
|
|
|
</Table.Summary>
|
|
|
|
|
)
|
|
|
|
|
}}
|
2025-04-10 14:27:15 +08:00
|
|
|
/>
|
|
|
|
|
{/* {
|
2025-03-28 17:31:43 +08:00
|
|
|
(newCols?.length>0 && width!==undefined)?
|
|
|
|
|
<MyTable
|
2025-04-10 14:27:15 +08:00
|
|
|
columns={demoColumns}
|
2025-03-28 17:31:43 +08:00
|
|
|
dataSource={dataSource}
|
|
|
|
|
width={width}
|
|
|
|
|
loading={loading}
|
|
|
|
|
table2Data={table2Data}
|
|
|
|
|
/>:null
|
2025-04-10 14:27:15 +08:00
|
|
|
} */}
|
2024-09-20 15:02:50 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Page;
|