From 5af996f9e5931254a6fc882aa3b7ccac5f88e52f Mon Sep 17 00:00:00 2001 From: goodmice Date: Thu, 8 Dec 2022 11:48:30 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A1=D1=82=D0=B8=D0=BB=D0=B8=20=D0=B2=D1=8B?= =?UTF-8?q?=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D1=8B=20=D0=B2=20=D0=BE=D1=82?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Deposit/StatisticsADW.jsx | 115 +++++++++++----------------- src/styles/statistics_adw.less | 59 ++++++++++++++ 2 files changed, 103 insertions(+), 71 deletions(-) create mode 100644 src/styles/statistics_adw.less diff --git a/src/pages/Deposit/StatisticsADW.jsx b/src/pages/Deposit/StatisticsADW.jsx index ddde54e..c26d948 100644 --- a/src/pages/Deposit/StatisticsADW.jsx +++ b/src/pages/Deposit/StatisticsADW.jsx @@ -1,19 +1,16 @@ +import { CheckOutlined, StopOutlined, QuestionCircleOutlined, WarningOutlined } from '@ant-design/icons' import { memo, useEffect, useMemo, useState } from 'react' -import { - CheckOutlined, - StopOutlined, - QuestionCircleOutlined, - WarningOutlined, -} from '@ant-design/icons' import { Card, Empty, Popover } from 'antd' -import { getWellTitle, WellView } from '@components/views' import LoaderPortal from '@components/LoaderPortal' -import { DateRangeWrapper, makeNumericColumn, makeNumericRender, makeTextColumn, Table } from '@components/Table' +import { getWellTitle, WellView } from '@components/views' import { invokeWebApiWrapperAsync } from '@components/factory' +import { DateRangeWrapper, makeNumericColumn, makeNumericRender, makeTextColumn, Table } from '@components/Table' import { arrayOrDefault, withPermissions } from '@utils' import { SubsystemOperationTimeService } from '@api' +import '@styles/statistics_adw.less' + const numericRender = makeNumericRender(2) const columns = [ @@ -31,15 +28,6 @@ const getSubsystemState = (subsystem) => { return 'ok' } -const getSubsystemColor = (state) => { - switch (state) { - case 'ok': return '#52c41a' - case 'warn': return '#faad14' - case 'error': return '#ff4d4f' - default: return null - } -} - const getSubsystemIcon = (state) => { switch (state) { case 'ok': return @@ -51,7 +39,7 @@ const getSubsystemIcon = (state) => { const getCardState = (subsystems) => { if (subsystems.length <= 0) return null - const states = subsystems.map((ss) => getSubsystemState(ss)) + const states = subsystems.map(getSubsystemState) if (states.some((state) => state === 'error')) return 'error' if (states.some((state) => state === 'warn')) return 'warn' return 'ok' @@ -61,33 +49,26 @@ const generateSubsystem = (subsystem) => { const state = getSubsystemState(subsystem) return ( -
+
{getSubsystemIcon(state)} {subsystem.subsystemName || subsystem.key}
) } -const onRow = (record) => { - const state = getSubsystemState(record) - if (state === null) return null - const color = getSubsystemColor(state) - return { style: { backgroundColor: color, color: 'white' } } -} +const onRow = (record) => ({ className: `status-${getSubsystemState(record)}` }) +const objectToArray = (obj) => Object.entries(obj).filter(([_, v]) => v).map(([key, v]) => ({ key, ...v })) const GeneralSubsystemStatistics = memo(() => { - const [data, setData] = useState([]) const [isLoading, setIsLoading] = useState(false) const [dates, setDates] = useState([null, null]) + const [data, setData] = useState([]) useEffect(() => { invokeWebApiWrapperAsync( async () => { const data = await SubsystemOperationTimeService.getStatByWell(dates?.[0]?.toISOString(), dates?.[1]?.toISOString()) - const out = arrayOrDefault(data).map(({ well, ...subsystems }) => ({ - well, - subsystems: Object.entries(subsystems).filter(([_, v]) => v).map(([key, v]) => ({ key, ...v })) - })) + const out = arrayOrDefault(data).map(({ well, ...ss }) => ({ well, subsystems: objectToArray(ss) })) setData(out) }, setIsLoading, @@ -96,56 +77,48 @@ const GeneralSubsystemStatistics = memo(() => { ) }, [dates]) - const cards = useMemo(() => { - return data.map((row) => { - const state = getCardState(row.subsystems) + const cards = useMemo(() => data.map((row) => { + const state = getCardState(row.subsystems) - const cardStyle = { - boxShadow: `0 0 5px 2px ${getSubsystemColor(state)}`, - userSelect: 'none', - } + const card = ( + +
+ {state ? row.subsystems.map((ss) => generateSubsystem(ss)) : } +
+
+ ) - const card = ( - -
- {state ? row.subsystems.map((ss) => generateSubsystem(ss)) : } -
-
- ) + if (!state) return card - if (!state) return card - - const detailTitle = ( - <> - Детальная информация по скважине - - - ) - - const detailContent = ( - - ) - - return {card} - }) - }, [data]) + return ( + + Детальная информация по скважине + + + )} + content={( +
+ )} + >{card} + ) + }), [data]) return ( -
-
+
+
Диапазон дат:
-
- {cards} -
+
{cards}
) diff --git a/src/styles/statistics_adw.less b/src/styles/statistics_adw.less new file mode 100644 index 0000000..b03fed3 --- /dev/null +++ b/src/styles/statistics_adw.less @@ -0,0 +1,59 @@ +@ok-color: #52c41a; +@warn-color: #faad14; +@error-color: #ff4d4f; + +.statistics-adw-page { + display: flex; + flex-direction: column; + align-items: stretch; + gap: 20px; + height: 100%; + + & .filter-block { + align-items: center; + padding-left: 15px; + display: flex; + gap: 10px; + } + + & .well-cards { + padding: 15px; + display: flex; + flex-wrap: wrap; + align-items: baseline; + gap: 15px; + + & .subsystem-card { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + + &.status-ok { box-shadow: 0 0 5px 2px @ok-color; } + &.status-warn { box-shadow: 0 0 5px 2px @warn-color; } + &.status-error { box-shadow: 0 0 5px 2px @error-color; } + + & .subsystem-card-body { + display: flex; + flex-direction: column; + gap: 10px; + + & .subsystem-status { + display: flex; + gap: 5px; + align-items: center; + + &.status-ok { color: @ok-color; } + &.status-warn { color: @warn-color; } + &.status-error { color: @error-color; } + } + } + } + } +} + +.ant-table-row { + &.status-ok { background-color: @ok-color; } + &.status-warn { background-color: @warn-color; } + &.status-error { background-color: @error-color; } +}