process/supplier-agents: common reactions for agents
This commit is contained in:
parent
a766546dfe
commit
31c70615af
@ -1,10 +1,10 @@
|
||||
import type { CalculationStatuses } from 'stores/calculation/statuses/types';
|
||||
|
||||
const defaultStatuses: CalculationStatuses = {
|
||||
selectIndAgent: 'Disabled',
|
||||
selectCalcBroker: 'Disabled',
|
||||
selectCalcFinDepartment: 'Disabled',
|
||||
selectCalcDoubleAgent: 'Disabled',
|
||||
selectIndAgent: 'Default',
|
||||
selectCalcBroker: 'Default',
|
||||
selectCalcFinDepartment: 'Default',
|
||||
selectCalcDoubleAgent: 'Default',
|
||||
selectClientType: 'Disabled',
|
||||
tbxImporterRewardRub: 'Disabled',
|
||||
tbxImporterRewardPerc: 'Disabled',
|
||||
@ -71,13 +71,13 @@ const defaultStatuses: CalculationStatuses = {
|
||||
selectDealerBrokerRewardCondition: 'Default',
|
||||
tbxDealerBrokerRewardSumm: 'Disabled',
|
||||
selectIndAgentRewardCondition: 'Default',
|
||||
tbxIndAgentRewardSumm: 'Default',
|
||||
tbxIndAgentRewardSumm: 'Disabled',
|
||||
selectCalcDoubleAgentRewardCondition: 'Default',
|
||||
tbxCalcDoubleAgentRewardSumm: 'Default',
|
||||
tbxCalcDoubleAgentRewardSumm: 'Disabled',
|
||||
selectCalcBrokerRewardCondition: 'Default',
|
||||
tbxCalcBrokerRewardSum: 'Default',
|
||||
tbxCalcBrokerRewardSum: 'Disabled',
|
||||
selectFinDepartmentRewardCondtion: 'Default',
|
||||
tbxFinDepartmentRewardSumm: 'Default',
|
||||
tbxFinDepartmentRewardSumm: 'Disabled',
|
||||
selectGPSBrand: 'Default',
|
||||
selectGPSModel: 'Default',
|
||||
selectRegionRegistration: 'Default',
|
||||
|
||||
@ -122,70 +122,6 @@ export type GetCurrencySymbolQueryVariables = Exact<{
|
||||
|
||||
export type GetCurrencySymbolQuery = { __typename?: 'Query', transactioncurrency?: { __typename?: 'transactioncurrency', currencysymbol?: string | null } | null };
|
||||
|
||||
export type GetAgentQueryVariables = Exact<{
|
||||
agentid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetAgentQuery = { __typename?: 'Query', agent?: { __typename?: 'account', label?: string | null, value?: any | null } | null };
|
||||
|
||||
export type GetAgentAccountIdFromLeadQueryVariables = Exact<{
|
||||
leadid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetAgentAccountIdFromLeadQuery = { __typename?: 'Query', lead?: { __typename?: 'lead', agentid?: any | null } | null };
|
||||
|
||||
export type GetDoubleAgentAccountIdQueryVariables = Exact<{
|
||||
leadid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetDoubleAgentAccountIdQuery = { __typename?: 'Query', lead?: { __typename?: 'lead', agentid?: any | null } | null };
|
||||
|
||||
export type GetBrokerAccountIdQueryVariables = Exact<{
|
||||
leadid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetBrokerAccountIdQuery = { __typename?: 'Query', lead?: { __typename?: 'lead', agentid?: any | null } | null };
|
||||
|
||||
export type GetFinDepartmentAccountIdQueryVariables = Exact<{
|
||||
leadid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetFinDepartmentAccountIdQuery = { __typename?: 'Query', lead?: { __typename?: 'lead', agentid?: any | null } | null };
|
||||
|
||||
export type GetDealerPersonQueryVariables = Exact<{
|
||||
dealerId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetDealerPersonQuery = { __typename?: 'Query', salon_providers?: Array<{ __typename?: 'account', label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetBrokerAccountIdFromDealerQueryVariables = Exact<{
|
||||
dealerId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetBrokerAccountIdFromDealerQuery = { __typename?: 'Query', dealer?: { __typename?: 'account', evo_broker_accountid?: any | null } | null };
|
||||
|
||||
export type GetRewardConditionsQueryVariables = Exact<{
|
||||
agentid: Scalars['Uuid'];
|
||||
currentDate?: InputMaybe<Scalars['DateTime']>;
|
||||
}>;
|
||||
|
||||
|
||||
export type GetRewardConditionsQuery = { __typename?: 'Query', evo_reward_conditions?: Array<{ __typename?: 'evo_reward_condition', evo_reward_summ?: any | null, label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetRewardSummQueryVariables = Exact<{
|
||||
conditionId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetRewardSummQuery = { __typename?: 'Query', evo_reward_condition?: { __typename?: 'evo_reward_condition', evo_reward_summ?: any | null } | null };
|
||||
|
||||
export type GetFinGapAddProductTypesQueryVariables = Exact<{
|
||||
currentDate?: InputMaybe<Scalars['DateTime']>;
|
||||
}>;
|
||||
@ -301,3 +237,74 @@ export type GetCurrencyIsoCodeQueryVariables = Exact<{
|
||||
|
||||
|
||||
export type GetCurrencyIsoCodeQuery = { __typename?: 'Query', transactioncurrency?: { __typename?: 'transactioncurrency', isocurrencycode?: string | null } | null };
|
||||
|
||||
export type GetAgentAccountIdFromLeadQueryVariables = Exact<{
|
||||
leadid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetAgentAccountIdFromLeadQuery = { __typename?: 'Query', lead?: { __typename?: 'lead', agentid?: any | null } | null };
|
||||
|
||||
export type GetDoubleAgentAccountIdQueryVariables = Exact<{
|
||||
leadid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetDoubleAgentAccountIdQuery = { __typename?: 'Query', lead?: { __typename?: 'lead', agentid?: any | null } | null };
|
||||
|
||||
export type GetBrokerAccountIdQueryVariables = Exact<{
|
||||
leadid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetBrokerAccountIdQuery = { __typename?: 'Query', lead?: { __typename?: 'lead', agentid?: any | null } | null };
|
||||
|
||||
export type GetFinDepartmentAccountIdQueryVariables = Exact<{
|
||||
leadid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetFinDepartmentAccountIdQuery = { __typename?: 'Query', lead?: { __typename?: 'lead', agentid?: any | null } | null };
|
||||
|
||||
export type GetAgentQueryVariables = Exact<{
|
||||
agentid: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetAgentQuery = { __typename?: 'Query', agent?: { __typename?: 'account', label?: string | null, value?: any | null } | null };
|
||||
|
||||
export type GetRewardConditionsQueryVariables = Exact<{
|
||||
agentid: Scalars['Uuid'];
|
||||
currentDate?: InputMaybe<Scalars['DateTime']>;
|
||||
}>;
|
||||
|
||||
|
||||
export type GetRewardConditionsQuery = { __typename?: 'Query', evo_reward_conditions?: Array<{ __typename?: 'evo_reward_condition', evo_reward_summ?: any | null, label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetRewardSummQueryVariables = Exact<{
|
||||
conditionId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetRewardSummQuery = { __typename?: 'Query', evo_reward_condition?: { __typename?: 'evo_reward_condition', evo_reward_summ?: any | null } | null };
|
||||
|
||||
export type GetRewardWithoutOtherAgentQueryVariables = Exact<{
|
||||
conditionId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetRewardWithoutOtherAgentQuery = { __typename?: 'Query', evo_reward_condition?: { __typename?: 'evo_reward_condition', evo_agency_agreementidData?: { __typename?: 'evo_agency_agreement', evo_reward_without_other_agent?: boolean | null } | null } | null };
|
||||
|
||||
export type GetDealerPersonQueryVariables = Exact<{
|
||||
dealerId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetDealerPersonQuery = { __typename?: 'Query', salon_providers?: Array<{ __typename?: 'account', label?: string | null, value?: any | null } | null> | null };
|
||||
|
||||
export type GetBrokerAccountIdFromDealerQueryVariables = Exact<{
|
||||
dealerId: Scalars['Uuid'];
|
||||
}>;
|
||||
|
||||
|
||||
export type GetBrokerAccountIdFromDealerQuery = { __typename?: 'Query', dealer?: { __typename?: 'account', evo_broker_accountid?: any | null } | null };
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
/* eslint-disable implicit-arrow-linebreak */
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import { gql } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import type * as CRMTypes from 'graphql/crm.types';
|
||||
import { reaction } from 'mobx';
|
||||
import type RootStore from 'stores/root';
|
||||
import { makeDisposable } from 'tools/mobx';
|
||||
@ -92,6 +94,396 @@ export function fillReactions(store: RootStore, apolloClient: ApolloClient<objec
|
||||
});
|
||||
}
|
||||
|
||||
export function commonReactions(store: RootStore, apolloClient: ApolloClient<object>) {}
|
||||
export function commonReactions(store: RootStore, apolloClient: ApolloClient<object>) {
|
||||
const { $calculation } = store;
|
||||
|
||||
const QUERY_GET_REWARD_WITHOUT_OTHER_AGENT = gql`
|
||||
query GetRewardWithoutOtherAgent($conditionId: Uuid!) {
|
||||
evo_reward_condition(evo_reward_conditionid: $conditionId) {
|
||||
evo_agency_agreementidData {
|
||||
evo_reward_without_other_agent
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
/**
|
||||
* Добавить реакцию на изменение списка в поле selectDealerRewardCondition :
|
||||
Если в списке selectDealerRewardCondition есть запись,
|
||||
у которой evo_reward_condition.evo_agency_agreementid.
|
||||
Выплата без других агентов (evo_reward_without_other_agent) = True,
|
||||
то сбрасывают значение и закрываются для выбора поля:
|
||||
|
||||
selectDealerBroker
|
||||
selectIndAgent
|
||||
selectCalcDoubleAgent
|
||||
selectCalcBroker
|
||||
selectFinDepartment
|
||||
*/
|
||||
|
||||
reaction(
|
||||
() => $calculation.getElementValue('selectDealerRewardCondition'),
|
||||
async (rewardConditionId) => {
|
||||
function fillAgents() {
|
||||
const leadid = $calculation.getElementValue('selectLead');
|
||||
fillAgentsFromLead.fillIndAgent(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillCalcDoubleAgent(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillCalcBroker(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillFinDepartment(store, apolloClient, leadid);
|
||||
}
|
||||
|
||||
if (!rewardConditionId) {
|
||||
fillAgents();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_reward_condition },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetRewardWithoutOtherAgentQuery,
|
||||
CRMTypes.GetRewardWithoutOtherAgentQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_REWARD_WITHOUT_OTHER_AGENT,
|
||||
variables: {
|
||||
conditionId: rewardConditionId,
|
||||
},
|
||||
});
|
||||
|
||||
if (evo_reward_condition?.evo_agency_agreementidData?.evo_reward_without_other_agent) {
|
||||
$calculation.resetElement('selectDealerBroker');
|
||||
$calculation.resetElement('selectIndAgent');
|
||||
$calculation.resetElement('selectCalcDoubleAgent');
|
||||
$calculation.resetElement('selectCalcBroker');
|
||||
$calculation.resetElement('selectCalcFinDepartment');
|
||||
} else {
|
||||
fillAgents();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Добавить реакцию на изменение списка в поле selectDealerBrokerRewardCondition :
|
||||
|
||||
Если в списке selectDealerBrokerRewardCondition есть запись,
|
||||
у которой evo_reward_condition.evo_agency_agreementid.
|
||||
Выплата без других агентов (evo_reward_without_other_agent) = True,
|
||||
то сбрасывают значение и закрываются для выбора поля:
|
||||
|
||||
selectDealerPerson (не обнуляем)
|
||||
selectIndAgent
|
||||
selectCalcDoubleAgent
|
||||
selectCalcBroker
|
||||
selectFinDepartment
|
||||
иначе
|
||||
|
||||
selectDealerPerson открываем для редактирования
|
||||
selectIndAgent заполняется значением из Интереса
|
||||
selectCalcDoubleAgent заполняется значением из Интереса
|
||||
selectCalcBrokerRewardCondition заполняется значением из Интереса
|
||||
selectFinDepartmentRewardCondtion заполняется значением из Интереса
|
||||
*/
|
||||
reaction(
|
||||
() => $calculation.getElementValue('selectDealerBrokerRewardCondition'),
|
||||
async (rewardConditionId) => {
|
||||
function fillAgents() {
|
||||
const leadid = $calculation.getElementValue('selectLead');
|
||||
fillAgentsFromLead.fillIndAgent(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillCalcDoubleAgent(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillCalcBroker(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillFinDepartment(store, apolloClient, leadid);
|
||||
}
|
||||
|
||||
if (!rewardConditionId) {
|
||||
fillAgents();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_reward_condition },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetRewardWithoutOtherAgentQuery,
|
||||
CRMTypes.GetRewardWithoutOtherAgentQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_REWARD_WITHOUT_OTHER_AGENT,
|
||||
variables: {
|
||||
conditionId: rewardConditionId,
|
||||
},
|
||||
});
|
||||
|
||||
if (evo_reward_condition?.evo_agency_agreementidData?.evo_reward_without_other_agent) {
|
||||
$calculation.blockElement('selectDealerPerson');
|
||||
|
||||
$calculation.resetElement('selectIndAgent');
|
||||
$calculation.resetElement('selectCalcDoubleAgent');
|
||||
$calculation.resetElement('selectCalcBroker');
|
||||
$calculation.resetElement('selectCalcFinDepartment');
|
||||
} else {
|
||||
$calculation.unblockElement('selectDealerPerson');
|
||||
fillAgents();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Добавить реакцию на изменение списка в поле selectIndAgentRewardCondition :
|
||||
|
||||
Если в списке selectIndAgentRewardCondition есть запись,
|
||||
у которой evo_reward_condition.evo_agency_agreementid.
|
||||
Выплата без других агентов (evo_reward_without_other_agent) = True,
|
||||
то сбрасывают значение и закрываются для выбора поля:
|
||||
|
||||
selectDealerPerson (не обнуляем)
|
||||
selectDealerBroker
|
||||
selectCalcDoubleAgent
|
||||
selectCalcBroker
|
||||
selectFinDepartment
|
||||
иначе
|
||||
|
||||
selectDealerPerson открываем для редактирования
|
||||
selectDealerBroker открываем для редактирования
|
||||
selectCalcDoubleAgent заполняется значением из Интереса
|
||||
selectCalcBroker заполняется значением из Интереса
|
||||
selectCalcFinDepartment заполняется значением из Интереса
|
||||
*/
|
||||
|
||||
reaction(
|
||||
() => $calculation.getElementValue('selectIndAgentRewardCondition'),
|
||||
async (rewardConditionId) => {
|
||||
function fillAgents() {
|
||||
const leadid = $calculation.getElementValue('selectLead');
|
||||
fillAgentsFromLead.fillCalcDoubleAgent(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillCalcBroker(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillFinDepartment(store, apolloClient, leadid);
|
||||
}
|
||||
|
||||
if (!rewardConditionId) {
|
||||
fillAgents();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_reward_condition },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetRewardWithoutOtherAgentQuery,
|
||||
CRMTypes.GetRewardWithoutOtherAgentQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_REWARD_WITHOUT_OTHER_AGENT,
|
||||
variables: {
|
||||
conditionId: rewardConditionId,
|
||||
},
|
||||
});
|
||||
|
||||
if (evo_reward_condition?.evo_agency_agreementidData?.evo_reward_without_other_agent) {
|
||||
$calculation.blockElement('selectDealerPerson');
|
||||
|
||||
$calculation.resetElement('selectDealerBroker');
|
||||
$calculation.resetElement('selectCalcDoubleAgent');
|
||||
$calculation.resetElement('selectCalcBroker');
|
||||
$calculation.resetElement('selectCalcFinDepartment');
|
||||
} else {
|
||||
$calculation.unblockElement('selectDealerPerson');
|
||||
fillAgents();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Добавить реакцию на изменение списка в поле selectCalcDoubleAgentRewardCondition :
|
||||
|
||||
Если в списке selectCalcDoubleAgentRewardCondition есть запись,
|
||||
у которой evo_reward_condition.evo_agency_agreementid.
|
||||
Выплата без других агентов (evo_reward_without_other_agent) = True,
|
||||
то сбрасывают значение и закрываются для выбора поля:
|
||||
|
||||
selectDealerPerson (не обнуляем)
|
||||
selectDealerBroker
|
||||
selectIndAgent
|
||||
selectCalcBroker
|
||||
selectCalcFinDepartment
|
||||
иначе
|
||||
|
||||
selectDealerPerson открываем для редактирования
|
||||
selectDealerBroker открываем для редактирования
|
||||
selectIndAgent заполняется значением из Интереса
|
||||
selectCalcBroker заполняется значением из Интереса
|
||||
selectCalcFinDepartment заполняется значением из Интереса
|
||||
*/
|
||||
|
||||
reaction(
|
||||
() => $calculation.getElementValue('selectCalcDoubleAgentRewardCondition'),
|
||||
async (rewardConditionId) => {
|
||||
function fillAgents() {
|
||||
const leadid = $calculation.getElementValue('selectLead');
|
||||
fillAgentsFromLead.fillIndAgent(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillCalcBroker(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillFinDepartment(store, apolloClient, leadid);
|
||||
}
|
||||
|
||||
if (!rewardConditionId) {
|
||||
fillAgents();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_reward_condition },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetRewardWithoutOtherAgentQuery,
|
||||
CRMTypes.GetRewardWithoutOtherAgentQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_REWARD_WITHOUT_OTHER_AGENT,
|
||||
variables: {
|
||||
conditionId: rewardConditionId,
|
||||
},
|
||||
});
|
||||
|
||||
if (evo_reward_condition?.evo_agency_agreementidData?.evo_reward_without_other_agent) {
|
||||
$calculation.blockElement('selectDealerPerson');
|
||||
|
||||
$calculation.resetElement('selectDealerBroker');
|
||||
$calculation.resetElement('selectIndAgent');
|
||||
$calculation.resetElement('selectCalcBroker');
|
||||
$calculation.resetElement('selectCalcFinDepartment');
|
||||
} else {
|
||||
$calculation.unblockElement('selectDealerPerson');
|
||||
$calculation.unblockElement('selectDealerBroker');
|
||||
fillAgents();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* @description
|
||||
* Добавить реакцию на изменение списка в поле selectCalcBrokerRewardCondition:
|
||||
|
||||
Если в списке selectCalcBrokerRewardCondition есть запись,
|
||||
у которой evo_reward_condition.evo_agency_agreementid.
|
||||
Выплата без других агентов (evo_reward_without_other_agent) = True,
|
||||
то сбрасывают значение и закрываются для выбора поля:
|
||||
|
||||
selectDealerPerson (не обнуляем)
|
||||
selectDealerBroker
|
||||
selectIndAgent
|
||||
selectCalcDoubleAgent
|
||||
selectCalcFinDepartment
|
||||
иначе
|
||||
|
||||
selectDealerPerson открываем для редактирования
|
||||
selectDealerBroker открываем для редактирования
|
||||
selectIndAgent заполняется значением из Интереса
|
||||
selectCalcDoubleAgent заполняется значением из Интереса
|
||||
selectCalcFinDepartment заполняется значением из Интереса
|
||||
*/
|
||||
reaction(
|
||||
() => $calculation.getElementValue('selectCalcBrokerRewardCondition'),
|
||||
async (rewardConditionId) => {
|
||||
function fillAgents() {
|
||||
const leadid = $calculation.getElementValue('selectLead');
|
||||
fillAgentsFromLead.fillIndAgent(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillCalcDoubleAgent(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillFinDepartment(store, apolloClient, leadid);
|
||||
}
|
||||
|
||||
if (!rewardConditionId) {
|
||||
fillAgents();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_reward_condition },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetRewardWithoutOtherAgentQuery,
|
||||
CRMTypes.GetRewardWithoutOtherAgentQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_REWARD_WITHOUT_OTHER_AGENT,
|
||||
variables: {
|
||||
conditionId: rewardConditionId,
|
||||
},
|
||||
});
|
||||
|
||||
if (evo_reward_condition?.evo_agency_agreementidData?.evo_reward_without_other_agent) {
|
||||
$calculation.blockElement('selectDealerPerson');
|
||||
|
||||
$calculation.resetElement('selectDealerBroker');
|
||||
$calculation.resetElement('selectIndAgent');
|
||||
$calculation.resetElement('selectCalcDoubleAgent');
|
||||
$calculation.resetElement('selectCalcFinDepartment');
|
||||
} else {
|
||||
$calculation.unblockElement('selectDealerPerson');
|
||||
$calculation.unblockElement('selectDealerBroker');
|
||||
fillAgents();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Добавить реакцию на изменение списка в поле selectFinDepartmentRewardCondtion:
|
||||
|
||||
Если в списке selectFinDepartmentRewardCondtion есть запись,
|
||||
у которой evo_reward_condition.evo_agency_agreementid.
|
||||
Выплата без других агентов (evo_reward_without_other_agent) = True,
|
||||
то сбрасывают значение и закрываются для выбора поля:
|
||||
|
||||
selectDealerPerson (не обнуляем)
|
||||
selectDealerBroker
|
||||
selectIndAgent
|
||||
selectCalcDoubleAgent
|
||||
selectCalcBroker
|
||||
иначе
|
||||
|
||||
selectDealerPerson открываем для редактирования
|
||||
selectDealerBroker открываем для редактирования
|
||||
selectIndAgent заполняется значением из Интереса
|
||||
selectCalcDoubleAgent заполняется значением из Интереса
|
||||
selectCalcBroker заполняется значением из Интереса
|
||||
*/
|
||||
|
||||
reaction(
|
||||
() => $calculation.getElementValue('selectFinDepartmentRewardCondtion'),
|
||||
async (rewardConditionId) => {
|
||||
function fillAgents() {
|
||||
const leadid = $calculation.getElementValue('selectLead');
|
||||
fillAgentsFromLead.fillIndAgent(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillCalcDoubleAgent(store, apolloClient, leadid);
|
||||
fillAgentsFromLead.fillFinDepartment(store, apolloClient, leadid);
|
||||
}
|
||||
|
||||
if (!rewardConditionId) {
|
||||
fillAgents();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_reward_condition },
|
||||
} = await apolloClient.query<
|
||||
CRMTypes.GetRewardWithoutOtherAgentQuery,
|
||||
CRMTypes.GetRewardWithoutOtherAgentQueryVariables
|
||||
>({
|
||||
query: QUERY_GET_REWARD_WITHOUT_OTHER_AGENT,
|
||||
variables: {
|
||||
conditionId: rewardConditionId,
|
||||
},
|
||||
});
|
||||
|
||||
if (evo_reward_condition?.evo_agency_agreementidData?.evo_reward_without_other_agent) {
|
||||
$calculation.blockElement('selectDealerPerson');
|
||||
|
||||
$calculation.resetElement('selectDealerBroker');
|
||||
$calculation.resetElement('selectIndAgent');
|
||||
$calculation.resetElement('selectCalcDoubleAgent');
|
||||
$calculation.resetElement('selectCalcBroker');
|
||||
} else {
|
||||
$calculation.unblockElement('selectDealerPerson');
|
||||
$calculation.unblockElement('selectDealerBroker');
|
||||
fillAgents();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function validationReactions(store: RootStore, apolloClient: ApolloClient<object>) {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user