обновленна логика кнокпи экспорта шахматки и обновленна логика древовидноого фильтра
This commit is contained in:
parent
478d0acd98
commit
6b956f7664
@ -49,7 +49,6 @@ export const TreeFilterDropdown: React.FC<TreeFilterDropdownProps> = ({
|
||||
if (isMatch || filteredChildren.length > 0) {
|
||||
return {
|
||||
...node,
|
||||
// ВАЖНО: мы оставляем родителя, но обрезаем его детей до найденных
|
||||
children: filteredChildren.length > 0 ? filteredChildren : undefined,
|
||||
};
|
||||
}
|
||||
@ -142,6 +141,14 @@ export const TreeFilterDropdown: React.FC<TreeFilterDropdownProps> = ({
|
||||
if (info.checked) {
|
||||
newKeys.add(node.key);
|
||||
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 {
|
||||
const parentNode = findParentByKey(treeData, node.key);
|
||||
if (parentNode?.key) {
|
||||
|
||||
@ -72,9 +72,11 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
return () => document.removeEventListener('fullscreenchange', handleFullscreenChange);
|
||||
}, []);
|
||||
|
||||
const isHalfFiltered = (debit.length > 0 && credit.length === 0) || (debit.length === 0 && credit.length > 0);
|
||||
|
||||
const loadData = useCallback(
|
||||
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: 'Для сравнений по Дт и Кт нужно заполнить оба фильтра' });
|
||||
return;
|
||||
}
|
||||
@ -99,7 +101,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
}
|
||||
}
|
||||
},
|
||||
[notification],
|
||||
[notification, isHalfFiltered],
|
||||
);
|
||||
const loadResData = useCallback(
|
||||
async (vid: string) => {
|
||||
@ -252,7 +254,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
/>
|
||||
</div>
|
||||
<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
|
||||
|
||||
@ -151,7 +151,6 @@ export const ConsolidationChessTableFilter: React.FC<ConsolidationChessTableFilt
|
||||
className='custom-select-selection-item '
|
||||
popupRender={() => (
|
||||
<TreeFilterDropdown
|
||||
|
||||
title='Компании'
|
||||
placeholder='Введите название компании'
|
||||
treeData={companyTreeData}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user