Commit ebcef43e authored by 崔佳豪's avatar 崔佳豪

fix: 优化历史曲线指标分组及排序

parent b50bc3db
...@@ -9,12 +9,13 @@ const GridChart = memo((props) => { ...@@ -9,12 +9,13 @@ const GridChart = memo((props) => {
const gridData = useMemo(() => { const gridData = useMemo(() => {
const grids = dataSource.reduce((pre, item, index) => { const grids = dataSource.reduce((pre, item, index) => {
const { sensorName } = item; const { sensorName, deviceType } = item;
let grid = pre.find((g) => g.key === sensorName); const key = `${deviceType}_${sensorName}`; // 同设备类型同指标才在同一组
let grid = pre.find((g) => g.key === key);
if (!grid) { if (!grid) {
const restProp = _.pick(item, ['equipmentName', 'sensorName', 'stationCode', 'unit']); const restProp = _.pick(item, ['equipmentName', 'sensorName', 'stationCode', 'unit']);
grid = { grid = {
key: sensorName, key: key,
list: [], list: [],
...restProp, ...restProp,
}; };
...@@ -45,15 +46,13 @@ const GridChart = memo((props) => { ...@@ -45,15 +46,13 @@ const GridChart = memo((props) => {
return ( return (
<div className={`${prefixCls}-grid`}> <div className={`${prefixCls}-grid`}>
{ {options.map((item) => (
options.map(item => (
<div key={item.key} className={`${prefixCls}-grid-item`}> <div key={item.key} className={`${prefixCls}-grid-item`}>
<div className={`${prefixCls}-grid-item-wrap`}> <div className={`${prefixCls}-grid-item-wrap`}>
<BasicChart style={{ width: '100%', height: '100%' }} option={item.option} notMerge /> <BasicChart style={{ width: '100%', height: '100%' }} option={item.option} notMerge />
</div> </div>
</div> </div>
)) ))}
}
</div> </div>
); );
}); });
......
import React from 'react'; import React from 'react';
import HistoryView from '../index'; import HistoryView from '../index';
const deviceParams = [{ const deviceParams = [
deviceCode: "EGBF00000146", {
sensors: "进水压力,出水瞬时流量,出水累计流量", deviceCode: 'EGBF00000146',
deviceType: "二供泵房" sensors: '进水压力,出水瞬时流量,出水累计流量',
}] deviceType: '二供泵房',
},
{
deviceCode: 'EGJZ00001113',
sensors: '出水瞬时流量,出水压力,泵1状态',
deviceType: '二供机组',
},
];
const Demo = () => { const Demo = () => {
return ( return (
<div style={{height: 700}}> <div style={{ height: 700 }}>
<HistoryView deviceParams={deviceParams} grid /> <HistoryView deviceParams={deviceParams} grid />
</div> </div>
); );
......
...@@ -2,16 +2,16 @@ import React from 'react'; ...@@ -2,16 +2,16 @@ import React from 'react';
import HistoryView from '../index'; import HistoryView from '../index';
const deviceParams = [ const deviceParams = [
// { {
// deviceCode: "EGBF00000146", deviceCode: 'EGBF00000146',
// sensors: "进水压力,出水瞬时流量,出水累计流量", sensors: '进水压力,出水瞬时流量,出水累计流量',
// deviceType: "二供泵房" deviceType: '二供泵房',
// }, },
// { {
// deviceCode: "EGJZ00001113", deviceCode: 'EGJZ00001113',
// sensors: "出水瞬时流量,出水压力,泵1状态", sensors: '出水瞬时流量,出水压力,泵1状态',
// deviceType: "二供机组" deviceType: '二供机组',
// } },
]; ];
const Demo = () => { const Demo = () => {
return ( return (
......
...@@ -175,7 +175,7 @@ const timeColumn = { ...@@ -175,7 +175,7 @@ const timeColumn = {
title: '采集时间', title: '采集时间',
dataIndex: 'time', dataIndex: 'time',
key: 'time', key: 'time',
width: 160, width: 170,
fixed: 'left', fixed: 'left',
ellipsis: true, ellipsis: true,
align: 'center', align: 'center',
...@@ -533,7 +533,19 @@ const HistoryView = (props) => { ...@@ -533,7 +533,19 @@ const HistoryView = (props) => {
d.dateFrom = dateFrom; d.dateFrom = dateFrom;
d.dateTo = dateTo; d.dateTo = dateTo;
}); });
data = data.concat(res.data); deviceParams.forEach((p) => {
// 返回数据按查询指标顺序排序
const sensors = p.sensors?.split(',') ?? [];
const list = sensors.map((s) => {
const dataItem = res.data.find(
(d) => d.stationCode === p.deviceCode && d.sensorName === s,
);
dataItem.dateFrom = dateFrom;
dataItem.dateTo = dateTo;
return dataItem;
});
data = data.concat(list);
});
} }
}); });
setLoading(false); setLoading(false);
...@@ -611,7 +623,7 @@ const HistoryView = (props) => { ...@@ -611,7 +623,7 @@ const HistoryView = (props) => {
dataSource={tableData} dataSource={tableData}
columns={columns} columns={columns}
{...tableProps} {...tableProps}
pagination={{ showQuickJumper: true, showSizeChanger: true }} pagination={false}
onChange={() => {}} onChange={() => {}}
/> />
) : ( ) : (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment