Merge pull request 'правка добавления строки в 4 форме' (#57) from fix-add-row-program-4-form into test

Reviewed-on: #57
This commit is contained in:
PotapovaA 2026-07-30 17:22:03 +03:00
commit abafe0e9a0
7 changed files with 59 additions and 29 deletions

View File

@ -1,4 +1,4 @@
import React from 'react'; import React, { useMemo } from 'react';
import ColumnResizer from './ColumnResizer'; import ColumnResizer from './ColumnResizer';
import { columnPinningDefault } from '../constants/columnConfig'; import { columnPinningDefault } from '../constants/columnConfig';
@ -149,6 +149,24 @@ const ColumnNumberCell = ({ column, table, selectedColumnId, onColumnSelect }) =
); );
}; };
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 HeaderCell = ({ header, table, onClick, onChangeWidth }) => { const HeaderCell = ({ header, table, onClick, onChangeWidth }) => {
const column = header.column; const column = header.column;
const pinningColumn = getPinnedColumnIds(table); const pinningColumn = getPinnedColumnIds(table);
@ -160,12 +178,16 @@ const HeaderCell = ({ header, table, onClick, onChangeWidth }) => {
const splitGroup = isGroup && isPinned && pinnedBandWidth > 0 && pinnedBandWidth < headerSize; const splitGroup = isGroup && isPinned && pinnedBandWidth > 0 && pinnedBandWidth < headerSize;
const customBgColor = column.columnDef?.muiTableHeadCellProps?.sx?.backgroundColor; const customBgColor = column.columnDef?.muiTableHeadCellProps?.sx?.backgroundColor;
const color = column.columnDef?.muiTableHeadCellProps?.sx?.color || '#000000';
const backgroundColor = customBgColor const backgroundColor = customBgColor
? customBgColor ? customBgColor
: 'rgba(243, 244, 246, 1)'; : 'rgba(243, 244, 246, 1)';
const color = useMemo(() => {
const brightness = getColorBrightness(backgroundColor);
return brightness < 128 ? '#ffffff' : '#000000';
}, [backgroundColor]);
const handleChangeWidth = (deltaWidth) => { const handleChangeWidth = (deltaWidth) => {
const size = header.getSize(); const size = header.getSize();
onChangeWidth(header, size + deltaWidth); onChangeWidth(header, size + deltaWidth);
@ -313,8 +335,8 @@ const FilterCell = ({ column, table }) => {
onChange={(e) => handleFilterChange(e.target.value)} onChange={(e) => handleFilterChange(e.target.value)}
style={{ style={{
width: '100%', width: '100%',
padding: '0.25rem 0.375rem', padding: '0.25rem 0.375rem',
fontSize: '0.6875rem', fontSize: '0.6875rem',
border: '1px solid #ddd', border: '1px solid #ddd',
borderRadius: '0.25rem', borderRadius: '0.25rem',
backgroundColor: 'white', backgroundColor: 'white',
@ -340,8 +362,8 @@ const FilterCell = ({ column, table }) => {
onChange={(e) => column.setFilterValue([e.target.value, max])} onChange={(e) => column.setFilterValue([e.target.value, max])}
style={{ style={{
width: '50%', width: '50%',
padding: '0.25rem', padding: '0.25rem',
fontSize: '0.6875rem' fontSize: '0.6875rem'
}} }}
/> />
<input <input
@ -351,8 +373,8 @@ const FilterCell = ({ column, table }) => {
onChange={(e) => column.setFilterValue([min, e.target.value])} onChange={(e) => column.setFilterValue([min, e.target.value])}
style={{ style={{
width: '50%', width: '50%',
padding: '0.25rem', padding: '0.25rem',
fontSize: '0.6875rem' fontSize: '0.6875rem'
}} }}
/> />
</div> </div>
@ -371,7 +393,7 @@ const FilterCell = ({ column, table }) => {
padding: '0.25rem 0.375rem', padding: '0.25rem 0.375rem',
fontSize: '0.6875rem', fontSize: '0.6875rem',
border: '1px solid #ddd', border: '1px solid #ddd',
borderRadius: '0.25rem', borderRadius: '0.25rem',
boxSizing: 'border-box', boxSizing: 'border-box',
}} }}
/> />

View File

@ -768,7 +768,7 @@ export const config = {
}, },
columns: [ columns: [
{ {
header: ".", header: "",
accessorKey: "field", accessorKey: "field",
columns: [ columns: [
{ {
@ -1469,7 +1469,7 @@ export const config = {
}, },
}, },
{ {
header: "..", header: "",
accessorKey: "field_4", accessorKey: "field_4",
columns: [ columns: [
{ {

View File

@ -1020,7 +1020,7 @@ export const config = {
}, },
}, },
{ {
header: "Платежив 2027 году", header: "Платежи в 2027 году",
accessorKey: "data.contract_summary.future_payments_y1", accessorKey: "data.contract_summary.future_payments_y1",
columnLetter: "Q", columnLetter: "Q",
size: 190, size: 190,
@ -1033,7 +1033,7 @@ export const config = {
}, },
}, },
{ {
header: "Платежив 2028 году", header: "Платежи в 2028 году",
accessorKey: "data.contract_summary.future_payments_y2", accessorKey: "data.contract_summary.future_payments_y2",
columnLetter: "R", columnLetter: "R",
size: 190, size: 190,
@ -2374,7 +2374,7 @@ export const config = {
header: "Сумма (без НДС)", header: "Сумма (без НДС)",
accessorKey: "data.q2.target_change", accessorKey: "data.q2.target_change",
columnLetter: "DE", columnLetter: "DE",
size: 150, size: 300,
filterFn: "contains", filterFn: "contains",
muiTableHeadCellProps: { muiTableHeadCellProps: {
sx: { sx: {
@ -2399,7 +2399,7 @@ export const config = {
header: "Сумма (без НДС)", header: "Сумма (без НДС)",
accessorKey: "data.q2.base_correction", accessorKey: "data.q2.base_correction",
columnLetter: "DF", columnLetter: "DF",
size: 150, size: 300,
filterFn: "contains", filterFn: "contains",
}, },
], ],

View File

@ -308,7 +308,7 @@ export const config = {
}, },
}, },
{ {
header: "ИТОГОПоддержка", header: "ИТОГО Поддержка",
accessorKey: "data.plan.support.year", accessorKey: "data.plan.support.year",
columnLetter: "H", columnLetter: "H",
@ -386,7 +386,7 @@ export const config = {
}, },
}, },
{ {
header: "ИТОГОРазвитие", header: "ИТОГО Развитие",
accessorKey: "data.plan.development.year", accessorKey: "data.plan.development.year",
columnLetter: "M", columnLetter: "M",
size: 150, size: 150,
@ -477,7 +477,7 @@ export const config = {
}, },
}, },
{ {
header: "ИТОГОПоддержка", header: "ИТОГО Поддержка",
accessorKey: "data.approved.support.year", accessorKey: "data.approved.support.year",
columnLetter: "T", columnLetter: "T",
size: 150, size: 150,
@ -554,7 +554,7 @@ export const config = {
}, },
}, },
{ {
header: "ИТОГОРазвитие", header: "ИТОГО Развитие",
accessorKey: "data.approved.development.year", accessorKey: "data.approved.development.year",
columnLetter: "Y", columnLetter: "Y",
size: 150, size: 150,
@ -643,7 +643,7 @@ export const config = {
}, },
}, },
{ {
header: "ИТОГОПоддержка", header: "ИТОГО Поддержка",
accessorKey: "data.fact.support.year", accessorKey: "data.fact.support.year",
columnLetter: "AF", columnLetter: "AF",
size: 150, size: 150,
@ -720,7 +720,7 @@ export const config = {
}, },
}, },
{ {
header: "ИТОГОРазвитие", header: "ИТОГО Развитие",
accessorKey: "data.fact.development.year", accessorKey: "data.fact.development.year",
columnLetter: "AK", columnLetter: "AK",
size: 150, size: 150,

View File

@ -764,7 +764,7 @@ export const config = {
}, },
columns: [ columns: [
{ {
header: ".", header: "",
accessorKey: "field", accessorKey: "field",
columns: [ columns: [
{ {
@ -1487,7 +1487,7 @@ export const config = {
}, },
}, },
{ {
header: "..", header: "",
accessorKey: "field_6", accessorKey: "field_6",
columns: [ columns: [
{ {
@ -3953,7 +3953,7 @@ export const config = {
}, },
}, },
{ {
header: "...", header: "",
accessorKey: "field_40", accessorKey: "field_40",
columns: [ columns: [
{ {

View File

@ -238,9 +238,13 @@ const useRealtimeData = (formId, sheetName, direction, formType, year) => {
}); });
}); });
const unsubscribeProgramAdds = subscribeToProgramAdds((data) => { const unsubscribeProgramAdds = subscribeToProgramAdds((msg) => {
const newRow = data.result[1][0]; let newRow = msg.result[1][0];
setData((prevData) => { setData((prevData) => {
const hasRoot = prevData.length > 0 && prevData[0].row_type === "ROOT";
if (hasRoot) {
newRow = msg.result[1][1];
}
const updateData = structuredClone(prevData); const updateData = structuredClone(prevData);
const [row_type, depth, sort_order, dataRow] = newRow; const [row_type, depth, sort_order, dataRow] = newRow;
const newRowObject = { const newRowObject = {
@ -250,8 +254,11 @@ const useRealtimeData = (formId, sheetName, direction, formType, year) => {
subRows: [], subRows: [],
data: dataRow, data: dataRow,
}; };
const newData = [...updateData, newRowObject]; if (hasRoot) {
return newData; updateData[0].subRows.push(newRowObject);
return updateData;
}
return [...updateData, newRowObject];
}); });
}); });

View File

@ -25,6 +25,7 @@ const CollapsibleTree = ({
onSelectNode, onSelectNode,
forStage = false forStage = false
}) => { }) => {
const [expandedItems, setExpandedItems] = useState([]); const [expandedItems, setExpandedItems] = useState([]);
const [anchorEl, setAnchorEl] = useState(null); const [anchorEl, setAnchorEl] = useState(null);
const [selectedNodes, setSelectedNodes] = useState([]); const [selectedNodes, setSelectedNodes] = useState([]);
@ -160,7 +161,7 @@ const CollapsibleTree = ({
const visibleSelectedCount = selectedNodes.filter((id) => const visibleSelectedCount = selectedNodes.filter((id) =>
visibleLeafKeys.includes(id), visibleLeafKeys.includes(id),
).length; ).length;
const selectedCount = forStage ? visibleSelectedCount : visibleSelectedCount - 1; //1 колонка всегда скрыта const selectedCount = visibleSelectedCount;
const isAllSelected = () => { const isAllSelected = () => {
if (!visibleColumnTree.length) return false; if (!visibleColumnTree.length) return false;