From bb74f511af49095bd18ea8875a3462bc43a549e6 Mon Sep 17 00:00:00 2001 From: PotapovaA Date: Mon, 22 Jun 2026 13:46:56 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BD=D0=B0=D0=BD=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=D1=8B=D0=B9=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=8F=D1=87=D0=B5=D0=B5=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RealtimeTable/Cell/Cell/Cell.jsx | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/web/src/components/RealtimeTable/Cell/Cell/Cell.jsx b/web/src/components/RealtimeTable/Cell/Cell/Cell.jsx index 7212e7f..d3682b2 100644 --- a/web/src/components/RealtimeTable/Cell/Cell/Cell.jsx +++ b/web/src/components/RealtimeTable/Cell/Cell/Cell.jsx @@ -4,7 +4,6 @@ import styled from '@emotion/styled'; import { useRealtime } from '../../contexts/RealtimeContext'; import { toast } from 'react-toastify'; - const ContainerForText = styled.span` display: -webkit-box; -webkit-box-orient: vertical; @@ -43,9 +42,30 @@ const highlightText = (text, searchQuery) => { ); }; +// Функция для форматирования числа в финансовый формат +const formatNumber = (value) => { + if (value === null || value === undefined || value === '') return String(value || ''); + + const num = Number(value); + if (isNaN(num)) return String(value); + + // Форматируем число с 1 знаком после запятой и разделением по 3 цифры + return num.toLocaleString('ru-RU', { + minimumFractionDigits: 1, + maximumFractionDigits: 1, + useGrouping: true, + }); +}; + const Cell = React.memo(({ cell, row, column, onClick, globalFilter, backgroundColor, color, isEditable }) => { const cellValue = cell.getValue(); - const textValue = String(cellValue || ''); + let textValue = String(cellValue || ''); + + // Проверяем, является ли значение числом, и форматируем его + const isNumeric = !isNaN(Number(cellValue)) && cellValue !== null && cellValue !== undefined && cellValue !== ''; + if (isNumeric) { + textValue = formatNumber(cellValue); + } // Подсвечиваем текст с учетом поискового запроса const highlightedContent = useMemo(() => { @@ -58,7 +78,6 @@ const Cell = React.memo(({ cell, row, column, onClick, globalFilter, backgroundC cursor: 'not-allowed', } : {}; - return (