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

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

parent b50bc3db
......@@ -9,12 +9,13 @@ const GridChart = memo((props) => {
const gridData = useMemo(() => {
const grids = dataSource.reduce((pre, item, index) => {
const { sensorName } = item;
let grid = pre.find((g) => g.key === sensorName);
const { sensorName, deviceType } = item;
const key = `${deviceType}_${sensorName}`; // 同设备类型同指标才在同一组
let grid = pre.find((g) => g.key === key);
if (!grid) {
const restProp = _.pick(item, ['equipmentName', 'sensorName', 'stationCode', 'unit']);
grid = {
key: sensorName,
key: key,
list: [],
...restProp,
};
......@@ -45,15 +46,13 @@ const GridChart = memo((props) => {
return (
<div className={`${prefixCls}-grid`}>
{
options.map(item => (
{options.map((item) => (
<div key={item.key} className={`${prefixCls}-grid-item`}>
<div className={`${prefixCls}-grid-item-wrap`}>
<BasicChart style={{ width: '100%', height: '100%' }} option={item.option} notMerge />
</div>
</div>
))
}
))}
</div>
);
});
......
import React from 'react';
import HistoryView from '../index';
const deviceParams = [{
deviceCode: "EGBF00000146",
sensors: "进水压力,出水瞬时流量,出水累计流量",
deviceType: "二供泵房"
}]
const deviceParams = [
{
deviceCode: 'EGBF00000146',
sensors: '进水压力,出水瞬时流量,出水累计流量',
deviceType: '二供泵房',
},
{
deviceCode: 'EGJZ00001113',
sensors: '出水瞬时流量,出水压力,泵1状态',
deviceType: '二供机组',
},
];
const Demo = () => {
return (
<div style={{height: 700}}>
<div style={{ height: 700 }}>
<HistoryView deviceParams={deviceParams} grid />
</div>
);
......
......@@ -2,16 +2,16 @@ import React from 'react';
import HistoryView from '../index';
const deviceParams = [
// {
// deviceCode: "EGBF00000146",
// sensors: "进水压力,出水瞬时流量,出水累计流量",
// deviceType: "二供泵房"
// },
// {
// deviceCode: "EGJZ00001113",
// sensors: "出水瞬时流量,出水压力,泵1状态",
// deviceType: "二供机组"
// }
{
deviceCode: 'EGBF00000146',
sensors: '进水压力,出水瞬时流量,出水累计流量',
deviceType: '二供泵房',
},
{
deviceCode: 'EGJZ00001113',
sensors: '出水瞬时流量,出水压力,泵1状态',
deviceType: '二供机组',
},
];
const Demo = () => {
return (
......
......@@ -175,7 +175,7 @@ const timeColumn = {
title: '采集时间',
dataIndex: 'time',
key: 'time',
width: 160,
width: 170,
fixed: 'left',
ellipsis: true,
align: 'center',
......@@ -533,7 +533,19 @@ const HistoryView = (props) => {
d.dateFrom = dateFrom;
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);
......@@ -611,7 +623,7 @@ const HistoryView = (props) => {
dataSource={tableData}
columns={columns}
{...tableProps}
pagination={{ showQuickJumper: true, showSizeChanger: true }}
pagination={false}
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