Commit a1b84078 authored by 陈龙's avatar 陈龙

feat: 优化历史曲线

parent 8c013759
...@@ -285,14 +285,20 @@ const HistoryView = (props) => { ...@@ -285,14 +285,20 @@ const HistoryView = (props) => {
const [chartType, setChartType] = useState('lineChart'); const [chartType, setChartType] = useState('lineChart');
const [showBoxOption, setShowBoxOption] = useState(true); const [showBoxOption, setShowBoxOption] = useState(true);
const [lineDataType, setLineDataType] = useState('特征曲线'); const [lineDataType, setLineDataType] = useState('特征曲线');
// 同期对比快捷键
// shortcutsValue
// onShortcutsChange
const [shortcutsValue, setShortcutsValue] = useState('');
const [shortcutsDatePickerArr, setShortcutsDatePickerArr] = useState([]);
// 选择的时间范围值 // 选择的时间范围值
const dateRange = useMemo(() => { const dateRange = useMemo(() => {
if (timeValue === 'customer') { if (timeValue === 'customer') {
return updateTime(customerChecked || customerTime); return updateTime(customerChecked || customerTime);
} else { } else {
return handleBatchTime(datePickerArr, contrastOption); let _dateArr = shortcutsValue ? shortcutsDatePickerArr : datePickerArr;
return handleBatchTime(_dateArr, contrastOption);
} }
}, [contrastOption, customerChecked, customerTime, datePickerArr, timeValue]); }, [contrastOption, customerChecked, customerTime, datePickerArr, timeValue, shortcutsValue]);
const configDependence = checkboxData const configDependence = checkboxData
.filter((item) => ['curveCenter', 'chartGrid'].indexOf(item.key) === -1) .filter((item) => ['curveCenter', 'chartGrid'].indexOf(item.key) === -1)
...@@ -326,10 +332,7 @@ const HistoryView = (props) => { ...@@ -326,10 +332,7 @@ const HistoryView = (props) => {
const chartGrid = checkboxData.find((item) => item.key === 'chartGrid')?.checked; const chartGrid = checkboxData.find((item) => item.key === 'chartGrid')?.checked;
return [curveCenter, chartGrid]; return [curveCenter, chartGrid];
}, [checkboxData]); }, [checkboxData]);
// 同期对比快捷键
// shortcutsValue
// onShortcutsChange
const [shortcutsValue, setShortcutsValue] = useState('');
// 自定义模式: 快速选择 // 自定义模式: 快速选择
const onCustomerTimeChange = (key) => { const onCustomerTimeChange = (key) => {
if (key === 'oneMonth' && lineDataType === '原始曲线') { if (key === 'oneMonth' && lineDataType === '原始曲线') {
...@@ -360,9 +363,10 @@ const HistoryView = (props) => { ...@@ -360,9 +363,10 @@ const HistoryView = (props) => {
// 同期对比模式: 选择(日/月) // 同期对比模式: 选择(日/月)
const onContrastChange = (value) => { const onContrastChange = (value) => {
if (value === 'month') { if (value === 'month') {
message.info('月模式数据量较大,不支持原始曲线模式,已切换为特征曲线') if (lineDataType === '原始曲线') message.info('月模式数据量较大,不支持原始曲线模式,已切换为特征曲线')
setLineDataType('特征曲线'); setLineDataType('特征曲线');
} }
setShortcutsValue('');
setContrastOption(value); setContrastOption(value);
// 模式为日时,默认对比时间根据defaultDate判断 是昨天、上月、还是去年 // 模式为日时,默认对比时间根据defaultDate判断 是昨天、上月、还是去年
setDatePickerArr([...DefaultDatePicker(value === 'day' && defaultDate ? defaultDate : value)]); setDatePickerArr([...DefaultDatePicker(value === 'day' && defaultDate ? defaultDate : value)]);
...@@ -408,7 +412,8 @@ const HistoryView = (props) => { ...@@ -408,7 +412,8 @@ const HistoryView = (props) => {
// 操作时间就清除掉快捷键选用状态 // 操作时间就清除掉快捷键选用状态
setShortcutsValue(''); setShortcutsValue('');
if (e.target.value === 'customer') { if (e.target.value === 'customer') {
setLineDataType('特征曲线') setLineDataType('特征曲线');
setShortcutsValue('');
} }
setTimeValue(e.target.value); setTimeValue(e.target.value);
if (e.target.value === 'contrast') { if (e.target.value === 'contrast') {
...@@ -444,6 +449,7 @@ const HistoryView = (props) => { ...@@ -444,6 +449,7 @@ const HistoryView = (props) => {
{key: 3, value: moment().subtract(2, 'days')}, {key: 3, value: moment().subtract(2, 'days')},
{key: 4, value: moment().subtract(3, 'days')}, {key: 4, value: moment().subtract(3, 'days')},
{key: 5, value: moment().subtract(4, 'days')}, {key: 5, value: moment().subtract(4, 'days')},
{key: 6, value: moment().subtract(5, 'days')},
] ]
break; break;
case '近3月': case '近3月':
...@@ -460,10 +466,11 @@ const HistoryView = (props) => { ...@@ -460,10 +466,11 @@ const HistoryView = (props) => {
{key: 3, value: moment().subtract(2, 'months')}, {key: 3, value: moment().subtract(2, 'months')},
{key: 4, value: moment().subtract(3, 'months')}, {key: 4, value: moment().subtract(3, 'months')},
{key: 5, value: moment().subtract(4, 'months')}, {key: 5, value: moment().subtract(4, 'months')},
{key: 6, value: moment().subtract(5, 'months')},
] ]
break; break;
} }
setDatePickerArr(_arr); setShortcutsDatePickerArr(_arr);
}; };
const renderTimeOption = () => { const renderTimeOption = () => {
return ( return (
...@@ -511,7 +518,7 @@ const HistoryView = (props) => { ...@@ -511,7 +518,7 @@ const HistoryView = (props) => {
picker={contrastOption} picker={contrastOption}
value={child.value} value={child.value}
onChange={(date, dateString) => onContrastPickerChange(date, dateString, child)} onChange={(date, dateString) => onContrastPickerChange(date, dateString, child)}
style={{width: 130}} style={{width: 130, border: !shortcutsValue ? '1px solid #1890ff' : ''}}
/> />
{datePickerArr.length > 2 && ( {datePickerArr.length > 2 && (
<div <div
...@@ -527,7 +534,7 @@ const HistoryView = (props) => { ...@@ -527,7 +534,7 @@ const HistoryView = (props) => {
)} )}
</div> </div>
))} ))}
{datePickerArr.length < 5 && <PlusCircleOutlined onClick={handleAddDatePicker}/>} {datePickerArr.length < 4 && <PlusCircleOutlined onClick={handleAddDatePicker}/>}
</> </>
)} )}
</div> </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