Compare commits
No commits in common. "f27ea41875bcc1f699232e9c659a31ab3642308c" and "b07e02e643b6a26067bce3e6d6d7edbef398ff9b" have entirely different histories.
f27ea41875
...
b07e02e643
@ -30,28 +30,6 @@ const LockBadge = styled.div`
|
|||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Функция для определения яркости цвета
|
|
||||||
const getColorBrightness = (hexColor) => {
|
|
||||||
if (!hexColor) return 255;
|
|
||||||
|
|
||||||
const color = hexColor.replace('#', '');
|
|
||||||
|
|
||||||
let r, g, b;
|
|
||||||
if (color.length === 3) {
|
|
||||||
r = parseInt(color[0] + color[0], 16);
|
|
||||||
g = parseInt(color[1] + color[1], 16);
|
|
||||||
b = parseInt(color[2] + color[2], 16);
|
|
||||||
} else if (color.length === 6) {
|
|
||||||
r = parseInt(color.substring(0, 2), 16);
|
|
||||||
g = parseInt(color.substring(2, 4), 16);
|
|
||||||
b = parseInt(color.substring(4, 6), 16);
|
|
||||||
} else {
|
|
||||||
return 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (0.299 * r + 0.587 * g + 0.114 * b);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Функция для подсветки текста
|
// Функция для подсветки текста
|
||||||
const highlightText = (text, searchQueries) => {
|
const highlightText = (text, searchQueries) => {
|
||||||
if (!text) return text;
|
if (!text) return text;
|
||||||
@ -82,35 +60,6 @@ const highlightText = (text, searchQueries) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const highlightWithFormatting = (originalValue, formattedValue, searchQueries) => {
|
|
||||||
if (!originalValue && originalValue !== 0) return formattedValue;
|
|
||||||
|
|
||||||
const cleanSearchQueries = searchQueries.filter(q => (q !== undefined && q !== ''));
|
|
||||||
if (cleanSearchQueries.length == 0) return formattedValue;
|
|
||||||
|
|
||||||
const originalString = String(originalValue);
|
|
||||||
const escapedQueries = cleanSearchQueries.map(query => query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
|
||||||
const regex = new RegExp(`(${escapedQueries.join('|')})`, 'gi');
|
|
||||||
|
|
||||||
if (!regex.test(originalString)) {
|
|
||||||
return formattedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<mark
|
|
||||||
style={{
|
|
||||||
backgroundColor: '#ffeb3b',
|
|
||||||
color: '#000',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
padding: '0 2px',
|
|
||||||
borderRadius: '2px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{formattedValue}
|
|
||||||
</mark>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const INTEGER_COLUMN_IDS = new Set([
|
const INTEGER_COLUMN_IDS = new Set([
|
||||||
'data.header.num_group',
|
'data.header.num_group',
|
||||||
'data.nomenclature_group_id',
|
'data.nomenclature_group_id',
|
||||||
@ -148,42 +97,34 @@ const Cell = React.memo(({ cell, row, column, onClick, globalFilter, columnFilte
|
|||||||
const isLocked = lockedCells.includes(cellKey);
|
const isLocked = lockedCells.includes(cellKey);
|
||||||
|
|
||||||
const cellValue = cell.getValue();
|
const cellValue = cell.getValue();
|
||||||
let originalValue = cellValue;
|
let textValue = String(cellValue || '');
|
||||||
let displayValue = String(cellValue || '');
|
|
||||||
|
|
||||||
const isNumeric = !isNaN(Number(cellValue)) && cellValue !== null && cellValue !== undefined && cellValue !== '';
|
const isNumeric = !isNaN(Number(cellValue)) && cellValue !== null && cellValue !== undefined && cellValue !== '';
|
||||||
if (isNumeric) {
|
if (isNumeric) {
|
||||||
const asInteger = INTEGER_COLUMN_IDS.has(column.id);
|
const asInteger = INTEGER_COLUMN_IDS.has(column.id);
|
||||||
displayValue = formatNumber(cellValue, asInteger);
|
textValue = formatNumber(cellValue, asInteger);
|
||||||
}
|
}
|
||||||
|
|
||||||
const highlightedContent = useMemo(() => {
|
const highlightedContent = useMemo(() => {
|
||||||
if (!isNumeric) {
|
return highlightText(textValue, [globalFilter, columnFilter]);
|
||||||
return highlightText(displayValue, [globalFilter, columnFilter]);
|
}, [textValue, globalFilter]);
|
||||||
}
|
|
||||||
return highlightWithFormatting(originalValue, displayValue, [globalFilter, columnFilter]);
|
|
||||||
}, [originalValue, displayValue, globalFilter, columnFilter, isNumeric]);
|
|
||||||
|
|
||||||
// Определяем цвет текста на основе яркости фона
|
|
||||||
const getTextColor = () => {
|
|
||||||
const brightness = getColorBrightness(backgroundColor);
|
|
||||||
|
|
||||||
// Если яркость меньше 128 (темный фон) - используем белый текст, иначе черный
|
|
||||||
return brightness < 128 ? '#ffffff' : '#000000';
|
|
||||||
};
|
|
||||||
|
|
||||||
// Базовые стили для заблокированной ячейки
|
// Базовые стили для заблокированной ячейки
|
||||||
const lockedStyles = isLocked ? {
|
const lockedStyles = isLocked ? {
|
||||||
border: '2px solid #e0e0e0',
|
border: '2px solid #e0e0e0',
|
||||||
backgroundColor: '#f5f5f5',
|
backgroundColor: '#f5f5f5',
|
||||||
|
color: '#999999',
|
||||||
cursor: 'not-allowed',
|
cursor: 'not-allowed',
|
||||||
opacity: 0.85,
|
opacity: 0.85,
|
||||||
} : {};
|
} : {};
|
||||||
|
|
||||||
|
// Если isEditable false, добавляем дополнительные стили
|
||||||
|
const editableStyles = !isEditable ? {
|
||||||
// Определяем финальный цвет текста
|
border: '2px solid #d3d3d3',
|
||||||
const finalTextColor = isLocked ? '#999999' : getTextColor();
|
color: backgroundColor?.toLowerCase() === '#933634' ? '#ffffff' : '#525252',
|
||||||
|
cursor: 'not-allowed',
|
||||||
|
} : {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -203,8 +144,9 @@ const Cell = React.memo(({ cell, row, column, onClick, globalFilter, columnFilte
|
|||||||
border: '2px solid transparent',
|
border: '2px solid transparent',
|
||||||
padding: '8px',
|
padding: '8px',
|
||||||
backgroundColor: isLocked ? '#f5f5f5' : backgroundColor,
|
backgroundColor: isLocked ? '#f5f5f5' : backgroundColor,
|
||||||
color: finalTextColor,
|
color: isLocked ? '#999999' : color,
|
||||||
...lockedStyles,
|
...lockedStyles,
|
||||||
|
...editableStyles,
|
||||||
}}
|
}}
|
||||||
onClick={isLocked ? undefined : onClick}
|
onClick={isLocked ? undefined : onClick}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -360,7 +360,7 @@ const ModalEditAddVsp = ({
|
|||||||
Региональный филиал <span style={{ color: 'red' }}>*</span>
|
Региональный филиал <span style={{ color: 'red' }}>*</span>
|
||||||
</FieldLabel>
|
</FieldLabel>
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
options={ssps.filter(s => s.is_active)}
|
options={ssps}
|
||||||
getOptionLabel={(option) => option.title || option.name || ''}
|
getOptionLabel={(option) => option.title || option.name || ''}
|
||||||
value={selectedSsp}
|
value={selectedSsp}
|
||||||
onChange={handleSspChange}
|
onChange={handleSspChange}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user