правка добавления строки в 4 форме #57
@ -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);
|
||||||
|
|||||||
@ -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: [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@ -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: [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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];
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user