From 6651d118e5b6ede1c81ab3c919fb3da710fe1d4b Mon Sep 17 00:00:00 2001 From: Chika Date: Wed, 13 Jul 2022 14:58:07 +0300 Subject: [PATCH] =?UTF-8?q?process/lead-opportunity:=20=D0=95=D1=81=D0=BB?= =?UTF-8?q?=D0=B8=20lead=20=D1=81=D0=BE=D0=B4=D0=B5=D1=80=D0=B6=D0=B8?= =?UTF-8?q?=D1=82=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5,=20=20=20=20=20?= =?UTF-8?q?=D0=A2=D0=BE=20=D0=B2=20quote=20=D0=BF=D0=BE=D0=B4=D0=B3=D1=80?= =?UTF-8?q?=D1=83=D0=B6=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D1=81=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=BE=D0=BA=20=D0=9F=D1=80=D0=B5=D0=B4=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B9=20CRM=20(=D1=81=D1=83=D1=89=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20quote),=20=20=20=20=20=D1=83=20?= =?UTF-8?q?=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B=D1=85=20=D0=B2=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=B5=20=D0=98=D0=BD=D1=82=D0=B5=D1=80=D0=B5=D1=81?= =?UTF-8?q?=20(quote.evo=5Fleadid)=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B0?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B2=D1=8B=D0=B1=D1=80=D0=B0=D0=BD=D0=BD=D1=8B=D0=B9?= =?UTF-8?q?=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D0=B5=D1=81.=20=20=20=20=20?= =?UTF-8?q?=D0=98=D0=BD=D0=B0=D1=87=D0=B5=20=D0=BE=D1=87=D0=B8=D1=89=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BF=D0=BE=D0=BB=D0=B5=20=D0=BA=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BA=D1=83=D0=BB=D1=8F=D1=82=D0=BE=D1=80=D0=B0=20quote.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__generated__/GetQuotesByLead.ts | 25 ++++++++++++ process/lead-opportunity/reactions/common.ts | 38 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 process/lead-opportunity/reactions/__generated__/GetQuotesByLead.ts diff --git a/process/lead-opportunity/reactions/__generated__/GetQuotesByLead.ts b/process/lead-opportunity/reactions/__generated__/GetQuotesByLead.ts new file mode 100644 index 0000000..8475ce0 --- /dev/null +++ b/process/lead-opportunity/reactions/__generated__/GetQuotesByLead.ts @@ -0,0 +1,25 @@ +/* tslint:disable */ +/* eslint-disable */ +// @generated +// This file was automatically generated and should not be edited. + +// ==================================================== +// GraphQL query operation: GetQuotesByLead +// ==================================================== + +export interface GetQuotesByLead_quotes { + __typename: "quote"; + label: string | null; + value: any | null; +} + +export interface GetQuotesByLead { + /** + * Предложения. statecode по умолчанию 0, можно отфильтровать по ownerid и/или domainName + */ + quotes: (GetQuotesByLead_quotes | null)[] | null; +} + +export interface GetQuotesByLeadVariables { + leadid: any; +} diff --git a/process/lead-opportunity/reactions/common.ts b/process/lead-opportunity/reactions/common.ts index fa998d6..5f634b2 100644 --- a/process/lead-opportunity/reactions/common.ts +++ b/process/lead-opportunity/reactions/common.ts @@ -2,8 +2,10 @@ import type { ApolloClient } from '@apollo/client'; import { gql } from '@apollo/client'; import { reaction } from 'mobx'; import type RootStore from 'stores/root'; +import { normalizeOptions } from 'tools/entity'; import type { GetLeadidByOpportunity } from './__generated__/GetLeadidByOpportunity'; import type { GetOpportunityByLead } from './__generated__/GetOpportunityByLead'; +import type { GetQuotesByLead } from './__generated__/GetQuotesByLead'; export default function commonReactions(store: RootStore, apolloClient: ApolloClient) { const { $calculation } = store; @@ -98,4 +100,40 @@ export default function commonReactions(store: RootStore, apolloClient: ApolloCl } } ); + + /** + * Если lead содержит данные, + То в quote подгружается список Предложений CRM (сущность quote), + у которых в поле Интерес (quote.evo_leadid) записана ссылка на выбранный интерес. + Иначе очищать поле калькулятора quote. + */ + + const QUERY_GET_QUOTES_BY_LEAD = gql` + query GetQuotesByLead($leadid: Uuid!) { + quotes(evo_leadid: $leadid) { + label: evo_quotename + value: quoteid + } + } + `; + + reaction( + () => $calculation.getElementValue('selectLead'), + async (leadid) => { + if (leadid) { + const { + data: { quotes }, + } = await apolloClient.query({ + query: QUERY_GET_QUOTES_BY_LEAD, + variables: { + leadid, + }, + }); + + $calculation.$options.setElementOptions('selectQuote', normalizeOptions(quotes)); + } else { + $calculation.resetElement('selectQuote'); + } + } + ); }