Commit 69359a7e authored by 陈龙's avatar 陈龙

feat: 优化历史曲线交互

parent 8e0ac16f
...@@ -4,7 +4,7 @@ import PandaEmpty from '@wisdom-components/empty'; ...@@ -4,7 +4,7 @@ import PandaEmpty from '@wisdom-components/empty';
import optionGenerator, { alarmMarkLine, minMaxMarkPoint, offlineArea } from './utils'; import optionGenerator, { alarmMarkLine, minMaxMarkPoint, offlineArea } from './utils';
import { isArray, cloneDeep } from 'lodash'; import { isArray, cloneDeep } from 'lodash';
const SimgleChart = memo((props) => { const SingleChart = memo((props) => {
const { const {
dataSource, dataSource,
contrast = false, contrast = false,
...@@ -128,4 +128,4 @@ const SimgleChart = memo((props) => { ...@@ -128,4 +128,4 @@ const SimgleChart = memo((props) => {
); );
}); });
export default SimgleChart; export default SingleChart;
import React from 'react'; import React from 'react';
import HistoryView from '../index'; import HistoryView from '../index';
/*const deviceParams = [ const deviceParams = [
{ {
deviceCode: 'EGBF00000136', deviceCode: 'EGBF00000136',
sensors: '进水压力,出水瞬时流量,出水累计流量', sensors: '进水压力,出水瞬时流量,出水累计流量',
...@@ -21,7 +21,7 @@ import HistoryView from '../index'; ...@@ -21,7 +21,7 @@ import HistoryView from '../index';
deviceType: '二供泵房', deviceType: '二供泵房',
pointAddressID: 4, pointAddressID: 4,
}, },
];*/ ];
/*const deviceParams = [ /*const deviceParams = [
{ {
"deviceCode": "LLJ00000055", "deviceCode": "LLJ00000055",
...@@ -34,7 +34,7 @@ import HistoryView from '../index'; ...@@ -34,7 +34,7 @@ import HistoryView from '../index';
"deviceType": "流量计" "deviceType": "流量计"
} }
]*/ ]*/
const deviceParams = [ /*const deviceParams = [
{ {
"deviceCode": "EGBF00000023", "deviceCode": "EGBF00000023",
"sensors": "出水瞬时流量,是否在线", "sensors": "出水瞬时流量,是否在线",
...@@ -45,7 +45,19 @@ const deviceParams = [ ...@@ -45,7 +45,19 @@ const deviceParams = [
"sensors": "出水瞬时流量,是否在线", "sensors": "出水瞬时流量,是否在线",
"deviceType": "二供泵房" "deviceType": "二供泵房"
} }
] ]*/
/*const deviceParams = [
{
"deviceCode": "QSSSC00000001",
"sensors": "出水瞬时流量,是否在线",
"deviceType": "确山送水厂"
},
{
"deviceCode": "EGBF00000019",
"sensors": "出水瞬时流量,是否在线",
"deviceType": "二供泵房"
}
]*/
const Demo = () => { const Demo = () => {
return <div style={{ height: 700 }}> return <div style={{ height: 700 }}>
<HistoryView deviceParams={deviceParams} grid /> <HistoryView deviceParams={deviceParams} grid />
......
...@@ -3,13 +3,13 @@ import HistoryView from '../index'; ...@@ -3,13 +3,13 @@ import HistoryView from '../index';
import {MobileHistoryChart} from "../mobile"; import {MobileHistoryChart} from "../mobile";
const deviceParams = [ const deviceParams = [
/* { {
deviceCode: 'EGBF00000141', deviceCode: 'EGBF00000141',
// sensors: '进水压力,出水瞬时流量,出水累计流量', // sensors: '进水压力,出水瞬时流量,出水累计流量',
sensors: '进水压力', sensors: '进水压力',
deviceType: '二供泵房', deviceType: '二供泵房',
pointAddressID: 208, pointAddressID: 208,
},*/ },
/* { /* {
"deviceCode": "SYJ00000008", "deviceCode": "SYJ00000008",
"sensors": "瞬时流量", "sensors": "瞬时流量",
...@@ -43,11 +43,11 @@ const deviceParams = [ ...@@ -43,11 +43,11 @@ const deviceParams = [
"deviceType": "二供机组" "deviceType": "二供机组"
}*/ }*/
// 邳州张楼水厂 // 邳州张楼水厂
{ /* {
"deviceCode": "SC00000023", "deviceCode": "SC00000023",
"sensors": "出水压力", "sensors": "出水压力",
"deviceType": "水厂" "deviceType": "水厂"
} }*/
/* /*
{ {
"deviceCode": "JFJ00000001", "deviceCode": "JFJ00000001",
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
Tabs, Tabs,
Tooltip, Tooltip,
Button, Button,
message, Segmented message,
} from 'antd'; } from 'antd';
import { import {
CloseCircleFilled, CloseCircleFilled,
...@@ -25,7 +25,7 @@ import TimeRangePicker from '@wisdom-components/timerangepicker'; ...@@ -25,7 +25,7 @@ import TimeRangePicker from '@wisdom-components/timerangepicker';
import PandaEmpty from '@wisdom-components/empty'; import PandaEmpty from '@wisdom-components/empty';
import BasicTable from '@wisdom-components/basictable'; import BasicTable from '@wisdom-components/basictable';
import {getHistoryInfo, getDeviceAlarmScheme, getExportDeviceHistoryUrl, getDictionaryInfoAll} from './apis'; import {getHistoryInfo, getDeviceAlarmScheme, getExportDeviceHistoryUrl, getDictionaryInfoAll} from './apis';
import SimgleChart from './SingleChart'; import SingleChart from './SingleChart';
import GridChart from './GridChart'; import GridChart from './GridChart';
import './index.less'; import './index.less';
import {globalConfig} from 'antd/lib/config-provider'; import {globalConfig} from 'antd/lib/config-provider';
...@@ -244,7 +244,8 @@ const timeColumn = { ...@@ -244,7 +244,8 @@ const timeColumn = {
sorter: true, sorter: true,
// sortOrder:['descend','ascend'] // sortOrder:['descend','ascend']
}; };
const OriginMaxDays = 7; // 原始曲线请求数据的最大天数
const CharacteristicMaxDays = 60; // 特征曲线或者其他曲线的最大天数
const HistoryView = (props) => { const HistoryView = (props) => {
const [completeInit, setCompleteInit] = useState(false); const [completeInit, setCompleteInit] = useState(false);
const {getPrefixCls} = useContext(ConfigProvider.ConfigContext); const {getPrefixCls} = useContext(ConfigProvider.ConfigContext);
...@@ -301,6 +302,8 @@ const HistoryView = (props) => { ...@@ -301,6 +302,8 @@ const HistoryView = (props) => {
} }
}, [contrastOption, customerChecked, customerTime, datePickerArr, timeValue, shortcutsValue]); }, [contrastOption, customerChecked, customerTime, datePickerArr, timeValue, shortcutsValue]);
const [dates, setDates] = useState(null);
const configDependence = checkboxData const configDependence = checkboxData
.filter((item) => ['curveCenter', 'chartGrid'].indexOf(item.key) === -1) .filter((item) => ['curveCenter', 'chartGrid'].indexOf(item.key) === -1)
.map((item) => item.checked) .map((item) => item.checked)
...@@ -474,37 +477,72 @@ const HistoryView = (props) => { ...@@ -474,37 +477,72 @@ const HistoryView = (props) => {
} }
setShortcutsDatePickerArr(_arr); setShortcutsDatePickerArr(_arr);
}; };
const renderTimeOption = () => { const renderTimeOption = useMemo(() => {
return ( return (
<div className={classNames(`${prefixCls}-date`)}> <div className={classNames(`${prefixCls}-date`)}>
<div className={classNames(`${prefixCls}-label`)}>时间选择</div> <div className={classNames(`${prefixCls}-label`)}>时间选择</div>
<Radio.Group value={timeValue} onChange={onTimeSetChange}> <Radio.Group value={timeValue} onChange={onTimeSetChange}>
<Radio.Button value="customer">自定义</Radio.Button> <Radio.Button value="customer">自定义</Radio.Button>
<Radio.Button value="contrast">同期对比</Radio.Button> {
!grid ? <Radio.Button value="contrast">同期对比</Radio.Button> : ''
}
</Radio.Group> </Radio.Group>
{timeValue === 'customer' && ( // 自定义 {timeValue === 'customer' && ( // 自定义
<> <>
<TimeRangePicker <TimeRangePicker
format={'YYYY-MM-DD HH:mm'}
onChange={onCustomerTimeChange} onChange={onCustomerTimeChange}
value={customerChecked} value={customerChecked}
dataSource={timeList} dataSource={timeList.filter(item => {
if (lineDataType === '原始曲线') return item.key !== 'oneMonth';
return true
})}
/> />
<RangePicker <RangePicker
format={'YYYY-MM-DD HH:mm'}
className={classNames(`${prefixCls}-custime-customer`)} className={classNames(`${prefixCls}-custime-customer`)}
onChange={onCustomerRangeChange} onChange={onCustomerRangeChange}
value={customerTime} value={dates || customerTime}
showTime onCalendarChange={(val) => {
console.log('val: ', val);
setDates(val);
}}
onOpenChange={(open) => {
if (open) {
setDates([null, null]);
} else {
setDates(null);
}
}}
disabledDate={(current) => {
if (timeValue !== 'customer') return false;
let _days = lineDataType === '原始曲线' ? OriginMaxDays : CharacteristicMaxDays;
if (!dates) {
return false;
}
const tooLate = dates[0] && current.diff(dates[0], 'days') > _days;
const tooEarly = dates[1] && dates[1].diff(current, 'days') > _days;
return !!tooEarly || !!tooLate;
}}
showTime={{
format: 'YYYY-MM-DD HH:mm',
minuteStep: 10
}}
/> />
</> </>
)} )}
{timeValue === 'contrast' && ( // 同期对比 {timeValue === 'contrast' && ( // 同期对比
<> <>
<Select value={contrastOption} style={{width: 60}} onChange={onContrastChange}> {
<Option value="day"></Option> lineDataType !== '原始曲线' &&
<Option value="month"></Option> <Select value={contrastOption} style={{width: 60}} onChange={onContrastChange}>
</Select> <Option value="day"></Option>
<Option value="month"></Option>
</Select>
}
{/*增加快捷日期*/} {/*增加快捷日期*/}
{ {
lineDataType !== '原始曲线' &&
deviceParams?.length === 1 && deviceParams?.[0]?.sensors?.split(',').length === 1 ? deviceParams?.length === 1 && deviceParams?.[0]?.sensors?.split(',').length === 1 ?
<Radio.Group value={shortcutsValue} onChange={onShortcutsChange}> <Radio.Group value={shortcutsValue} onChange={onShortcutsChange}>
{ {
...@@ -544,7 +582,7 @@ const HistoryView = (props) => { ...@@ -544,7 +582,7 @@ const HistoryView = (props) => {
)} )}
</div> </div>
); );
}; }, [timeValue, customerChecked, lineDataType, datePickerArr, deviceParams, dates, customerTime, chartDataSource]);
// 曲线设置项选择/取消 // 曲线设置项选择/取消
const onCheckboxChange = (e, key, showJustLine) => { const onCheckboxChange = (e, key, showJustLine) => {
...@@ -587,7 +625,8 @@ const HistoryView = (props) => { ...@@ -587,7 +625,8 @@ const HistoryView = (props) => {
let _endDate = dateRange[0]?.dateTo; let _endDate = dateRange[0]?.dateTo;
let diffDays = moment(_endDate).diff(moment(_startDate), 'days'); let diffDays = moment(_endDate).diff(moment(_startDate), 'days');
if (_val === '原始曲线' && diffDays > 7) { if (_val === '原始曲线' && diffDays > 7) {
return message.info('查阅原始曲线时,请选择小于或等于7天的时间间隔'); message.info('查阅原始曲线时,需选择小于或等于7天的时间间隔,已自动切换为近一周');
setCustomerChecked('oneWeek');
} }
setLineDataType(_val) setLineDataType(_val)
}; };
...@@ -964,7 +1003,7 @@ const HistoryView = (props) => { ...@@ -964,7 +1003,7 @@ const HistoryView = (props) => {
const tableMemo = useMemo(() => { const tableMemo = useMemo(() => {
return <> return <>
<div className={`${prefixCls}-options`}> <div className={`${prefixCls}-options`}>
{renderTimeOption()} {renderTimeOption}
{renderCurveOption()} {renderCurveOption()}
</div> </div>
<div className={`${prefixCls}-content`}> <div className={`${prefixCls}-content`}>
...@@ -1001,7 +1040,7 @@ const HistoryView = (props) => { ...@@ -1001,7 +1040,7 @@ const HistoryView = (props) => {
return ( return (
<> <>
<div className={`${prefixCls}-options`}> <div className={`${prefixCls}-options`}>
{renderTimeOption()} {renderTimeOption}
{renderCurveOption( {renderCurveOption(
true, true,
deviceParams?.length === 1 && deviceParams?.[0]?.sensors?.split(',').length === 1, deviceParams?.length === 1 && deviceParams?.[0]?.sensors?.split(',').length === 1,
...@@ -1020,7 +1059,7 @@ const HistoryView = (props) => { ...@@ -1020,7 +1059,7 @@ const HistoryView = (props) => {
deviceAlarmSchemes={deviceAlarmSchemes} deviceAlarmSchemes={deviceAlarmSchemes}
/> />
) : ( ) : (
<SimgleChart <SingleChart
showBoxOption={showBoxOption} showBoxOption={showBoxOption}
lineDataType={lineDataType} lineDataType={lineDataType}
curveCenter={curveCenter} curveCenter={curveCenter}
......
...@@ -3,7 +3,7 @@ import {ConfigProvider} from "antd"; ...@@ -3,7 +3,7 @@ import {ConfigProvider} from "antd";
import {Selector, Checkbox, Space} from 'antd-mobile/es'; import {Selector, Checkbox, Space} from 'antd-mobile/es';
import moment from "moment"; import moment from "moment";
import {getDeviceAlarmScheme, getHistoryInfo} from "./apis"; import {getDeviceAlarmScheme, getHistoryInfo} from "./apis";
import SimgleChart from "./SingleChart"; import SingleChart from "./SingleChart";
import {handlePx} from "./utils"; import {handlePx} from "./utils";
import styles from './index.less'; import styles from './index.less';
...@@ -171,7 +171,7 @@ const MobileHistoryChart = ( ...@@ -171,7 +171,7 @@ const MobileHistoryChart = (
</Checkbox.Group> </Checkbox.Group>
</div> </div>
<div style={{width: '100%', flex: 1}}> <div style={{width: '100%', flex: 1}}>
<SimgleChart <SingleChart
showBoxOption={showBoxOption} showBoxOption={showBoxOption}
curveCenter={options.curveCenter} curveCenter={options.curveCenter}
showGridLine={chartGrid} showGridLine={chartGrid}
......
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