Commit 8c7dd0a4 authored by 陈龙's avatar 陈龙

fix: 修复被回退的代码

parent 3ec8e3f6
......@@ -13,6 +13,9 @@ const SimgleChart = memo((props) => {
curveCenter,
showGridLine = false,
deviceAlarmSchemes,
chartType,
justLine
} = props;
const chartRef = useRef();
......@@ -24,6 +27,8 @@ const SimgleChart = memo((props) => {
deviceAlarmSchemes,
showMarkLine: true,
showPoint: true,
chartType,
justLine
};
return optionGenerator(dataSource, null, contrast, contrastOption, smooth, config);
}, [dataSource, smooth, curveCenter]);
......
......@@ -25,7 +25,7 @@ const deviceParams = [
const Demo = () => {
return (
<div style={{ height: 700 }}>
<HistoryView deviceParams={deviceParams} grid />
{/*<HistoryView deviceParams={deviceParams} grid />*/}
</div>
);
};
......
......@@ -2,18 +2,19 @@ import React from 'react';
import HistoryView from '../index';
const deviceParams = [
// {
// deviceCode: 'EGBF00000146',
// sensors: '进水压力,出水瞬时流量,出水累计流量',
// deviceType: '二供泵房',
// pointAddressID: 4,
// },
{
deviceCode: 'EGBF00000146',
sensors: '进水压力,出水瞬时流量,出水累计流量',
// deviceCode: 'EGBF00000002',
deviceCode: 'EGBF00000082',
sensors: '进水压力',
deviceType: '二供泵房',
pointAddressID: 4,
},
{
deviceCode: 'EGJZ00001113',
sensors: '出水瞬时流量,出水压力,泵1状态',
deviceType: '二供机组',
pointAddressID: 4,
},
// {
// deviceCode: 'EGJZ00001113',
// sensors: '出水压力',
......
import React, { useContext, useEffect, useMemo, useState } from 'react';
import React, {useContext, useEffect, useMemo, useState} from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import {
......@@ -23,21 +23,20 @@ import _ from 'lodash';
import TimeRangePicker from '@wisdom-components/timerangepicker';
import PandaEmpty from '@wisdom-components/empty';
import BasicTable from '@wisdom-components/basictable';
import { getHistoryInfo, getDeviceAlarmScheme, getExportDeviceHistoryUrl } from './apis';
import {getHistoryInfo, getDeviceAlarmScheme, getExportDeviceHistoryUrl} from './apis';
import SimgleChart from './SingleChart';
import GridChart from './GridChart';
import './index.less';
import { globalConfig } from 'antd/lib/config-provider';
import {globalConfig} from 'antd/lib/config-provider';
const { RangePicker } = DatePicker;
const { Option } = Select;
const {RangePicker} = DatePicker;
const {Option} = Select;
const startFormat = 'YYYY-MM-DD 00:00:00';
const endFormat = 'YYYY-MM-DD 23:59:59';
const timeFormat = 'YYYY-MM-DD HH:mm:ss';
const dateFormat = 'YYYYMMDD';
// 时间列表
const timeList = [
{
key: 'twelveHours',
......@@ -221,7 +220,7 @@ const timeColumn = {
};
const HistoryView = (props) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
const {getPrefixCls} = useContext(ConfigProvider.ConfigContext);
const prefixCls = getPrefixCls('history-view');
const {
......@@ -234,8 +233,7 @@ const HistoryView = (props) => {
showModels,
needMarkLine,
} = props;
const isBoxPlots =
deviceParams?.length === 1 && deviceParams[0]?.sensors?.split(',').length === 1;
const isBoxPlots = deviceParams?.length === 1 && deviceParams[0]?.sensors?.split(',').length === 1;
const [loading, setLoading] = useState(false);
const [activeTabKey, setActiveTabKey] = useState(defaultModel);
......@@ -390,7 +388,7 @@ const HistoryView = (props) => {
)}
{timeValue === 'contrast' && ( // 同期对比
<>
<Select value={contrastOption} style={{ width: 60 }} onChange={onContrastChange}>
<Select value={contrastOption} style={{width: 60}} onChange={onContrastChange}>
<Option value="day"></Option>
<Option value="month"></Option>
</Select>
......@@ -407,7 +405,7 @@ const HistoryView = (props) => {
className={classNames(`${prefixCls}-contrast-delete`)}
onClick={() => handleDeleteDatePicker(index)}
>
<CloseCircleFilled />
<CloseCircleFilled/>
</div>
)}
</div>
......@@ -416,7 +414,7 @@ const HistoryView = (props) => {
)}
</div>
))}
{datePickerArr.length < 5 && <PlusCircleOutlined onClick={handleAddDatePicker} />}
{datePickerArr.length < 5 && <PlusCircleOutlined onClick={handleAddDatePicker}/>}
</>
)}
</div>
......@@ -426,8 +424,8 @@ const HistoryView = (props) => {
// 曲线设置项选择/取消
const onCheckboxChange = (e, key) => {
let data = [...checkboxData];
let _index = data.findIndex((item) => item.key === 'justLine'); // 仅查看曲线会在勾选了数据滤波后展示
let _index1 = data.findIndex((item) => item.key === 'ignoreOutliers'); // 仅查看曲线会在勾选了数据滤波后展示
let _index = data.findIndex(item => item.key === 'justLine'); // 仅查看曲线会在勾选了数据滤波后展示
let _index1 = data.findIndex(item => item.key === 'ignoreOutliers'); // 仅查看曲线会在勾选了数据滤波后展示
data.forEach((item) => {
if (item.key === key) {
item.checked = e.target.checked;
......@@ -465,7 +463,7 @@ const HistoryView = (props) => {
</Checkbox>
{child.tooltip && (
<Tooltip title={child.tooltip}>
<QuestionCircleFilled className={`${prefixCls}-question`} />
<QuestionCircleFilled className={`${prefixCls}-question`}/>
</Tooltip>
)}
</>
......@@ -475,26 +473,19 @@ const HistoryView = (props) => {
const renderCurveOption = (isChart, isSingle) => {
return (
<div className={classNames(`${prefixCls}-cover`)}>
{isChart && isSingle ? (
<>
<div className={classNames(`${prefixCls}-cover`)} style={isChart && isSingle ? {width: '100%'} : {}}>
{
isChart && isSingle ? <>
<div className={classNames(`${prefixCls}-label`)}>曲线形态</div>
<Radio.Group
value={chartType}
style={{ marginRight: 16 }}
onChange={(e) => {
<Radio.Group value={chartType} style={{marginRight: 16}} onChange={(e) => {
let _value = e.target.value;
setChartType(_value);
onCheckboxChange({ target: { value: _value !== 'boxChart' } }, 'chartType');
}}
>
onCheckboxChange({target: {value: _value !== 'boxChart'}}, 'chartType')
}}>
<Radio.Button value={'lineChart'}>线形图</Radio.Button>
<Radio.Button value={'boxChart'}>箱线图</Radio.Button>
</Radio.Group>
</>
) : (
''
)}
</Radio.Group></> : ''
}
<div className={classNames(`${prefixCls}-label`)}>曲线设置</div>
{checkboxData.map((child) => {
const box = renderCheckbox(child);
......@@ -508,7 +499,7 @@ const HistoryView = (props) => {
{activeTabKey === 'table' && (
<Select
value={dataThinKey}
style={{ width: 90 }}
style={{width: 90}}
onChange={onTimeIntervalChange}
disabled={!dataConfig.dataThin}
>
......@@ -546,14 +537,15 @@ const HistoryView = (props) => {
aDom.click();
aDom.remove();
})
.catch((err) => {});
.catch((err) => {
});
});
};
const handleTableData = (data) => {
const ignoreOutliers = checkboxData.find((item) => item.key === 'ignoreOutliers').checked;
const dataIndexAccess = (dataItem, index) => {
const { stationCode, sensorName } = dataItem;
const {stationCode, sensorName} = dataItem;
return `${stationCode}-${sensorName}-${index}`;
};
......@@ -564,7 +556,7 @@ const HistoryView = (props) => {
// 处理表头数据
const columnsData = data.map((item, index) => {
const { stationCode, equipmentName, sensorName, unit, dataModel } = item;
const {stationCode, equipmentName, sensorName, unit, dataModel} = item;
const dataIndex = dataIndexAccess(item, index);
let col = {
title: `${equipmentName}-${sensorName}${unit ? `(${unit})` : ''}`,
......@@ -587,7 +579,7 @@ const HistoryView = (props) => {
const timeData = {};
const buildDefaultData = (time) => {
const obj = { key: time, time: time };
const obj = {key: time, time: time};
data.forEach((item, index) => {
const dataIndex = dataIndexAccess(item, index);
obj[dataIndex] = '';
......@@ -595,7 +587,7 @@ const HistoryView = (props) => {
return obj;
};
data.forEach((item, index) => {
const { stationCode, sensorName, dataModel } = item;
const {stationCode, sensorName, dataModel} = item;
dataModel.forEach((data) => {
const formatTime = moment(data.pt).format(format);
......@@ -610,7 +602,7 @@ const HistoryView = (props) => {
// 处理表格数据
data.forEach((child, index) => {
const { dataModel } = child;
const {dataModel} = child;
const dataIndex = dataIndexAccess(child, index);
dataModel.forEach((value, j) => {
const formatTime = moment(value.pt).format(format);
......@@ -660,23 +652,23 @@ const HistoryView = (props) => {
const handleDataThinKey = (diffDays) => {
// edit by zy 根据选择的时长控制抽稀频度
if (diffDays >= 7 && diffDays < 15) {
return { unit: 'h', zoom: '2' };
return {unit: 'h', zoom: '2'};
} else if (diffDays >= 15 && diffDays < 30) {
return { unit: 'h', zoom: '4' };
return {unit: 'h', zoom: '4'};
} else if (diffDays >= 30) {
return { unit: 'h', zoom: '6' };
return {unit: 'h', zoom: '6'};
} else if (diffDays < 7 && diffDays >= 2) {
return { unit: 'min', zoom: '40' };
return {unit: 'min', zoom: '40'};
} else if (diffDays < 2 && diffDays >= 1) {
return { unit: 'min', zoom: '30' };
return {unit: 'min', zoom: '30'};
} else {
return { unit: 'min', zoom: '10' };
return {unit: 'min', zoom: '10'};
}
};
// 处理接口服务参数的变化
const onChangeParams = (value = {}) => {
const { dateRange, isDilute, ignoreOutliers, zoom, unit } = value;
const {dateRange, isDilute, ignoreOutliers, zoom, unit} = value;
const requestArr = [];
const acrossTables = [];
deviceParams.forEach((i) => {
......@@ -689,7 +681,7 @@ const HistoryView = (props) => {
return;
}
dateRange.forEach((item) => {
let _showLine = checkboxData.find((item) => item.key === 'justLine');
let _showLine = checkboxData.find(item => item.key === 'justLine');
const param = {
isDilute,
zoom,
......@@ -699,20 +691,19 @@ const HistoryView = (props) => {
dateFrom: item.dateFrom,
dateTo: item.dateTo,
acrossTables,
isBoxPlots: isBoxPlots,
isBoxPlots: isBoxPlots
};
let diffDays = moment(item.dateTo).diff(moment(item.dateFrom), 'days');
let zoomParam = activeTabKey === 'curve' ? handleDataThinKey(diffDays) : {};
requestArr.push(getHistoryInfo({ ...param, ...zoomParam }));
requestArr.push(getHistoryInfo({...param, ...zoomParam}));
});
setLoading(true);
Promise.all(requestArr).then((results) => {
if (results.length) {
let data = [];
results.forEach((res, index) => {
const { dateFrom, dateTo } = dateRange?.[index] ?? {};
const {dateFrom, dateTo} = dateRange?.[index] ?? {};
if (res.code === 0 && res.data.length) {
debugger;
res.data.forEach((d) => {
d.dateFrom = dateFrom;
d.dateTo = dateTo;
......@@ -740,7 +731,7 @@ const HistoryView = (props) => {
};
useEffect(() => {
const { dataThin, ignoreOutliers, zoom, unit } = dataConfig;
const {dataThin, ignoreOutliers, zoom, unit} = dataConfig;
beforChangeParams().finally(() => {
onChangeParams({
isDilute: dataThin,
......@@ -748,7 +739,7 @@ const HistoryView = (props) => {
zoom,
unit,
dateRange,
isBoxPlots: isBoxPlots,
isBoxPlots: isBoxPlots
});
});
}, [dateRange, dataConfig, deviceParams, chartType]);
......@@ -759,14 +750,11 @@ const HistoryView = (props) => {
<>
<div className={`${prefixCls}-options`}>
{renderTimeOption()}
{renderCurveOption(
true,
deviceParams?.length === 1 && deviceParams[0]?.sensors?.split(',').length === 1,
)}
{renderCurveOption(true, (deviceParams?.length === 1 && deviceParams[0]?.sensors?.split(',').length === 1))}
</div>
<div className={`${prefixCls}-content`}>
{!chartDataSource.length ? (
<PandaEmpty />
<PandaEmpty/>
) : grid === true ? (
<GridChart
curveCenter={curveCenter}
......@@ -782,7 +770,7 @@ const HistoryView = (props) => {
showGridLine={chartGrid}
prefixCls={prefixCls}
dataSource={chartDataSource}
justLine={!!checkboxData.find((item) => item.key === 'justLine' && item.checked)}
justLine={!!checkboxData.find(item => item.key === 'justLine' && item.checked)}
chartType={isBoxPlots ? chartType : null}
contrast={timeValue === 'contrast'}
contrastOption={contrastOption}
......@@ -807,10 +795,11 @@ const HistoryView = (props) => {
columns={columns}
{...tableProps}
pagination={false}
onChange={() => {}}
onChange={() => {
}}
/>
) : (
<PandaEmpty />
<PandaEmpty/>
)}
</div>
</>
......@@ -835,7 +824,7 @@ const HistoryView = (props) => {
<div className={`${prefixCls}-extra-right`}>
{activeTabKey === 'table' && (
<Button type="link" onClick={exportExcelBtn}>
<DownloadOutlined />
<DownloadOutlined/>
下载
</Button>
)}
......
......@@ -459,7 +459,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
let unit = ''
series = series.map(item => {
if (item.unit) unit = item.unit;
let _item = {...item, symbol: null};
let _item = {...item, symbol: 'none'};
_item.data = _item?.data?.map(d => {
return d[1] || null
}) || [];
......@@ -468,7 +468,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
series.push({
type: 'candlestick',
name: '箱线图',
symbol: null,
symbol: 'none',
data: otherData,
});
tooltip = tooltipAccessor(unit)
......@@ -482,7 +482,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
}); //当存在othersData的时候,只是单曲线
xAxis = {type: 'category', data: series[0].data.map(item => moment(item[0]).format('YYYY-MM-DD'))};
series = series.map(item => {
let _item = {...item, symbol: false};
let _item = {...item, symbol: 'none'};
_item.data = _item?.data?.map(d => {
return d[1] || null
}) || [];
......
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