process/lead-opportunity:
Если lead содержит данные,
То в quote подгружается список Предложений CRM (сущность quote),
у которых в поле Интерес (quote.evo_leadid) записана ссылка на выбранный интерес.
Иначе очищать поле калькулятора quote.
This commit is contained in:
parent
2eb474e362
commit
6651d118e5
25
process/lead-opportunity/reactions/__generated__/GetQuotesByLead.ts
generated
Normal file
25
process/lead-opportunity/reactions/__generated__/GetQuotesByLead.ts
generated
Normal file
@ -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;
|
||||
}
|
||||
@ -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<object>) {
|
||||
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<GetQuotesByLead>({
|
||||
query: QUERY_GET_QUOTES_BY_LEAD,
|
||||
variables: {
|
||||
leadid,
|
||||
},
|
||||
});
|
||||
|
||||
$calculation.$options.setElementOptions('selectQuote', normalizeOptions(quotes));
|
||||
} else {
|
||||
$calculation.resetElement('selectQuote');
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user