From d1f1715f938473fddb633b61dcd042fb843917ec Mon Sep 17 00:00:00 2001 From: lishenfeng Date: Sat, 22 Nov 2025 15:08:46 +0800 Subject: [PATCH] =?UTF-8?q?feat():=20=E8=A1=A8=E6=A0=BC=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Home/RealTable.js | 34 ++++++++++++++++++---------------- src/views/Home/_.js | 1 + 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/views/Home/RealTable.js b/src/views/Home/RealTable.js index 7d6d764..f361f6f 100644 --- a/src/views/Home/RealTable.js +++ b/src/views/Home/RealTable.js @@ -14,9 +14,9 @@ const RealTable = ({ ctx }) => { const [visible, setVisible] = useState(false); const [detailRow, setDetailRow] = useState(); const [range, setRange] = useState([moment().add(-7, 'day'), moment()]); - const [tabKey, setTabKey] = useState('PH'); + const [tabKey, setTabKey] = useState('pH'); const [list, setList] = useState([]); - const getUnit = (key) => key === 'PH' ? '' : 'mg/L'; + const getUnit = (key) => key === 'pH' ? '' : 'mg/L'; const loadDetail = async (rowArg) => { const target = rowArg; if (!target) return; @@ -35,11 +35,11 @@ const RealTable = ({ ctx }) => { { title: '站点名称', key: 'mn',dataIndex:"mn",ellipsis: true, width: 90}, { title: '数据时间', key: 'tm', dataIndex: "tm", align: 'center', width: 80, - render: (v, r) => {v ? moment(v).format('MM-DD HH:mm:ss'):""} + render: (v, r) => {v ? moment(v).format('MM-DD HH:mm:ss'):""} }, - { title: 'PH值', key: 'ph', dataIndex:"ph",align: 'center', width: 70}, + { title: 'pH值', key: 'ph', dataIndex:"ph",align: 'center', width: 70}, { title: '总磷(mg/L)', key: 'p', dataIndex:"p",align: 'center', width: 70}, - { title: 'COD(mg/L)', key: 'cod', dataIndex:"cod",align: 'center', width: 90}, + { title: 'CODcr (mg/L)', key: 'cod', dataIndex:"cod",align: 'center', width: 80}, { title: '氨氮(mg/L)', key: 'ad', dataIndex: "ad", align: 'center', width: 70 }, { title: '操作', key: 'operation', width: 70, align: 'center', @@ -66,7 +66,9 @@ const RealTable = ({ ctx }) => { return ctx?.selArea?.label == '水质'? columns : flowColumns },[ctx]) - const height = (ctx.dataWithFav.length + 1) * 40; + const height = (ctx.dataWithFav.length + 1) * 60; + console.log(height,size); + return (
{ dataSource={ctx?.selArea?.label == '水质'? ctx.dataWithFav:[]} rowKey={row => row.mn} columns={newCols} - scroll={size?.height && size.height < height ? { y: size.height - 48 } : undefined} + scroll={size?.height && size.height < height ? { y: size.height - 48,x:"auto" } : undefined} /> - { setVisible(false);setTabKey('PH') }} footer={null} width={900}> + { setVisible(false); setTabKey('pH');setList([]) }} footer={null} width={900}>
@@ -91,27 +93,27 @@ const RealTable = ({ ctx }) => { rowKey={row => row.mn} columns={[ { title: '时间', dataIndex: 'tm', key: 'tm', width: 140, render: (v, r) => {v ? moment(v).format('YYYY-MM-DD HH:mm:ss'):""} }, - { title: 'PH值', dataIndex: 'ph', key: 'ph', width: 80 }, + { title: 'pH值', dataIndex: 'ph', key: 'ph', width: 80 }, { title: '总磷(mg/L)', dataIndex: 'p', key: 'p', width: 120 }, - { title: 'COD(mg/L)', dataIndex: 'cod', key: 'cod', width: 140 }, + { title: 'CODcr (mg/L)', dataIndex: 'cod', key: 'cod', width: 80 }, { title: '氨氮(mg/L)', dataIndex: 'ad', key: 'ad', width: 120 }, ]} scroll={{y:400,x:"auto"}} />
- ({ key: k, label: k }))} /> + ({ key: k, label: k }))} /> { const p = Array.isArray(params) ? params[0] : params; const unit = getUnit(tabKey); return `${p.axisValue}
${p.seriesName}: ${p.data === null ? '' : p.data}${unit ? ' ' + unit : ''}`; } }, - xAxis: { type: 'category', data: list.map(o => moment(o.time || o.tm).format('MM-DD HH:mm'))}, + xAxis: { type: 'category',inverse:true, data: list.map(o => moment(o.time || o.tm).format('MM-DD HH:mm'))}, yAxis: (() => { const vals = list.map(o => { - if (tabKey === 'PH') return o.ph; + if (tabKey === 'pH') return o.ph; if (tabKey === '总磷') return o.p; - if (tabKey === 'COD') return o.cod; + if (tabKey === 'CODcr') return o.cod; return o.ad; }).filter(v => typeof v === 'number'); const unit = getUnit(tabKey); @@ -125,9 +127,9 @@ const RealTable = ({ ctx }) => { }; })(), series: [{ name: tabKey, type: 'line', smooth: true, data: list.map(o => { - if (tabKey === 'PH') return o.ph; + if (tabKey === 'pH') return o.ph; if (tabKey === '总磷') return o.p; - if (tabKey === 'COD') return o.cod; + if (tabKey === 'CODcr') return o.cod; return o.ad; }) }] }} /> diff --git a/src/views/Home/_.js b/src/views/Home/_.js index 9674210..97df4f6 100644 --- a/src/views/Home/_.js +++ b/src/views/Home/_.js @@ -34,6 +34,7 @@ export function usePageContext() { return acc.concat(arr.map(item => ({ ...item, status: statusKey }))); }, []); } + data = data.sort((a, b) => ((a?.status === 'false' || a?.status === false) ? 1 : 0) - ((b?.status === 'false' || b?.status === false) ? 1 : 0)); setStData(data.map(o => ({ ...o, name: o.name || o.stationName || o.stnm }))); } catch (error) { console.log(error);