Commit c27cf46b authored by 陈龙's avatar 陈龙

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

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