diff --git a/process/supplier-agent/reactions/agents.ts b/process/supplier-agent/reactions/agents.ts index d530482..1820f0b 100644 --- a/process/supplier-agent/reactions/agents.ts +++ b/process/supplier-agent/reactions/agents.ts @@ -1,6 +1,29 @@ +/* eslint-disable implicit-arrow-linebreak */ import type { ApolloClient } from '@apollo/client'; +import { reaction } from 'mobx'; import type RootStore from 'stores/root'; +import { makeDisposable } from 'tools/mobx'; +import * as fillAgentsFromLead from '../lib/fill-agents-from-lead'; -export function commonReactions(store: RootStore, apolloClient: ApolloClient) {} +export function commonReactions(store: RootStore, apolloClient: ApolloClient) { + const { $calculation, $process } = store; + + /** + * Заполняем агентов из Интереса + */ + makeDisposable( + () => + reaction( + () => $calculation.getElementValue('selectLead'), + (leadid) => { + fillAgentsFromLead.fillIndAgent(store, apolloClient, leadid); + fillAgentsFromLead.fillCalcDoubleAgent(store, apolloClient, leadid); + fillAgentsFromLead.fillCalcBroker(store, apolloClient, leadid); + fillAgentsFromLead.fillFinDepartment(store, apolloClient, leadid); + } + ), + () => $process.has('LoadKP') + ); +} export function validationReactions(store: RootStore, apolloClient: ApolloClient) {} diff --git a/process/supplier-agent/reactions/supplier.ts b/process/supplier-agent/reactions/supplier.ts index ce3e098..807cc1f 100644 --- a/process/supplier-agent/reactions/supplier.ts +++ b/process/supplier-agent/reactions/supplier.ts @@ -9,7 +9,6 @@ import { reaction } from 'mobx'; import type RootStore from 'stores/root'; import { normalizeOptions } from 'tools/entity'; import { makeDisposable } from 'tools/mobx'; -import * as fillAgentsFromLead from '../lib/fill-agents-from-lead'; import { QUERY_GET_AGENT } from '../lib/query'; dayjs.extend(utc); @@ -17,23 +16,6 @@ dayjs.extend(utc); export function commonReactions(store: RootStore, apolloClient: ApolloClient) { const { $calculation, $process } = store; - /** - * Заполняем агентов из Интереса - */ - makeDisposable( - () => - reaction( - () => $calculation.getElementValue('selectLead'), - (leadid) => { - fillAgentsFromLead.fillIndAgent(store, apolloClient, leadid); - fillAgentsFromLead.fillCalcDoubleAgent(store, apolloClient, leadid); - fillAgentsFromLead.fillCalcBroker(store, apolloClient, leadid); - fillAgentsFromLead.fillFinDepartment(store, apolloClient, leadid); - } - ), - () => $process.has('LoadKP') - ); - /** * Заполняем selectDealerPerson * На изменение Салон приобретения формируем список в поле ЮЛ поставщика - записи Контрагент,