process/supplier-agent: move reaction from supplier to agents

This commit is contained in:
Chika 2022-10-25 18:55:06 +03:00
parent 1d886bb43e
commit 45e540fbfb
2 changed files with 24 additions and 19 deletions

View File

@ -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<object>) {}
export function commonReactions(store: RootStore, apolloClient: ApolloClient<object>) {
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<object>) {}

View File

@ -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<object>) {
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
* На изменение Салон приобретения формируем список в поле ЮЛ поставщика - записи Контрагент,