From be5fbe1c0102c7a6e76d8b2368405b63c9c90355 Mon Sep 17 00:00:00 2001 From: lb Date: Thu, 25 Jan 2024 09:10:00 +0800 Subject: [PATCH] update --- .../Energy/EnergeCostRealtime/index.jsx | 88 +++++++++++++++ .../EnergeCostRealtime/index.module.scss | 33 ++++++ .../Common/Energy/EnergyCostChart/index.jsx | 28 ++++- .../Energy/EnergyCostChart/index.module.css | 104 +++++++++--------- src/components/Common/Energy/index.jsx | 83 +------------- .../components/GoodRateChart/index.jsx | 7 +- 6 files changed, 208 insertions(+), 135 deletions(-) create mode 100644 src/components/Common/Energy/EnergeCostRealtime/index.jsx create mode 100644 src/components/Common/Energy/EnergeCostRealtime/index.module.scss diff --git a/src/components/Common/Energy/EnergeCostRealtime/index.jsx b/src/components/Common/Energy/EnergeCostRealtime/index.jsx new file mode 100644 index 0000000..04c4748 --- /dev/null +++ b/src/components/Common/Energy/EnergeCostRealtime/index.jsx @@ -0,0 +1,88 @@ +import cls from "./index.module.scss"; +import { useSelector } from "react-redux"; + +const EnergyCostRealtime = () => { + const energyInfo = useSelector((state) => state.energy?.info); + + return ( +
+
+ + 余热发电 + + + {(+energyInfo?.elecQty1)?.toFixed(2) || 0}kWh + +
+
+
+ + 水耗量 + + + {(+energyInfo?.waterQty)?.toFixed(2) || 0}Km³ + +
+
+ + 天然气I + + + {energyInfo?.ngQty1 || "0Nm³"} + +
+
+ + 电耗量 + + + {(+energyInfo?.elecQty2)?.toFixed(2) || 0}kWh + +
+
+ + 天然气II + + + {energyInfo?.ngQty2 || "0Nm³"} + +
+
+
+ ); +}; + +export default EnergyCostRealtime; diff --git a/src/components/Common/Energy/EnergeCostRealtime/index.module.scss b/src/components/Common/Energy/EnergeCostRealtime/index.module.scss new file mode 100644 index 0000000..f838cae --- /dev/null +++ b/src/components/Common/Energy/EnergeCostRealtime/index.module.scss @@ -0,0 +1,33 @@ +.cost__info { + margin-top: 4px; + margin-bottom: 12px; + + div { + flex-grow: 1; + } +} + +.info__item { + border-radius: 2px; + color: hsl(0, 0%, 100%, 0.9); + box-shadow: inset 0 0 17px 0px hsla(0, 0%, 100%, 0.15); + // min-width: 190px; + // height: 43px; + font-size: 14px; + // letter-spacing: 1.43px; + line-height: 40px; + padding-left: 12px; + // text-align: center; + user-select: none; +} + +.hAuto { + height: auto; +} + +.info__item_groups { + margin-left: 8px; + display: grid; + grid-template-columns: 1fr 1fr; + gap: 8px; +} diff --git a/src/components/Common/Energy/EnergyCostChart/index.jsx b/src/components/Common/Energy/EnergyCostChart/index.jsx index f9f7945..c05f416 100644 --- a/src/components/Common/Energy/EnergyCostChart/index.jsx +++ b/src/components/Common/Energy/EnergyCostChart/index.jsx @@ -14,6 +14,12 @@ const EnergyCostChart = (props) => { const [source, setSource] = useState("elec"); const [period, setPeriod] = useState("week"); + const [timestr, setTimestr] = useState( + dayjs().subtract(7, "day").format("YYYY.MM.DD") + + " - " + + dayjs().subtract(1, "day").format("YYYY.MM.DD") + ); + const currentTrend = source == "elec" ? elecTrend : source == "gasi" ? gasITrend : gasIITrend; @@ -26,12 +32,29 @@ const EnergyCostChart = (props) => { function handleDateChange(value) { setPeriod( { - 日: "day", 周: "week", 月: "month", 年: "year", }[value] ); + setTimestr( + { + 年: + dayjs().subtract(1, "year").endOf("year").format("YYYY.MM.") + + "29 - " + + dayjs().endOf("year").format("YYYY.MM.") + + "28", + 周: + dayjs().subtract(7, "day").format("YYYY.MM.DD") + + " - " + + dayjs().subtract(1, "day").format("YYYY.MM.DD"), + 月: + dayjs().subtract(1, "month").format("YYYY.MM.") + + "29 - " + + dayjs().format("YYYY.MM.") + + "28", + }[value] + ); } return ( @@ -74,6 +97,9 @@ const EnergyCostChart = (props) => { 年 */} + +
{timestr}
+