обновленна логика кнокпи экспорта шахматки и обновленна логика древовидноого фильтра
This commit is contained in:
parent
478d0acd98
commit
6b956f7664
@ -49,7 +49,6 @@ export const TreeFilterDropdown: React.FC<TreeFilterDropdownProps> = ({
|
|||||||
if (isMatch || filteredChildren.length > 0) {
|
if (isMatch || filteredChildren.length > 0) {
|
||||||
return {
|
return {
|
||||||
...node,
|
...node,
|
||||||
// ВАЖНО: мы оставляем родителя, но обрезаем его детей до найденных
|
|
||||||
children: filteredChildren.length > 0 ? filteredChildren : undefined,
|
children: filteredChildren.length > 0 ? filteredChildren : undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -142,6 +141,14 @@ export const TreeFilterDropdown: React.FC<TreeFilterDropdownProps> = ({
|
|||||||
if (info.checked) {
|
if (info.checked) {
|
||||||
newKeys.add(node.key);
|
newKeys.add(node.key);
|
||||||
childrens?.forEach((elem) => newKeys.add(elem));
|
childrens?.forEach((elem) => newKeys.add(elem));
|
||||||
|
const parentNode = findParentByKey(treeData, node.key);
|
||||||
|
if (parentNode?.key) {
|
||||||
|
const childrens = getAllDescendants(parentNode as OptionType);
|
||||||
|
const isAllChildrenSelected = childrens.every((childKey) => newKeys.has(childKey));
|
||||||
|
if(!isAllChildrenSelected){
|
||||||
|
newKeys.delete(parentNode.key)
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const parentNode = findParentByKey(treeData, node.key);
|
const parentNode = findParentByKey(treeData, node.key);
|
||||||
if (parentNode?.key) {
|
if (parentNode?.key) {
|
||||||
|
|||||||
@ -72,9 +72,11 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
|||||||
return () => document.removeEventListener('fullscreenchange', handleFullscreenChange);
|
return () => document.removeEventListener('fullscreenchange', handleFullscreenChange);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const isHalfFiltered = (debit.length > 0 && credit.length === 0) || (debit.length === 0 && credit.length > 0);
|
||||||
|
|
||||||
const loadData = useCallback(
|
const loadData = useCallback(
|
||||||
async (vId: string, dIds: string[], cIds: string[], isActual: () => boolean) => {
|
async (vId: string, dIds: string[], cIds: string[], isActual: () => boolean) => {
|
||||||
if ((dIds.length > 0 && cIds.length === 0) || (dIds.length === 0 && cIds.length > 0)) {
|
if (isHalfFiltered) {
|
||||||
notification.info({ description: 'Для сравнений по Дт и Кт нужно заполнить оба фильтра' });
|
notification.info({ description: 'Для сравнений по Дт и Кт нужно заполнить оба фильтра' });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -99,7 +101,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[notification],
|
[notification, isHalfFiltered],
|
||||||
);
|
);
|
||||||
const loadResData = useCallback(
|
const loadResData = useCallback(
|
||||||
async (vid: string) => {
|
async (vid: string) => {
|
||||||
@ -252,7 +254,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', gap: 8, marginTop: 8 }}>
|
<div style={{ display: 'flex', gap: 8, marginTop: 8 }}>
|
||||||
<Button loading={matrixExportLoading} onClick={() => download()} icon={<DownloadOutlined />}>
|
<Button disabled={isHalfFiltered} loading={matrixExportLoading} onClick={() => download()} icon={<DownloadOutlined />}>
|
||||||
Экспорт
|
Экспорт
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -151,7 +151,6 @@ export const ConsolidationChessTableFilter: React.FC<ConsolidationChessTableFilt
|
|||||||
className='custom-select-selection-item '
|
className='custom-select-selection-item '
|
||||||
popupRender={() => (
|
popupRender={() => (
|
||||||
<TreeFilterDropdown
|
<TreeFilterDropdown
|
||||||
|
|
||||||
title='Компании'
|
title='Компании'
|
||||||
placeholder='Введите название компании'
|
placeholder='Введите название компании'
|
||||||
treeData={companyTreeData}
|
treeData={companyTreeData}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user