process/agents: complete fill agents from lead

This commit is contained in:
Chika 2022-07-14 16:26:23 +03:00
parent 378d1b408d
commit 3e38446eee
6 changed files with 156 additions and 3 deletions

View File

@ -0,0 +1,22 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: GetBroker
// ====================================================
export interface GetBroker_agent {
__typename: "account";
label: string | null;
value: any | null;
}
export interface GetBroker {
agent: GetBroker_agent | null;
}
export interface GetBrokerVariables {
agentid: any;
}

View File

@ -0,0 +1,24 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: GetBrokerAccountId
// ====================================================
export interface GetBrokerAccountId_lead {
__typename: "lead";
agentid: any | null;
}
export interface GetBrokerAccountId {
/**
* Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName
*/
lead: GetBrokerAccountId_lead | null;
}
export interface GetBrokerAccountIdVariables {
leadid: any;
}

View File

@ -0,0 +1,22 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: GetFinDepartment
// ====================================================
export interface GetFinDepartment_agent {
__typename: "account";
label: string | null;
value: any | null;
}
export interface GetFinDepartment {
agent: GetFinDepartment_agent | null;
}
export interface GetFinDepartmentVariables {
agentid: any;
}

View File

@ -0,0 +1,24 @@
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.
// ====================================================
// GraphQL query operation: GetFinDepartmentAccountId
// ====================================================
export interface GetFinDepartmentAccountId_lead {
__typename: "lead";
agentid: any | null;
}
export interface GetFinDepartmentAccountId {
/**
* Лизинговые сделки. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName
*/
lead: GetFinDepartmentAccountId_lead | null;
}
export interface GetFinDepartmentAccountIdVariables {
leadid: any;
}

View File

@ -104,3 +104,62 @@ export const fillCalcDoubleAgent = fillAgent(
QUERY_GET_DOUBLE_AGENT_ACCOUNTID,
QUERY_GET_DOUBLE_AGENT
);
/**
* Если lead содержит данные, то calcBroker заполняется ссылкой на карточку Контрагент (account),
* записанную в поле Интереса "Брокер" (lead.evo_broker_accountid account)
* иначе очищать поле калькулятора calcBroker
*/
const QUERY_GET_BROKER_ACCOUNTID = gql`
query GetBrokerAccountId($leadid: Uuid!) {
lead(leadid: $leadid) {
agentid: evo_broker_accountid
}
}
`;
const QUERY_GET_BROKER = gql`
query GetBroker($agentid: Uuid!) {
agent: account(accountid: $agentid) {
label: name
value: accountid
}
}
`;
export const fillCalcBroker = fillAgent(
'selectCalcBroker',
QUERY_GET_BROKER_ACCOUNTID,
QUERY_GET_BROKER
);
/**
* если lead содержит данные, то calcFinDepartment заполняется ссылкой
* на карточку Контрагент (account),
* записанную в поле Интереса "Финотдел" (lead.evo_fin_department_accountid account)
* иначе очищать поле калькулятора calcFinDepartment
*/
const QUERY_GET_FIN_DEPARTMENT_ACCOUNTID = gql`
query GetFinDepartmentAccountId($leadid: Uuid!) {
lead(leadid: $leadid) {
agentid: evo_fin_department_accountid
}
}
`;
const QUERY_GET_FIN_DEPARTMENT = gql`
query GetFinDepartment($agentid: Uuid!) {
agent: account(accountid: $agentid) {
label: name
value: accountid
}
}
`;
export const fillFinDepartment = fillAgent(
'selectCalcFinDepartment',
QUERY_GET_FIN_DEPARTMENT_ACCOUNTID,
QUERY_GET_FIN_DEPARTMENT
);

View File

@ -1,15 +1,17 @@
import type { ApolloClient } from '@apollo/client';
import { reaction } from 'mobx';
import type RootStore from 'stores/root';
import { fillCalcDoubleAgent, fillIndAgent } from '../lib/fill-agents-from-lead';
import * as fillAgentsFromLead from '../lib/fill-agents-from-lead';
export default function commonReactions(store: RootStore, apolloClient: ApolloClient<object>) {
const { $calculation } = store;
reaction(
() => $calculation.getElementValue('selectLead'),
(leadid) => {
fillIndAgent(store, apolloClient, leadid);
fillCalcDoubleAgent(store, apolloClient, leadid);
fillAgentsFromLead.fillIndAgent(store, apolloClient, leadid);
fillAgentsFromLead.fillCalcDoubleAgent(store, apolloClient, leadid);
fillAgentsFromLead.fillCalcBroker(store, apolloClient, leadid);
fillAgentsFromLead.fillFinDepartment(store, apolloClient, leadid);
}
);
}