From 88aa991f0f326298db7162836d79658c5331996c Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Mon, 16 Jan 2023 15:38:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8E=20=D0=BD=D0=B0=20=D0=BA=D0=BD=D0=BE=D0=BF?= =?UTF-8?q?=D0=BA=D1=83=20=D0=A0=D0=B0=D1=81=D1=81=D1=87=D0=B8=D1=82=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B2=D0=BD=D0=B5=D1=81=D1=82=D0=B8=20=D0=B8?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5:=20=20=20=20?= =?UTF-8?q?=201)=20=D0=BF=D0=BE=D0=BB=D0=B5=20selectDealerPerson=20=D1=83?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D1=82=D1=8C=20=D0=B8=D0=B7=20=D1=81=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BE=D0=B1=D1=8F=D0=B7=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D1=87=D0=B5=D1=82=D0=B0=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B9=20=20=20=20=202)=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8E=20=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=BB=D0=B5=20select?= =?UTF-8?q?DealerPerson=20:=20=20=20=20=20=D0=95=D1=81=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=B2=20=D0=BF=D0=BE=D0=BB=D0=B5=20selectDealer=20=D1=83=D0=BA?= =?UTF-8?q?=D0=B0=D0=B7=D0=B0=D0=BD=20account,=20=D1=83=20=D0=BA=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=BE=D0=B3=D0=BE=20evo=5Freturn=5Fleasing?= =?UTF-8?q?=5Fdealer=20=3D=20False=20(=D0=B8=D0=BB=D0=B8=20null)=20=20=20?= =?UTF-8?q?=20=20=D0=B8=20=D0=BF=D0=BE=D0=BB=D0=B5=20selectDealerPerson=20?= =?UTF-8?q?=3D=20null,=20=D1=82=D0=BE=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=D0=BB=D0=B5=20selectDealerPerson=20=D0=BE?= =?UTF-8?q?=D0=B1=D0=B2=D0=BE=D0=B4=D0=B8=D1=82=D1=8C=20=D0=BA=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D0=BD=D0=BE=D0=B9=20=D1=80=D0=B0=D0=BC=D0=BA=D0=BE=D0=B9?= =?UTF-8?q?,=20=20=20=20=20=D0=B8=D0=BD=D0=B0=D1=87=D0=B5=20=D0=B2=D1=81?= =?UTF-8?q?=D0=B5=20=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supplier-agent/reactions/leaseback.ts | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/apps/web/process/supplier-agent/reactions/leaseback.ts b/apps/web/process/supplier-agent/reactions/leaseback.ts index de54da9..f78ab67 100644 --- a/apps/web/process/supplier-agent/reactions/leaseback.ts +++ b/apps/web/process/supplier-agent/reactions/leaseback.ts @@ -1,5 +1,6 @@ +/* eslint-disable max-len */ import type * as CRMTypes from 'graphql/crm.types'; -import { reaction } from 'mobx'; +import { autorun, reaction } from 'mobx'; import type { ReactionsContext } from 'process/types'; import * as query from '../lib/query'; @@ -80,4 +81,40 @@ export default function leasebackReactions({ store, apolloClient }: ReactionsCon } } ); + + /** + * В валидацию на кнопку Рассчитать внести изменение: + 1) поле selectDealerPerson убрать из списка обязательных для расчета полей + 2) добавить валидацию на поле selectDealerPerson : + Если в поле selectDealer указан account, у которого evo_return_leasing_dealer = False (или null) + и поле selectDealerPerson = null, то выводить ошибку и поле selectDealerPerson обводить красной рамкой, + иначе все ок + */ + + autorun(async () => { + const dealerId = $calculation.element('selectDealer').getValue(); + const dealerPersonId = $calculation.element('selectDealerPerson').getValue(); + + let returnLeasing: boolean | null | undefined; + + if (dealerId) { + const { + data: { dealer }, + } = await apolloClient.query< + CRMTypes.GetDealerReturnLeasingQuery, + CRMTypes.GetDealerReturnLeasingQueryVariables + >({ + query: query.QUERY_GET_DEALER_RETURN_LEASING, + variables: { + dealerId, + }, + }); + returnLeasing = dealer?.evo_return_leasing_dealer; + } + + $calculation.element('selectDealerPerson').validate({ + invalid: !!dealerId && !dealerPersonId && !returnLeasing, + message: 'Не заполнено поле', + }); + }); }