From 32edb46215ec01876770aef604c0318a0d12c8f9 Mon Sep 17 00:00:00 2001 From: lb Date: Fri, 3 Nov 2023 13:32:50 +0800 Subject: [PATCH] update basic structrue of graphbase --- .../能耗分析/GraphBase/index.jsx | 66 ++++++++++++++++- .../能耗分析/GraphBase/index.module.css | 71 ++++++++++++++++++- .../能耗分析/一氧化氮/index.jsx | 11 ++- .../能耗分析/烟气处理/index.jsx | 2 +- .../能耗分析/能源/index.jsx | 2 +- src/hooks/useSlider.js | 2 +- 6 files changed, 144 insertions(+), 10 deletions(-) diff --git a/src/components/模块组件/能耗分析/GraphBase/index.jsx b/src/components/模块组件/能耗分析/GraphBase/index.jsx index 0a29756..4d4b77b 100644 --- a/src/components/模块组件/能耗分析/GraphBase/index.jsx +++ b/src/components/模块组件/能耗分析/GraphBase/index.jsx @@ -1,6 +1,8 @@ // TODO: 通用组件 - 按钮 菜单控制层 import useIcon from '../../../../hooks/useIcon'; import cls from './index.module.css'; +import { useMemo, useState } from 'react'; +import { Switch, Radio } from 'antd'; function choseBg(size) { const [width, height] = size; @@ -26,9 +28,34 @@ function choseBg(size) { function GraphBase(props) { const size = props.size || ['middle', 'middle']; const bgClass = choseBg(size); - const { icon, title, desc, switcher, onSwitch, dateOptions, onDateChange } = - props; + const { + icon, + title, + desc, + switchOptions, + onSwitch, + dateOptions, + onDateChange, + legend, + } = props; const iconSrc = useIcon(icon); + const colors = useMemo(() => ['#ffd160', '#2760ff', '#15e8f5'], []); + const [showChart, setShowChart] = useState(true); + + let dto = null; + + if (dateOptions) { + dto = dateOptions.map((item) => ( + + {item} + + )); + } + + function handleSwitchChange(v) { + v ? setShowChart(true) : setShowChart(false); + onSwitch(v); + } return (

{title}

-
{props.children}
+
+ {desc &&
{desc}
} + {switchOptions && ( +
+ + {showChart && 历史详情} + {!showChart && 实时流量} +
+ )} + {legend && showChart && ( +
+ {legend.map((item, index) => ( +
+ + {item} +
+ ))} +
+ )} + {dateOptions && ( + onDateChange(target.value)} + > + {dto} + + )} + {props.children} +
); } diff --git a/src/components/模块组件/能耗分析/GraphBase/index.module.css b/src/components/模块组件/能耗分析/GraphBase/index.module.css index 450dc0e..58c9160 100644 --- a/src/components/模块组件/能耗分析/GraphBase/index.module.css +++ b/src/components/模块组件/能耗分析/GraphBase/index.module.css @@ -64,7 +64,7 @@ 'Source Han Sans SC', 'Noto Sans CJK SC', 'WenQuanYi Micro Hei', sans-serif; margin: 0; margin-left: 6px; - font-size: 18px; + font-size: 20px; color: #fff; letter-spacing: 2px; font-weight: 500; @@ -73,4 +73,73 @@ .graphBaseContent { height: 1px; flex: 1; + background: #fff3; +} + +.graphBaseDesc { + position: absolute; + top: 25px; + left: 150px; + font-size: 19px; + color: #76fff9; +} + +.graphBaseSwitch { + position: absolute; + top: 30px; + left: 258px; + display: flex; + align-items: center; +} + +.graphBaseDate { + position: absolute; + right: 0; + top: 24px; + color: #fff; + margin-right: 24px; +} + +.radioGroup { + user-select: none; +} + +.radioGroup * { + border: none !important; + border-radius: 0 !important; +} + +.radioGroup *:focus-within { + box-shadow: none !important; +} + +.radioGroup *::before { + width: 0 !important; +} + +.switchLabel { + color: white; + margin-left: 6px; +} + +.legend { + position: absolute; + top: 30px; + left: 360px; + color: #fff; + display: flex; + align-items: center; +} + +.legendItem { + display: flex; + align-items: center; + margin-left: 8px; +} + +.lengedItemPrefix { + width: 12px; + height: 12px; + border-radius: 2px; + margin-right: 4px; } diff --git a/src/components/模块组件/能耗分析/一氧化氮/index.jsx b/src/components/模块组件/能耗分析/一氧化氮/index.jsx index 3a89a82..af32bdc 100644 --- a/src/components/模块组件/能耗分析/一氧化氮/index.jsx +++ b/src/components/模块组件/能耗分析/一氧化氮/index.jsx @@ -1,18 +1,23 @@ import GraphBase from '../GraphBase'; function NO(props) { - function handleSwitch() {} + function handleSwitch(v) { + console.log('switched ', v); + } - function handleDateChange() {} + function handleDateChange(v) { + console.log('date ', v); + } return ( diff --git a/src/components/模块组件/能耗分析/烟气处理/index.jsx b/src/components/模块组件/能耗分析/烟气处理/index.jsx index c1f41ac..94b79bd 100644 --- a/src/components/模块组件/能耗分析/烟气处理/index.jsx +++ b/src/components/模块组件/能耗分析/烟气处理/index.jsx @@ -5,7 +5,7 @@ function SmokeHandle(props) { return (
{ }; return (
- +
); };