From 0d3aecbcd4111fc88f82534eac7d9c7c1b159637 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Wed, 11 Jan 2023 15:25:08 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80?= =?UTF-8?q?=20=D0=A1=D0=B0=D0=BB=D0=BE=D0=BD=D0=B0=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B5=D1=82=D0=B5=D0=BD=D0=B8=D1=8F=20select?= =?UTF-8?q?Dealer=20-=20=D0=9D=D0=B0=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=A1=D0=B0=D0=BB=D0=BE=D0=BD=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=D0=BE=D0=B1=D1=80=D0=B5=D1=82=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20selectDealer=20=20=D1=84=D0=BE=D1=80=D0=BC=D0=B8?= =?UTF-8?q?=D1=80=D1=83=D0=B5=D0=BC=20=D1=81=D0=BF=D0=B8=D1=81=D0=BE=D0=BA?= =?UTF-8?q?=20=D0=B2=20=D0=BF=D0=BE=D0=BB=D0=B5=20=D0=AE=D0=9B=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D1=89=D0=B8=D0=BA=D0=B0=20select?= =?UTF-8?q?DealerPerson-=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=B2=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D0=B5=20selectDealer=20=D1=83=D0=BA=D0=B0=D0=B7?= =?UTF-8?q?=D0=B0=D0=BD=20account,=20=D1=83=20=D0=BA=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=BE=D0=B3=D0=BE=20evo=5Freturn=5Fleasing=5Fdealer=20?= =?UTF-8?q?=3D=20true,=20=D1=82=D0=B5=D1=81=D1=8208.11=20-=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D0=BE=D1=82=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=BD=D0=B0=20evo=5Freturn=5Fleasing=5Fdealer=20=3D=20true,=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D0=BB=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=BA=20=D0=B8=20=D0=BD=D0=B0=20false?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit то поле selectDealerPerson обнулять и закрывать для редактирования, иначе формировать список связанных значений - записи Контрагент, у которых статус = активный И Поставщик = Да И Тип поставщика = Юридическое лицо И связаны с карточкой Контрагент из поля "Салон приобретения" по связи Салон-ЮЛ (salon_providers) --- apps/web/process/supplier-agent/lib/query.ts | 9 ++++++++- .../supplier-agent/reactions/leaseback.ts | 16 +++++----------- .../process/supplier-agent/reactions/supplier.ts | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/apps/web/process/supplier-agent/lib/query.ts b/apps/web/process/supplier-agent/lib/query.ts index 79482d8..e487114 100644 --- a/apps/web/process/supplier-agent/lib/query.ts +++ b/apps/web/process/supplier-agent/lib/query.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/prefer-default-export */ import { gql } from '@apollo/client'; export const QUERY_GET_AGENT = gql` @@ -9,3 +8,11 @@ export const QUERY_GET_AGENT = gql` } } `; + +export const QUERY_GET_DEALER_RETURN_LEASING = gql` + query GetDealerReturnLeasing($dealerId: Uuid!) { + dealer: account(accountid: $dealerId) { + evo_return_leasing_dealer + } + } +`; diff --git a/apps/web/process/supplier-agent/reactions/leaseback.ts b/apps/web/process/supplier-agent/reactions/leaseback.ts index fb644f9..de54da9 100644 --- a/apps/web/process/supplier-agent/reactions/leaseback.ts +++ b/apps/web/process/supplier-agent/reactions/leaseback.ts @@ -1,7 +1,7 @@ -import { gql } from '@apollo/client'; import type * as CRMTypes from 'graphql/crm.types'; import { reaction } from 'mobx'; import type { ReactionsContext } from 'process/types'; +import * as query from '../lib/query'; export default function leasebackReactions({ store, apolloClient }: ReactionsContext) { const { $calculation, $tables } = store; @@ -20,14 +20,6 @@ export default function leasebackReactions({ store, apolloClient }: ReactionsCon 3) ПЛ БУ cbxLeaseObjectUsed = true */ - const QUERY_GET_DEALER_RETURN_LEASING = gql` - query GetDealerReturnLeasing($dealerId: Uuid!) { - dealer: account(accountid: $dealerId) { - evo_return_leasing_dealer - } - } - `; - reaction( () => $calculation.element('selectDealer').getValue(), async (dealerId) => { @@ -39,16 +31,18 @@ export default function leasebackReactions({ store, apolloClient }: ReactionsCon CRMTypes.GetDealerReturnLeasingQuery, CRMTypes.GetDealerReturnLeasingQueryVariables >({ - query: QUERY_GET_DEALER_RETURN_LEASING, + query: query.QUERY_GET_DEALER_RETURN_LEASING, variables: { dealerId, }, }); if (dealer?.evo_return_leasing_dealer === true) { + $calculation.element('selectDealerPerson').block().resetValue(); $tables.insurance.row('kasko').setValue('insured', 100_000_000).block('insured'); $calculation.element('cbxLeaseObjectUsed').setValue(true); } else { + $calculation.element('selectDealerPerson').unblock(); $tables.insurance.row('kasko').resetStatus('insured'); } } @@ -71,7 +65,7 @@ export default function leasebackReactions({ store, apolloClient }: ReactionsCon CRMTypes.GetDealerReturnLeasingQuery, CRMTypes.GetDealerReturnLeasingQueryVariables >({ - query: QUERY_GET_DEALER_RETURN_LEASING, + query: query.QUERY_GET_DEALER_RETURN_LEASING, variables: { dealerId, }, diff --git a/apps/web/process/supplier-agent/reactions/supplier.ts b/apps/web/process/supplier-agent/reactions/supplier.ts index 435cadb..9d702f4 100644 --- a/apps/web/process/supplier-agent/reactions/supplier.ts +++ b/apps/web/process/supplier-agent/reactions/supplier.ts @@ -43,6 +43,22 @@ export function commonReactions({ store, apolloClient }: ReactionsContext) { return; } + const { + data: { dealer }, + } = await apolloClient.query< + CRMTypes.GetDealerReturnLeasingQuery, + CRMTypes.GetDealerReturnLeasingQueryVariables + >({ + query: query.QUERY_GET_DEALER_RETURN_LEASING, + variables: { + dealerId, + }, + }); + + if (dealer?.evo_return_leasing_dealer) { + return; + } + const { data: { salon_providers }, } = await apolloClient.query<