865
This commit is contained in:
parent
cc62551c92
commit
a23a2dffc6
@ -31,12 +31,13 @@ const LockBadge = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
// Функция для подсветки текста
|
// Функция для подсветки текста
|
||||||
const highlightText = (text, searchQuery) => {
|
const highlightText = (text, searchQueries) => {
|
||||||
if (!searchQuery || !text) return text;
|
if (!text) return text;
|
||||||
|
const cleanSearchQueries = searchQueries.filter(q => (q !== undefined && q !== ''));
|
||||||
const escapedQuery = searchQuery.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
if (cleanSearchQueries.length == 0) return text;
|
||||||
const regex = new RegExp(`(${escapedQuery})`, 'gi');
|
|
||||||
|
|
||||||
|
const escapedQueries = cleanSearchQueries.map(query => query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
|
||||||
|
const regex = new RegExp(`(${ escapedQueries.join('|')})`, 'gi');
|
||||||
const parts = text.split(regex);
|
const parts = text.split(regex);
|
||||||
|
|
||||||
return parts.map((part, index) =>
|
return parts.map((part, index) =>
|
||||||
@ -89,7 +90,7 @@ const formatNumber = (value, asInteger = false) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const Cell = React.memo(({ cell, row, column, onClick, globalFilter, backgroundColor, color, isEditable }) => {
|
const Cell = React.memo(({ cell, row, column, onClick, globalFilter, columnFilter, backgroundColor, color, isEditable }) => {
|
||||||
const { lockedCells } = useRealtime();
|
const { lockedCells } = useRealtime();
|
||||||
const cellKey = `${row.id}_${column.id}`;
|
const cellKey = `${row.id}_${column.id}`;
|
||||||
|
|
||||||
@ -105,9 +106,10 @@ const Cell = React.memo(({ cell, row, column, onClick, globalFilter, backgroundC
|
|||||||
}
|
}
|
||||||
|
|
||||||
const highlightedContent = useMemo(() => {
|
const highlightedContent = useMemo(() => {
|
||||||
return highlightText(textValue, globalFilter);
|
return highlightText(textValue, [globalFilter, columnFilter]);
|
||||||
}, [textValue, globalFilter]);
|
}, [textValue, globalFilter]);
|
||||||
|
|
||||||
|
|
||||||
// Базовые стили для заблокированной ячейки
|
// Базовые стили для заблокированной ячейки
|
||||||
const lockedStyles = isLocked ? {
|
const lockedStyles = isLocked ? {
|
||||||
border: '2px solid #e0e0e0',
|
border: '2px solid #e0e0e0',
|
||||||
|
|||||||
@ -229,6 +229,12 @@ const RealtimeTable = ({ formType, formId, sheetName, direction, year }) => {
|
|||||||
minHeight: '1px',
|
minHeight: '1px',
|
||||||
maxHeight: '1px',
|
maxHeight: '1px',
|
||||||
visibility: 'hidden',
|
visibility: 'hidden',
|
||||||
|
'& svg': {
|
||||||
|
height: '1px',
|
||||||
|
minHeight: '1px',
|
||||||
|
maxHeight: '1px',
|
||||||
|
visibility: 'hidden',
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
muiTablePaperProps: getTablePaperStyles(),
|
muiTablePaperProps: getTablePaperStyles(),
|
||||||
|
|||||||
@ -313,10 +313,10 @@ const FilterCell = ({ column, table }) => {
|
|||||||
onChange={(e) => handleFilterChange(e.target.value)}
|
onChange={(e) => handleFilterChange(e.target.value)}
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
padding: '4px 6px',
|
padding: '0.25rem 0.375rem',
|
||||||
fontSize: '11px',
|
fontSize: '0.6875rem',
|
||||||
border: '1px solid #ddd',
|
border: '1px solid #ddd',
|
||||||
borderRadius: '4px',
|
borderRadius: '0.25rem',
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@ -330,23 +330,30 @@ const FilterCell = ({ column, table }) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
case 'range': {
|
case 'range': {
|
||||||
// Для диапазона можно реализовать два поля
|
|
||||||
const [min, max] = column.getFilterValue() || ['', ''];
|
const [min, max] = column.getFilterValue() || ['', ''];
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex', gap: '4px' }}>
|
<div style={{ display: 'flex', gap: '0.25rem' }}> {/* 4px */}
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
placeholder="От"
|
placeholder="От"
|
||||||
value={min}
|
value={min}
|
||||||
onChange={(e) => column.setFilterValue([e.target.value, max])}
|
onChange={(e) => column.setFilterValue([e.target.value, max])}
|
||||||
style={{ width: '50%', padding: '4px', fontSize: '11px' }}
|
style={{
|
||||||
|
width: '50%',
|
||||||
|
padding: '0.25rem',
|
||||||
|
fontSize: '0.6875rem'
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
placeholder="До"
|
placeholder="До"
|
||||||
value={max}
|
value={max}
|
||||||
onChange={(e) => column.setFilterValue([min, e.target.value])}
|
onChange={(e) => column.setFilterValue([min, e.target.value])}
|
||||||
style={{ width: '50%', padding: '4px', fontSize: '11px' }}
|
style={{
|
||||||
|
width: '50%',
|
||||||
|
padding: '0.25rem',
|
||||||
|
fontSize: '0.6875rem'
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -361,10 +368,10 @@ const FilterCell = ({ column, table }) => {
|
|||||||
placeholder="Поиск..."
|
placeholder="Поиск..."
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
padding: '4px 6px',
|
padding: '0.25rem 0.375rem',
|
||||||
fontSize: '11px',
|
fontSize: '0.6875rem',
|
||||||
border: '1px solid #ddd',
|
border: '1px solid #ddd',
|
||||||
borderRadius: '4px',
|
borderRadius: '0.25rem',
|
||||||
boxSizing: 'border-box',
|
boxSizing: 'border-box',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -112,6 +112,7 @@ export const getTableColumns = ({
|
|||||||
globalFilter={
|
globalFilter={
|
||||||
table.getState().globalFilter
|
table.getState().globalFilter
|
||||||
}
|
}
|
||||||
|
columnFilter={table.getState().columnFilters?.find(f => f.id === column.id)?.value}
|
||||||
isEditable={row.original?.row_type === 'INPUT' || false}
|
isEditable={row.original?.row_type === 'INPUT' || false}
|
||||||
backgroundColor={columnColors[column.id]?.color_type?.[row.original?.row_type || row.row_type]}
|
backgroundColor={columnColors[column.id]?.color_type?.[row.original?.row_type || row.row_type]}
|
||||||
color={columnColors[column.id]?.color_type?.['COLOR']}
|
color={columnColors[column.id]?.color_type?.['COLOR']}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user