From aa711a3e378401dff8544871f690025b5c4df297 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Mon, 30 Jan 2023 11:45:24 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=9F=D1=80=D0=BE=D0=B4=D1=83?= =?UTF-8?q?=D0=BA=D1=82=D0=B0=20selectProduct=20=D0=BD=D0=B5=D0=BE=D0=B1?= =?UTF-8?q?=D1=85=D0=BE=D0=B4=D0=B8=D0=BC=D0=BE=20=D0=B2=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=20"=D0=A0=D0=B0=D1=81=D1=87=D0=B5=D1=82=20=D0=BE?= =?UTF-8?q?=D1=82"=20=20=20=20*=20radioCalcType=20=D1=84=D0=B8=D0=BB=D1=8C?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=B7=D0=BD=D0=B0?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=BE=D0=B3=D0=BB=D0=B0?= =?UTF-8?q?=D1=81=D0=BD=D0=BE=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D1=83=20=20?= =?UTF-8?q?=20=20*=20=D0=B2=20=D0=BF=D0=BE=D0=BB=D0=B5=20"=D0=94=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=83=D0=BF=D0=BD=D1=8B=D0=B5=20=D0=9C=D0=B5=D1=82?= =?UTF-8?q?=D0=BE=D0=B4=D1=8B=20=D1=80=D0=B0=D1=81=D1=87=D0=B5=D1=82=D0=B0?= =?UTF-8?q?=20=D0=B2=20=D0=BA=D0=B0=D0=BB=D1=8C=D0=BA=D1=83=D0=BB=D1=8F?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B5"=20evo=5Fcalculation=5Fmethod=20=D0=B2?= =?UTF-8?q?=20selectProduct?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/graphql/crm.types.ts | 2 +- .../process/configurator/reactions/filters.ts | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/apps/web/graphql/crm.types.ts b/apps/web/graphql/crm.types.ts index fb796b3..f80a04e 100644 --- a/apps/web/graphql/crm.types.ts +++ b/apps/web/graphql/crm.types.ts @@ -139,7 +139,7 @@ export type GetProduct_ProcessConfiguratorQueryVariables = Exact<{ }>; -export type GetProduct_ProcessConfiguratorQuery = { __typename?: 'Query', evo_baseproduct: { __typename?: 'evo_baseproduct', evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null } | null }; +export type GetProduct_ProcessConfiguratorQuery = { __typename?: 'Query', evo_baseproduct: { __typename?: 'evo_baseproduct', evo_calculation_method: Array | null, evo_leasingobject_types: Array<{ __typename?: 'evo_leasingobject_type', evo_leasingobject_typeid: string | null } | null> | null } | null }; export type GetSubsidy_ProcessConfiguratorQueryVariables = Exact<{ subsidyId: Scalars['Uuid']; diff --git a/apps/web/process/configurator/reactions/filters.ts b/apps/web/process/configurator/reactions/filters.ts index d140f2e..00116be 100644 --- a/apps/web/process/configurator/reactions/filters.ts +++ b/apps/web/process/configurator/reactions/filters.ts @@ -24,6 +24,7 @@ const QUERY_GET_PRODUCT = gql` evo_leasingobject_types { evo_leasingobject_typeid } + evo_calculation_method } } `; @@ -349,4 +350,42 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex $calculation.element('selectSeasonType').setOptions(filteredSeasonTypesOptions); } ); + + /** + * При изменении Продукта selectProduct необходимо в поле "Расчет от" + * radioCalcType фильтровать значения согласно списку + * в поле "Доступные Методы расчета в калькуляторе" evo_calculation_method в selectProduct + */ + reaction( + () => $calculation.element('selectProduct').getValue(), + async (productId) => { + if (!productId) { + $calculation.element('radioCalcType').resetOptions(); + + return; + } + + const { + data: { evo_baseproduct }, + } = await apolloClient.query< + CRMTypes.GetProduct_ProcessConfiguratorQuery, + CRMTypes.GetProduct_ProcessConfiguratorQueryVariables + >({ + query: QUERY_GET_PRODUCT, + variables: { + productId, + }, + }); + + if (evo_baseproduct?.evo_calculation_method) { + const filteredCalcTypeOptions = $calculation + .element('radioCalcType') + .getOptions() + .filter((calcType) => evo_baseproduct.evo_calculation_method?.includes(calcType.value)); + $calculation.element('radioCalcType').setOptions(filteredCalcTypeOptions); + } else { + $calculation.element('radioCalcType').resetOptions(); + } + } + ); }