Compare commits

..

5 Commits

Author SHA1 Message Date
aep
ed0052bad0 Merge pull request 'AURORA-1671: исправления по функционалу ГК и ЮЛ' (#179) from fix/legalEntities into main 2026-10-26 23:17:17 +03:00
Andrey Epifancev
3aad670510 fix(web): справочники — выбранная ГК, счётчик ЮЛ, ошибки у полей (ревью #179, AURORA-1671)
- Страница ГК: снова выбирается первая ГК списка; список ЮЛ без выбранной ГК
  не запрашивается (иначе уходил запрос по всем ГК), «ЮЛ вне ГК» грузится без ГК.
- Выбранная ГК обновляется после перезагрузки списка ГК — счётчик ЮЛ в шапке
  и на вкладке после создания/переноса/вывода ЮЛ.
- Загрузка ГСК/ГСЗ: try/finally — ошибка не оставляет вечный спиннер.
- Форма ЮЛ: INVALID_INN/INVALID_KPP/INN_EXISTS/CRM_ID_EXISTS — у поля;
  КПП приводится к верхнему регистру при вводе.
- crm_id ГСК/ГСЗ — string | null; колонка «ID в CRM»; LE_PAGE вместо литерала;
  возвращён комментарий в фильтре шахматки.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 00:00:47 +04:00
630a616bf1 форматирование 2026-10-26 14:14:50 +03:00
daec128fc3 AURORA-1671: добавленна отображения ошибки crm_id_exists напрямую в форму 2026-10-26 14:11:48 +03:00
633c4d3fed AURORA-1671: исправления по функционалу ГК и ЮЛ 2026-10-26 13:35:05 +03:00
20 changed files with 160 additions and 174 deletions

View File

@ -0,0 +1,7 @@
/* Теги выбранных значений в селектах: фильтр шахматки, синонимы ЮЛ */
.custom-select-selection-item .ant-select-selection-item {
background-color: #ecfdf3 !important;
color: #1f5f35 !important;
box-shadow: inset 0 0 0 1px #2ea64b38 !important;
border-radius: 999px !important;
}

View File

@ -6,8 +6,8 @@ import PageTitle from '../components/PageTitle';
import { createCatalogueJur } from '../services/api/directories/catalogue_jur'; import { createCatalogueJur } from '../services/api/directories/catalogue_jur';
import { createCompanyGroup, fetchRelatedGroups } from '../services/api/directories/company_groups'; import { createCompanyGroup, fetchRelatedGroups } from '../services/api/directories/company_groups';
import { createRelatedGroup } from '../services/api/directories/related-groups'; import { createRelatedGroup } from '../services/api/directories/related-groups';
import { setActiveCompanyGroup } from '../store/slices/catalogueJurSlice/catalogueJurSlice';
import { getCatalogueJurThunk } from '../store/slices/catalogueJurSlice/thunks'; import { getCatalogueJurThunk } from '../store/slices/catalogueJurSlice/thunks';
import { setActiveCompanyGroup } from '../store/slices/companyGroupsSlice/companyGroupsSlice';
import { getCompanyGroupsThunk } from '../store/slices/companyGroupsSlice/thunks'; import { getCompanyGroupsThunk } from '../store/slices/companyGroupsSlice/thunks';
import { useAppDispatch, useAppSelector } from '../store/store'; import { useAppDispatch, useAppSelector } from '../store/store';
import type { RelatedGroupOut } from '../types/api'; import type { RelatedGroupOut } from '../types/api';
@ -37,61 +37,37 @@ export function CatalogueGroup() {
const [activeTab, setActiveTab] = useState<CatalogueGroupTabKey>('legal_entities'); const [activeTab, setActiveTab] = useState<CatalogueGroupTabKey>('legal_entities');
const [gskData, setGskData] = useState<RelatedGroupOut[]>([]); const [gskData, setGskData] = useState<RelatedGroupOut[]>([]);
const [gszData, setGszData] = useState<RelatedGroupOut[]>([]); const [gszData, setGszData] = useState<RelatedGroupOut[]>([]);
const activeCompanyGroup = useAppSelector((state) => state.company_groups.activeCompanyGroup); const activeCompanyGroup = useAppSelector((state) => state.catalogue_jur.activeCompanyGroup);
const relatedGroupFilter = useAppSelector((state) => state.catalogue_jur.relatedGroupFilter); const relatedGroupFilter = useAppSelector((state) => state.catalogue_jur.relatedGroupFilter);
const rawRows = useAppSelector((state) => state.company_groups.raw_rows); const rawRows = useAppSelector((state) => state.company_groups.raw_rows);
async function createJurHandler(values: CatalogueJurFormProps) { async function createJurHandler(values: CatalogueJurFormProps) {
try { await createCatalogueJur(values);
await createCatalogueJur(values); dispatch(getCompanyGroupsThunk());
dispatch(getCompanyGroupsThunk()); dispatch(
dispatch( getCatalogueJurThunk({
getCatalogueJurThunk({ closed: isGettingArchive,
closed: isGettingArchive, outside_group: false,
outside_group: false, company_group_id: activeCompanyGroup?.id,
company_group_id: activeCompanyGroup?.id, }),
}), );
); setKindForm(null);
setKindForm(null);
} catch (e) {
if (e instanceof ApiError) {
notification.error({
description: e.message,
});
}
}
} }
async function createRelatedGroupHandler(values: RelatedGroupFormType) { async function createRelatedGroupHandler(values: RelatedGroupFormType) {
if (values.company_group_id) { if (values.company_group_id) {
try { await createRelatedGroup(values.company_group_id, {
await createRelatedGroup(values.company_group_id, { ...values,
...values, company_group_id: undefined,
company_group_id: undefined, });
}); getRelatedGroupsHandler();
getRelatedGroupsHandler(); setKindForm(null);
setKindForm(null);
} catch (e) {
if (e instanceof ApiError) {
notification.error({
description: e.message,
});
}
}
} }
} }
async function createCompanyGroupHandler(values: CreateCompanyGroupProps) { async function createCompanyGroupHandler(values: CreateCompanyGroupProps) {
try { await createCompanyGroup(values);
await createCompanyGroup(values); dispatch(getCompanyGroupsThunk());
dispatch(getCompanyGroupsThunk()); getRelatedGroupsHandler();
getRelatedGroupsHandler(); setKindForm(null);
setKindForm(null);
} catch (e) {
if (e instanceof ApiError) {
notification.error({
description: e.message,
});
}
}
} }
async function getRelatedGroupsHandler() { async function getRelatedGroupsHandler() {
@ -105,9 +81,7 @@ export function CatalogueGroup() {
setGszData(gszs); setGszData(gszs);
} catch (e) { } catch (e) {
if (e instanceof ApiError) { if (e instanceof ApiError) {
notification.error({ notification.error({ description: e.message });
description: e.message,
});
} }
} finally { } finally {
setRelatedGroupLoading(false); setRelatedGroupLoading(false);
@ -119,16 +93,17 @@ export function CatalogueGroup() {
getRelatedGroupsHandler(); getRelatedGroupsHandler();
}, [activeCompanyGroup]); }, [activeCompanyGroup]);
// Без выбранной ГК таблица ЮЛ не грузится — выбираем первую ГК списка
useEffect(() => {
if (!activeCompanyGroup && rawRows?.length) {
dispatch(setActiveCompanyGroup(rawRows[0]));
}
}, [rawRows, activeCompanyGroup, dispatch]);
useEffect(() => { useEffect(() => {
setActiveTab('legal_entities'); setActiveTab('legal_entities');
}, [relatedGroupFilter]); }, [relatedGroupFilter]);
useEffect(() => {
if (!activeCompanyGroup && rawRows?.length) {
dispatch(setActiveCompanyGroup(rawRows?.[0]));
}
}, [rawRows, activeCompanyGroup]);
return ( return (
<div <div
style={{ style={{
@ -203,9 +178,7 @@ export function CatalogueGroup() {
onCancel={() => { onCancel={() => {
setKindForm(null); setKindForm(null);
}} }}
onOk={async (values) => { onOk={createJurHandler}
await createJurHandler(values);
}}
/> />
)} )}
{(kindForm === 'gsk' || kindForm === 'gsz') && ( {(kindForm === 'gsk' || kindForm === 'gsz') && (
@ -215,9 +188,7 @@ export function CatalogueGroup() {
onCancel={() => { onCancel={() => {
setKindForm(null); setKindForm(null);
}} }}
onOk={async (values) => { onOk={createRelatedGroupHandler}
await createRelatedGroupHandler(values);
}}
/> />
)} )}
{kindForm === 'gk' && ( {kindForm === 'gk' && (
@ -226,9 +197,7 @@ export function CatalogueGroup() {
onCancel={() => { onCancel={() => {
setKindForm(null); setKindForm(null);
}} }}
onOk={async (values) => { onOk={createCompanyGroupHandler}
await createCompanyGroupHandler(values);
}}
/> />
)} )}
</div> </div>

View File

@ -1,41 +1,30 @@
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import { Button, Space } from 'antd'; import { Button, Space } from 'antd';
import { useState } from 'react'; import { useState } from 'react';
import { ApiError } from '../api/client';
import PageTitle from '../components/PageTitle'; import PageTitle from '../components/PageTitle';
import { createCatalogueJur } from '../services/api/directories/catalogue_jur'; import { createCatalogueJur } from '../services/api/directories/catalogue_jur';
import { getCatalogueJurThunk } from '../store/slices/catalogueJurSlice/thunks'; import { getCatalogueJurThunk } from '../store/slices/catalogueJurSlice/thunks';
import { useAppDispatch, useAppSelector } from '../store/store'; import { useAppDispatch, useAppSelector } from '../store/store';
import type { CatalogueJurFormProps } from '../types/catalogueJur/catalogueJur'; import type { CatalogueJurFormProps } from '../types/catalogueJur/catalogueJur';
import { useNotificationApi } from '../utils/useNotification';
import { CatalogueJurForm } from '../widgets/CatalogueJurForm/CatalogueJurForm'; import { CatalogueJurForm } from '../widgets/CatalogueJurForm/CatalogueJurForm';
import { CatalogueJurTable } from '../widgets/CatalogueJurTable/CatalogueJurTable'; import { CatalogueJurTable } from '../widgets/CatalogueJurTable/CatalogueJurTable';
export function CatalogueJur() { export function CatalogueJur() {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const notification = useNotificationApi();
const isGettingArchive = useAppSelector((state) => state.catalogue_jur.isGettingArchive); const isGettingArchive = useAppSelector((state) => state.catalogue_jur.isGettingArchive);
const [createFormOpen, setCreateFormOpen] = useState(false); const [createFormOpen, setCreateFormOpen] = useState(false);
const outside_group = true; const outside_group = true;
async function createJurHandler(values: CatalogueJurFormProps) { async function createJurHandler(values: CatalogueJurFormProps) {
try { await createCatalogueJur(values);
await createCatalogueJur(values); dispatch(
dispatch( getCatalogueJurThunk({
getCatalogueJurThunk({ closed: isGettingArchive,
closed: isGettingArchive, outside_group: outside_group,
outside_group: outside_group, }),
}), );
); setCreateFormOpen(false);
setCreateFormOpen(false);
} catch (e) {
if (e instanceof ApiError) {
notification.error({
description: e.message,
});
}
}
} }
return ( return (
@ -59,9 +48,7 @@ export function CatalogueJur() {
onCancel={() => { onCancel={() => {
setCreateFormOpen(false); setCreateFormOpen(false);
}} }}
onOk={async (values) => { onOk={createJurHandler}
await createJurHandler(values);
}}
/> />
)} )}
</div> </div>

View File

@ -1,5 +1,7 @@
import { type PayloadAction, createSlice } from '@reduxjs/toolkit'; import { type PayloadAction, createSlice } from '@reduxjs/toolkit';
import type { RelatedGroupOut } from '../../../types/api'; import type { RelatedGroupOut } from '../../../types/api';
import type { ICompanyGroup } from '../../../types/companyGroups/companyGroups';
import { getCompanyGroupsThunk } from '../companyGroupsSlice/thunks';
import { getCatalogueJurThunk } from './thunks'; import { getCatalogueJurThunk } from './thunks';
import type { CatalogueJurSliceType } from './types'; import type { CatalogueJurSliceType } from './types';
@ -10,6 +12,7 @@ const initialState: CatalogueJurSliceType = {
error: null, error: null,
isGettingArchive: false, isGettingArchive: false,
relatedGroupFilter: null, relatedGroupFilter: null,
activeCompanyGroup: null,
}; };
const catalogueJurSlice = createSlice({ const catalogueJurSlice = createSlice({
@ -22,6 +25,10 @@ const catalogueJurSlice = createSlice({
setRelatedGroupFilter(state, action: PayloadAction<RelatedGroupOut | null>) { setRelatedGroupFilter(state, action: PayloadAction<RelatedGroupOut | null>) {
state.relatedGroupFilter = action.payload; state.relatedGroupFilter = action.payload;
}, },
setActiveCompanyGroup(state, action: PayloadAction<ICompanyGroup | null>) {
state.activeCompanyGroup = action.payload;
state.relatedGroupFilter = null;
},
}, },
extraReducers: (builder) => { extraReducers: (builder) => {
builder builder
@ -37,8 +44,15 @@ const catalogueJurSlice = createSlice({
.addCase(getCatalogueJurThunk.rejected, (state, action) => { .addCase(getCatalogueJurThunk.rejected, (state, action) => {
state.error = action.payload ?? 'Неизвестная ошибка'; state.error = action.payload ?? 'Неизвестная ошибка';
state.loading = false; state.loading = false;
})
// Выбранная ГК — копия строки списка ГК: после перезагрузки списка берём свежую (счётчик ЮЛ в шапке и вкладке)
.addCase(getCompanyGroupsThunk.fulfilled, (state, action) => {
if (state.activeCompanyGroup?.id) {
state.activeCompanyGroup = action.payload.find((elem) => elem.id === state.activeCompanyGroup?.id) ?? null;
}
}); });
}, },
}); });
export const { setIsGettingArchive, setRelatedGroupFilter } = catalogueJurSlice.actions;
export const { setIsGettingArchive, setRelatedGroupFilter, setActiveCompanyGroup } = catalogueJurSlice.actions;
export default catalogueJurSlice.reducer; export default catalogueJurSlice.reducer;

View File

@ -1,5 +1,6 @@
import type { RelatedGroupOut } from '../../../types/api'; import type { RelatedGroupOut } from '../../../types/api';
import type { ICatalogueJur } from '../../../types/catalogueJur/catalogueJur'; import type { ICatalogueJur } from '../../../types/catalogueJur/catalogueJur';
import type { ICompanyGroup } from '../../../types/companyGroups/companyGroups';
export interface CatalogueJurSliceType { export interface CatalogueJurSliceType {
total_groups: number; total_groups: number;
@ -8,6 +9,7 @@ export interface CatalogueJurSliceType {
error: string | null; error: string | null;
isGettingArchive: boolean; isGettingArchive: boolean;
relatedGroupFilter?: RelatedGroupOut | null; relatedGroupFilter?: RelatedGroupOut | null;
activeCompanyGroup?: ICompanyGroup | null;
} }
export interface GetCatalogueJurPropsI { export interface GetCatalogueJurPropsI {

View File

@ -1,5 +1,4 @@
import { type PayloadAction, createSlice } from '@reduxjs/toolkit'; import { createSlice } from '@reduxjs/toolkit';
import type { ICompanyGroup } from '../../../types/companyGroups/companyGroups';
import { getCompanyGroupsThunk } from './thunks'; import { getCompanyGroupsThunk } from './thunks';
import type { CompanyGroupSliceType } from './types'; import type { CompanyGroupSliceType } from './types';
@ -8,17 +7,12 @@ const initialState: CompanyGroupSliceType = {
total_groups: 0, total_groups: 0,
loading: false, loading: false,
error: null, error: null,
activeCompanyGroup: null,
}; };
const comGroupsSlice = createSlice({ const comGroupsSlice = createSlice({
name: 'company_groups', name: 'company_groups',
initialState, initialState,
reducers: { reducers: {},
setActiveCompanyGroup(state, action: PayloadAction<ICompanyGroup | null>) {
state.activeCompanyGroup = action.payload;
},
},
extraReducers: (builder) => { extraReducers: (builder) => {
builder builder
.addCase(getCompanyGroupsThunk.pending, (state) => { .addCase(getCompanyGroupsThunk.pending, (state) => {
@ -27,10 +21,6 @@ const comGroupsSlice = createSlice({
}) })
.addCase(getCompanyGroupsThunk.fulfilled, (state, action) => { .addCase(getCompanyGroupsThunk.fulfilled, (state, action) => {
state.raw_rows = action.payload; state.raw_rows = action.payload;
if (state.activeCompanyGroup?.id) {
const newActiveCompanyGroup = action.payload.find((elem) => elem.id === state.activeCompanyGroup?.id);
state.activeCompanyGroup = newActiveCompanyGroup;
}
state.total_groups = action.payload.length; state.total_groups = action.payload.length;
state.loading = false; state.loading = false;
}) })
@ -40,5 +30,4 @@ const comGroupsSlice = createSlice({
}); });
}, },
}); });
export const { setActiveCompanyGroup } = comGroupsSlice.actions;
export default comGroupsSlice.reducer; export default comGroupsSlice.reducer;

View File

@ -5,5 +5,4 @@ export interface CompanyGroupSliceType {
raw_rows: ICompanyGroup[]; raw_rows: ICompanyGroup[];
loading: boolean; loading: boolean;
error: string | null; error: string | null;
activeCompanyGroup?: ICompanyGroup | null;
} }

View File

@ -375,6 +375,7 @@ export interface ConsolidationCreate {
export interface RelatedGroupOut { export interface RelatedGroupOut {
id: string; id: string;
code: string; code: string;
crm_id: string | null;
company_group_id: string; company_group_id: string;
kind: 'gsk' | 'gsz'; kind: 'gsk' | 'gsz';
name: string; name: string;
@ -389,7 +390,6 @@ export interface RelatedGroupMemberOut {
} }
export interface RelatedGroupDetail extends RelatedGroupOut { export interface RelatedGroupDetail extends RelatedGroupOut {
members: RelatedGroupMemberOut[]; members: RelatedGroupMemberOut[];
crm_id: string;
} }
export interface LegalEntityBrief { export interface LegalEntityBrief {
id: string; id: string;

View File

@ -1,7 +1,7 @@
export type RelatedGroupFormType = { export type RelatedGroupFormType = {
name: string; name: string;
created_date: string | null; created_date: string | null;
crm_id: string; crm_id: string | null;
kind?: 'gsk' | 'gsz'; kind?: 'gsk' | 'gsz';
company_group_id?: string; company_group_id?: string;
}; };

View File

@ -12,7 +12,7 @@ interface CataloguGroupTabsI {
export type CatalogueGroupTabKey = 'legal_entities' | 'gsk' | 'gsz'; export type CatalogueGroupTabKey = 'legal_entities' | 'gsk' | 'gsz';
export const CataloguGroupTabs = ({ activeTab, setActiveTab, gskData, gszData }: CataloguGroupTabsI) => { export const CataloguGroupTabs = ({ activeTab, setActiveTab, gskData, gszData }: CataloguGroupTabsI) => {
const activeCompanyGroup = useAppSelector((state) => state.company_groups.activeCompanyGroup); const activeCompanyGroup = useAppSelector((state) => state.catalogue_jur.activeCompanyGroup);
return ( return (
<Tabs <Tabs

View File

@ -5,7 +5,7 @@ import { useAppSelector } from '../../store/store';
import { pluralRu } from '../../utils/labels'; import { pluralRu } from '../../utils/labels';
export const CompanyGroupHeader = () => { export const CompanyGroupHeader = () => {
const activeCompanyGroup = useAppSelector((state) => state.company_groups.activeCompanyGroup); const activeCompanyGroup = useAppSelector((state) => state.catalogue_jur.activeCompanyGroup);
const count = activeCompanyGroup?.legal_entities_count ?? 0; const count = activeCompanyGroup?.legal_entities_count ?? 0;
const organizationWord = pluralRu(count, ['организация', 'организации', 'организаций']); const organizationWord = pluralRu(count, ['организация', 'организации', 'организаций']);

View File

@ -17,6 +17,14 @@ type Props = {
jurId?: string; jurId?: string;
}; };
// Ошибки сервера, относящиеся к одному полю, показываем у этого поля
const FIELD_BY_ERROR_CODE: Record<string, keyof CatalogueJurFormProps> = {
INN_EXISTS: 'inn',
INVALID_INN: 'inn',
INVALID_KPP: 'kpp',
CRM_ID_EXISTS: 'crm_id',
};
export const CatalogueJurForm: React.FC<Props> = ({ open, onCancel, onOk, jurId }) => { export const CatalogueJurForm: React.FC<Props> = ({ open, onCancel, onOk, jurId }) => {
const [form] = Form.useForm<CatalogueJurFormProps>(); const [form] = Form.useForm<CatalogueJurFormProps>();
const notification = useNotificationApi(); const notification = useNotificationApi();
@ -27,12 +35,11 @@ export const CatalogueJurForm: React.FC<Props> = ({ open, onCancel, onOk, jurId
const [loadingOfficesOptions, setLoadingOfficesOptions] = useState(false); const [loadingOfficesOptions, setLoadingOfficesOptions] = useState(false);
const [confirmLoading, setConfirmLoading] = useState(false); const [confirmLoading, setConfirmLoading] = useState(false);
const [officesOptions, setOfficesOptions] = useState<{ value: string; label: string }[]>([]); const [officesOptions, setOfficesOptions] = useState<{ value: string; label: string }[]>([]);
const companyGrops = useAppSelector((state) => state.company_groups.raw_rows); const companyGrops = useAppSelector((state) => state.company_groups.raw_rows);
const companyGropsLoading = useAppSelector((state) => state.company_groups.loading); const companyGropsLoading = useAppSelector((state) => state.company_groups.loading);
const activeCompanyGroup = useAppSelector((state) => state.catalogue_jur.activeCompanyGroup);
const type = Form.useWatch('entity_type', form); const type = Form.useWatch('entity_type', form);
const companyGroupId = Form.useWatch('company_group_id', form);
async function getInitialData() { async function getInitialData() {
if (jurId) { if (jurId) {
@ -51,6 +58,7 @@ export const CatalogueJurForm: React.FC<Props> = ({ open, onCancel, onOk, jurId
gsk_id: data.memberships?.find((elem) => elem.kind === 'gsk')?.related_group_id, gsk_id: data.memberships?.find((elem) => elem.kind === 'gsk')?.related_group_id,
gsz_id: data.memberships?.find((elem) => elem.kind === 'gsz')?.related_group_id, gsz_id: data.memberships?.find((elem) => elem.kind === 'gsz')?.related_group_id,
}); });
getRelatedGroupsHandler(data.company_group_id as string);
} catch (e) { } catch (e) {
if (e instanceof ApiError) { if (e instanceof ApiError) {
notification.error({ description: e.message }); notification.error({ description: e.message });
@ -58,6 +66,11 @@ export const CatalogueJurForm: React.FC<Props> = ({ open, onCancel, onOk, jurId
} finally { } finally {
setInitialDataLoading(false); setInitialDataLoading(false);
} }
} else {
form.setFieldsValue({
company_group_id: activeCompanyGroup?.id ?? undefined,
});
getRelatedGroupsHandler(activeCompanyGroup?.id ?? '');
} }
} }
@ -76,12 +89,12 @@ export const CatalogueJurForm: React.FC<Props> = ({ open, onCancel, onOk, jurId
} }
} }
async function getRelatedGroupsHandler() { async function getRelatedGroupsHandler(companyId: string) {
if (!companyGroupId) return; if (!companyId) return;
setLoadingRelatedGroupsOptions(true); setLoadingRelatedGroupsOptions(true);
try { try {
const res = await fetchRelatedGroups(companyGroupId); const res = await fetchRelatedGroups(companyId);
const gsks = res.filter((elem) => elem.kind === 'gsk'); const gsks = res.filter((elem) => elem.kind === 'gsk');
const gszs = res.filter((elem) => elem.kind === 'gsz'); const gszs = res.filter((elem) => elem.kind === 'gsz');
setGskData(gsks); setGskData(gsks);
@ -101,18 +114,21 @@ export const CatalogueJurForm: React.FC<Props> = ({ open, onCancel, onOk, jurId
const values = await form.validateFields(); const values = await form.validateFields();
await onOk({ await onOk({
...values, ...values,
kpp: type === 'ИП' ? null : values.kpp?.toString(), kpp: type === 'ИП' ? null : (values.kpp?.toString() ?? null),
inn: jurId ? undefined : values?.inn?.toString(), inn: jurId ? undefined : values?.inn?.toString(),
company_group_id: jurId ? undefined : values.company_group_id, company_group_id: jurId ? undefined : values.company_group_id,
gsz_id: values.gsz_id ? values?.gsz_id : null, gsz_id: values.gsz_id ? values?.gsz_id : null,
gsk_id: values.gsk_id ? values?.gsk_id : null, gsk_id: values.gsk_id ? values?.gsk_id : null,
regional_office_id: values.regional_office_id ? values?.regional_office_id : null, regional_office_id: values.regional_office_id ? values?.regional_office_id : null,
crm_id: values.crm_id ?? null,
}); });
} catch (e) { } catch (e) {
if (e instanceof ApiError) { if (e instanceof ApiError) {
notification.error({ const field = e.code ? FIELD_BY_ERROR_CODE[e.code] : undefined;
description: e.message, if (field) {
}); form.setFields([{ name: field, errors: [e.message] }]);
}
notification.error({ description: e.message });
} }
} finally { } finally {
setConfirmLoading(false); setConfirmLoading(false);
@ -128,21 +144,13 @@ export const CatalogueJurForm: React.FC<Props> = ({ open, onCancel, onOk, jurId
return companyGrops?.map((company) => company && { value: company.id, label: company.name }); return companyGrops?.map((company) => company && { value: company.id, label: company.name });
}, [companyGrops]); }, [companyGrops]);
useEffect(() => {
getInitialData();
}, [jurId, open]);
useEffect(() => { useEffect(() => {
getOfficesOptionsHandler(); getOfficesOptionsHandler();
}, []); }, []);
useEffect(() => { useEffect(() => {
form.setFieldsValue({ getInitialData();
gsk_id: undefined, }, [jurId, open]);
gsz_id: undefined,
});
getRelatedGroupsHandler();
}, [companyGroupId]);
return ( return (
<Modal <Modal
@ -182,7 +190,11 @@ export const CatalogueJurForm: React.FC<Props> = ({ open, onCancel, onOk, jurId
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={6}> <Col span={6}>
<Form.Item name='kpp' label='КПП' rules={[{ pattern: /^[0-9]{4}[0-9A-Z]{2}[0-9]{3}$/, message: 'Некорректный формат' }]}> <Form.Item
name='kpp'
label='КПП'
normalize={(value?: string) => value?.toUpperCase()}
rules={[{ pattern: /^[0-9]{4}[0-9A-Z]{2}[0-9]{3}$/, message: 'Некорректный формат' }]}>
<Input placeholder='000000000' maxLength={9} disabled={type === 'ИП'} style={{ width: '100%' }} /> <Input placeholder='000000000' maxLength={9} disabled={type === 'ИП'} style={{ width: '100%' }} />
</Form.Item> </Form.Item>
</Col> </Col>
@ -213,6 +225,7 @@ export const CatalogueJurForm: React.FC<Props> = ({ open, onCancel, onOk, jurId
label='Альтернативные наименования' label='Альтернативные наименования'
extra='Введите синоним и нажмите Enter. Можно добавить несколько значений.'> extra='Введите синоним и нажмите Enter. Можно добавить несколько значений.'>
<Select <Select
className='custom-select-selection-item'
mode='tags' mode='tags'
style={{ width: '100%' }} style={{ width: '100%' }}
placeholder='Добавить синоним' placeholder='Добавить синоним'
@ -246,6 +259,13 @@ export const CatalogueJurForm: React.FC<Props> = ({ open, onCancel, onOk, jurId
showSearch showSearch
optionFilterProp='label' optionFilterProp='label'
notFoundContent={companyGropsLoading ? 'Загрузка' : 'Нет вариантов'} notFoundContent={companyGropsLoading ? 'Загрузка' : 'Нет вариантов'}
onChange={(value) => {
form.setFieldsValue({
gsk_id: undefined,
gsz_id: undefined,
});
getRelatedGroupsHandler(value);
}}
/> />
</Form.Item> </Form.Item>
</Col> </Col>

View File

@ -45,7 +45,7 @@ export function CatalogueJurTable({ outside_group, tabsComponent }: CatalogueJur
const rawRows = useAppSelector((state) => state.catalogue_jur.raw_rows); const rawRows = useAppSelector((state) => state.catalogue_jur.raw_rows);
const loading = useAppSelector((state) => state.catalogue_jur.loading); const loading = useAppSelector((state) => state.catalogue_jur.loading);
const isGettingArchive = useAppSelector((state) => state.catalogue_jur.isGettingArchive); const isGettingArchive = useAppSelector((state) => state.catalogue_jur.isGettingArchive);
const activeCompanyGroup = useAppSelector((state) => state.company_groups.activeCompanyGroup); const activeCompanyGroup = useAppSelector((state) => state.catalogue_jur.activeCompanyGroup);
const relatedGroupFilter = useAppSelector((state) => state.catalogue_jur.relatedGroupFilter); const relatedGroupFilter = useAppSelector((state) => state.catalogue_jur.relatedGroupFilter);
const [moveCatalogueFormOpen, setMoveCatalogueFormOpen] = useState(false); const [moveCatalogueFormOpen, setMoveCatalogueFormOpen] = useState(false);
@ -122,24 +122,17 @@ export function CatalogueJurTable({ outside_group, tabsComponent }: CatalogueJur
} }
async function editJurHandler(values: CatalogueJurFormProps) { async function editJurHandler(values: CatalogueJurFormProps) {
try { await editCatalogueJur(jurId, values);
await editCatalogueJur(jurId, values); getCatalogueJur();
getCatalogueJur(); closeEditCatalogueJurHandler();
closeEditCatalogueJurHandler();
} catch (e) {
if (e instanceof ApiError) {
notification.error({
description: e.message,
});
}
}
} }
useEffect(() => { useEffect(() => {
if (activeCompanyGroup?.id) { // «ЮЛ вне ГК» грузится без выбранной ГК; список ГК — только по выбранной (без неё запрос ушёл бы по всем ГК)
if (outside_group || activeCompanyGroup?.id) {
getCatalogueJur(); getCatalogueJur();
} }
}, [isGettingArchive, activeCompanyGroup]); }, [isGettingArchive, activeCompanyGroup, outside_group]);
const extraColumns: ColumnsType<ICatalogueJur> = useMemo( const extraColumns: ColumnsType<ICatalogueJur> = useMemo(
() => [ () => [
@ -329,9 +322,7 @@ export function CatalogueJurTable({ outside_group, tabsComponent }: CatalogueJur
onCancel={() => { onCancel={() => {
closeEditCatalogueJurHandler(); closeEditCatalogueJurHandler();
}} }}
onOk={async (values) => { onOk={editJurHandler}
await editJurHandler(values);
}}
/> />
)} )}
</div> </div>

View File

@ -19,7 +19,7 @@ export const CompanyGroupForm: React.FC<Props> = ({ open, onCancel, onOk }) => {
const { me } = useMe(); const { me } = useMe();
const notification = useNotificationApi(); const notification = useNotificationApi();
const activeCompanyGroup = useAppSelector((state) => state.company_groups.activeCompanyGroup); const activeCompanyGroup = useAppSelector((state) => state.catalogue_jur.activeCompanyGroup);
const [officesOptions, setOfficesOptions] = useState<{ value: string; label: string }[]>([]); const [officesOptions, setOfficesOptions] = useState<{ value: string; label: string }[]>([]);
const [loadingOptions, setLoadingOptions] = useState(false); const [loadingOptions, setLoadingOptions] = useState(false);
const [confirmLoading, setConfirmLoading] = useState(false); const [confirmLoading, setConfirmLoading] = useState(false);
@ -49,6 +49,14 @@ export const CompanyGroupForm: React.FC<Props> = ({ open, onCancel, onOk }) => {
}); });
} catch (e) { } catch (e) {
if (e instanceof ApiError) { if (e instanceof ApiError) {
if (e.code === 'CRM_ID_EXISTS') {
form.setFields([
{
name: 'crm_id',
errors: [e.message],
},
]);
}
notification.error({ notification.error({
description: e.message, description: e.message,
}); });
@ -86,7 +94,7 @@ export const CompanyGroupForm: React.FC<Props> = ({ open, onCancel, onOk }) => {
<Row gutter={16}> <Row gutter={16}>
<Col span={12}> <Col span={12}>
<Form.Item name='crm_id' label='ID ГК в CRM'> <Form.Item name='crm_id' label='ID ГК в CRM'>
<Input placeholder='Генерируется автоматически' /> <Input />
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={12}> <Col span={12}>

View File

@ -2,7 +2,7 @@ import { FolderOpenOutlined, SearchOutlined } from '@ant-design/icons';
import { Empty, Input, List, Spin, Tag, Typography } from 'antd'; import { Empty, Input, List, Spin, Tag, Typography } from 'antd';
import { useEffect, useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { useVirtualList } from '../../hooks/useVirtualList'; import { useVirtualList } from '../../hooks/useVirtualList';
import { setActiveCompanyGroup } from '../../store/slices/companyGroupsSlice/companyGroupsSlice'; import { setActiveCompanyGroup } from '../../store/slices/catalogueJurSlice/catalogueJurSlice';
import { getCompanyGroupsThunk } from '../../store/slices/companyGroupsSlice/thunks'; import { getCompanyGroupsThunk } from '../../store/slices/companyGroupsSlice/thunks';
import { useAppDispatch, useAppSelector } from '../../store/store'; import { useAppDispatch, useAppSelector } from '../../store/store';
@ -13,7 +13,7 @@ export const CompanyGroupsList = () => {
const rawRows = useAppSelector((state) => state.company_groups.raw_rows); const rawRows = useAppSelector((state) => state.company_groups.raw_rows);
const loading = useAppSelector((state) => state.company_groups.loading); const loading = useAppSelector((state) => state.company_groups.loading);
const activeCompanyGroup = useAppSelector((state) => state.company_groups.activeCompanyGroup); const activeCompanyGroup = useAppSelector((state) => state.catalogue_jur.activeCompanyGroup);
const [query, setQuery] = useState(''); const [query, setQuery] = useState('');

View File

@ -1,7 +0,0 @@
/* Теги выбранных значений в селектах фильтра шахматки */
.custom-select-selection-item .ant-select-selection-item {
background-color: #ecfdf3 !important;
color: #1f5f35 !important;
box-shadow: inset 0 0 0 1px #2ea64b38 !important;
border-radius: 999px !important;
}

View File

@ -6,7 +6,6 @@ import { type OptionType, TreeFilterDropdown } from '../../components/TreeFilter
import type { Account, MatrixCompany, Quarter } from '../../types/api'; import type { Account, MatrixCompany, Quarter } from '../../types/api';
import { quarterShortLabel } from '../../utils/labels'; import { quarterShortLabel } from '../../utils/labels';
import { useNotificationApi } from '../../utils/useNotification'; import { useNotificationApi } from '../../utils/useNotification';
import './ConsolidationChessTableFilter.css';
interface ConsolidationChessTableFilterI { interface ConsolidationChessTableFilterI {
companies: string[]; companies: string[];

View File

@ -26,9 +26,15 @@ export const RelatedGroupForm: React.FC<Props> = ({ open, onCancel, onOk, relate
const [confirmLoading, setConfirmLoading] = useState(false); const [confirmLoading, setConfirmLoading] = useState(false);
const companyGrops = useAppSelector((state) => state.company_groups.raw_rows); const companyGrops = useAppSelector((state) => state.company_groups.raw_rows);
const companyGropsLoading = useAppSelector((state) => state.company_groups.loading); const companyGropsLoading = useAppSelector((state) => state.company_groups.loading);
const activeCompanyGroup = useAppSelector((state) => state.catalogue_jur.activeCompanyGroup);
async function getInitialData() { async function getInitialData() {
if (!relatedGroupId) return; if (!relatedGroupId) {
form.setFieldsValue({
company_group_id: activeCompanyGroup?.id ?? undefined,
});
return;
}
setInitialDataLoading(true); setInitialDataLoading(true);
try { try {
const data = await fetchRelatedGroup(relatedGroupId); const data = await fetchRelatedGroup(relatedGroupId);
@ -36,7 +42,7 @@ export const RelatedGroupForm: React.FC<Props> = ({ open, onCancel, onOk, relate
form.setFieldsValue({ form.setFieldsValue({
crm_id: data?.crm_id, crm_id: data?.crm_id,
name: data?.name, name: data?.name,
created_date: data?.created_date ?? dayjs().format('YYYY-MM-DD'), created_date: data?.created_date ?? null,
company_group_id: data?.company_group_id, company_group_id: data?.company_group_id,
}); });
} catch (e) { } catch (e) {
@ -53,7 +59,7 @@ export const RelatedGroupForm: React.FC<Props> = ({ open, onCancel, onOk, relate
try { try {
const { created_date, name, crm_id, company_group_id } = await form.validateFields(); const { created_date, name, crm_id, company_group_id } = await form.validateFields();
await onOk({ await onOk({
created_date: created_date ?? dayjs().format('YYYY-MM-DD'), created_date: created_date ?? (relatedGroupId ? null : dayjs().format('YYYY-MM-DD')),
name, name,
crm_id, crm_id,
company_group_id: relatedGroupId ? undefined : company_group_id, company_group_id: relatedGroupId ? undefined : company_group_id,
@ -61,6 +67,14 @@ export const RelatedGroupForm: React.FC<Props> = ({ open, onCancel, onOk, relate
}); });
} catch (e) { } catch (e) {
if (e instanceof ApiError) { if (e instanceof ApiError) {
if (e.code === 'CRM_ID_EXISTS') {
form.setFields([
{
name: 'crm_id',
errors: [e.message],
},
]);
}
notification.error({ notification.error({
description: e.message, description: e.message,
}); });
@ -96,7 +110,7 @@ export const RelatedGroupForm: React.FC<Props> = ({ open, onCancel, onOk, relate
confirmLoading={confirmLoading}> confirmLoading={confirmLoading}>
<Form form={form} layout='vertical'> <Form form={form} layout='vertical'>
<FormItem name='crm_id' label='ID в CRM'> <FormItem name='crm_id' label='ID в CRM'>
<Input placeholder='Генерируется автоматически' /> <Input />
</FormItem> </FormItem>
<FormItem name='name' label='Наименование' rules={[{ required: true, message: 'Укажите наименование' }]}> <FormItem name='name' label='Наименование' rules={[{ required: true, message: 'Укажите наименование' }]}>
<Input /> <Input />

View File

@ -62,17 +62,9 @@ export function RelatedGroupTable({ tabsComponent, data, loading, getData, activ
} }
async function editRelatedGroupHandler(values: RelatedGroupFormType) { async function editRelatedGroupHandler(values: RelatedGroupFormType) {
try { await editRelatedGroup(groupId, values);
await editRelatedGroup(groupId, values); getData();
getData(); closeEditRelatedGroupHandler();
closeEditRelatedGroupHandler();
} catch (e) {
if (e instanceof ApiError) {
notification.error({
description: e.message,
});
}
}
} }
const extraColumns: ColumnsType<RelatedGroupOut> = useMemo( const extraColumns: ColumnsType<RelatedGroupOut> = useMemo(
@ -167,9 +159,7 @@ export function RelatedGroupTable({ tabsComponent, data, loading, getData, activ
onCancel={() => { onCancel={() => {
closeEditRelatedGroupHandler(); closeEditRelatedGroupHandler();
}} }}
onOk={async (values) => { onOk={editRelatedGroupHandler}
await editRelatedGroupHandler(values);
}}
/> />
)} )}
{deleteModalOpen && ( {deleteModalOpen && (

View File

@ -6,13 +6,17 @@ import { store } from '../../store/store';
import type { RelatedGroupOut } from '../../types/api'; import type { RelatedGroupOut } from '../../types/api';
export const relateGroupConfig: TableConfig<RelatedGroupOut> = { export const relateGroupConfig: TableConfig<RelatedGroupOut> = {
rowKey: 'id', rowKey: 'id',
searchableKeys: ['code', 'name', 'members_count', 'created_date'], searchableKeys: ['code', 'crm_id', 'name', 'members_count', 'created_date'],
columns: [ columns: [
{ {
key: 'code', key: 'code',
title: 'ID', title: 'ID',
features: { search: true, multiselect: true }, features: { search: true, multiselect: true },
}, },
{
key: 'crm_id',
title: 'ID в CRM',
},
{ {
key: 'name', key: 'name',
title: 'Наименование', title: 'Наименование',
@ -35,7 +39,7 @@ export const relateGroupConfig: TableConfig<RelatedGroupOut> = {
key: 'created_date', key: 'created_date',
title: 'Дата создания', title: 'Дата создания',
render: (val) => { render: (val) => {
return new Date(val as string).toLocaleDateString('ru-RU'); return val ? new Date(val as string).toLocaleDateString('ru-RU') : '—';
}, },
}, },
], ],