Commit c27cf46b authored by 陈龙's avatar 陈龙

fix: 修复点击白屏问题;增加历史曲线表格的排序;

parent 0a460799
......@@ -41,6 +41,15 @@ npm run build
npm run release
```
```bash
# 完整发布
npm run build
add commit your code
npm run release
# 发布后文件的格式化导致变更,需要还原一下。请注意,是发布完后还原。
git checkout -- .
```
```bash
# 在base-components下新增TreeCustom文件夹
lerna create @wisdom-components/TreeCustom base-components
......
......@@ -47,7 +47,6 @@ class App extends React.Component {
isResize: false,
text: '',
isFlv: false,
loadingText: '加载中',
debug: false,
recordType: 'mp4',
loadingTimeout: 10,
......
import React, {useContext, useEffect, useMemo, useState} from 'react';
import React, {useContext, useEffect, useMemo, useState, useCallback} from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import {
......@@ -218,6 +218,8 @@ const timeColumn = {
fixed: 'left',
ellipsis: true,
align: 'center',
sorter: true,
sortOrder:'descend'
};
const HistoryView = (props) => {
......@@ -257,7 +259,7 @@ const HistoryView = (props) => {
const [columns, setColumns] = useState([]);
const [tableData, setTableData] = useState([]);
const [chartDataSource, setChartDataSource] = useState([]);
const [timeOrder, setTimeOrder] = useState('descend');
const [chartType, setChartType] = useState('lineChart');
const [showBoxOption, setShowBoxOption] = useState(true);
// 选择的时间范围值
......@@ -572,7 +574,7 @@ const HistoryView = (props) => {
});
};
const handleTableData = (data) => {
const handleTableData = useCallback((data) => {
const ignoreOutliers = checkboxData.find((item) => item.key === 'ignoreOutliers').checked;
const dataIndexAccess = (dataItem, index) => {
const {stationCode, sensorName} = dataItem;
......@@ -651,13 +653,13 @@ const HistoryView = (props) => {
aa = a.slice(contrastOption === 'day' ? 11 : 8, 16);
bb = b.slice(contrastOption === 'day' ? 11 : 8, 16);
}
return aa.localeCompare(bb);
return timeOrder === 'descend' ? -aa.localeCompare(bb) : aa.localeCompare(bb);
};
const times = Object.keys(timeData).sort(timeSort);
const tableData = times.map((time) => timeData[time]);
setColumns([timeColumn, ...columnsData]);
setTableData(tableData);
};
}, [timeOrder]);
const [deviceAlarmSchemes, setDeviceAlarmSchemes] = useState([]);
const beforChangeParams = (value = {}) => {
......@@ -739,7 +741,6 @@ const HistoryView = (props) => {
setLoading(true);
Promise.all(requestArr).then((results) => {
if (results.length) {
debugger
let data = [];
results.forEach((res, index) => {
const {dateFrom, dateTo} = dateRange?.[index] ?? {};
......@@ -787,7 +788,37 @@ const HistoryView = (props) => {
});
});
}, [dateRange, dataConfig, deviceParams, chartType]);
const handleChange = (pagination, filter, sort) => {
if (sort.field === 'time') {
debugger
setTimeOrder(sort.order)
}
};
const tableMemo = useMemo(() => {
return <>
<div className={`${prefixCls}-options`}>
{renderTimeOption()}
{renderCurveOption()}
</div>
<div className={`${prefixCls}-content`}>
{chartDataSource.length > 0 ? (
<BasicTable
dataSource={tableData.sort((a, b) => {
let _a = a.time;
let _b = b.time
return timeOrder === 'ascend' ? moment(_a) - moment(_b) : moment(_b) - moment(_a);
})}
columns={columns}
{...tableProps}
pagination={false}
onChange={handleChange}
/>
) : (
<PandaEmpty/>
)}
</div>
</>
}, [timeOrder, chartDataSource, columns, tableProps, tableData])
const renderPanel = (model) => {
if (model === 'curve') {
return (
......@@ -830,28 +861,7 @@ const HistoryView = (props) => {
);
}
if (model === 'table') {
return (
<>
<div className={`${prefixCls}-options`}>
{renderTimeOption()}
{renderCurveOption()}
</div>
<div className={`${prefixCls}-content`}>
{chartDataSource.length > 0 ? (
<BasicTable
dataSource={tableData}
columns={columns}
{...tableProps}
pagination={false}
onChange={() => {
}}
/>
) : (
<PandaEmpty/>
)}
</div>
</>
);
return tableMemo;
}
};
......
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