From 9c87172a58de00ef6f839b3cdd057e82aadc854d Mon Sep 17 00:00:00 2001 From: Chika Date: Thu, 3 Feb 2022 17:00:06 +0300 Subject: [PATCH] =?UTF-8?q?for=20db21b16:=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=20?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D1=87=D0=B5=D1=82=D0=BE=D0=BC=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=BF=D1=81=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Calculation/Elements/props/common.ts | 10 ++++++---- .../actions/calculate/validate/elements.ts | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/client/Containers/Calculation/Elements/props/common.ts b/src/client/Containers/Calculation/Elements/props/common.ts index ad4e565..13aba13 100644 --- a/src/client/Containers/Calculation/Elements/props/common.ts +++ b/src/client/Containers/Calculation/Elements/props/common.ts @@ -209,12 +209,12 @@ const elementsProps: Partial> = { formatter: formatNumber, }, tbxInsAgeDrivers: { - min: '18', - max: '99', + // min: '18', + // max: '99', }, tbxInsExpDrivers: { - min: '0', - max: '99', + // min: '0', + // max: '99', }, selectRegionRegistration: { showSearch: true, @@ -348,6 +348,8 @@ export const numberElementsProps: Partial> = return acc; }, {}); + console.table(numberElementsProps) + const moneyResultElementsProps = ( [ 'labelResultTotalGraphwithNDS', diff --git a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts index 4bfff21..546e875 100644 --- a/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts +++ b/src/client/stores/CalculationStore/Effects/actions/calculate/validate/elements.ts @@ -1,3 +1,4 @@ +import { numberElementsProps } from 'client/Containers/Calculation/Elements/props/common'; import { getValueName } from 'client/Containers/Calculation/Elements/tools'; import { ElementsNames } from 'client/Containers/Calculation/types/elements'; import { pipe } from 'core/tools/func'; @@ -192,11 +193,30 @@ const entityElementsConditions = ( {}, ); +/** Проверяем по настройкам полей min max */ +const numberElementsConditions = Object.keys(numberElementsProps).reduce( + (acc, elem) => { + acc[elem] = (calculationStore, elementName) => { + const valueName = getValueName(elementName); + const value = calculationStore.getValue(valueName); + const { min, max } = numberElementsProps[elem]; + return { + isValid: + (min === undefined || value >= min) && + (max === undefined || value <= max), + }; + }; + return acc; + }, + {} as Partial>, +); + const conditions = Object.assign( {}, customConditions, elementsConditions, entityElementsConditions, + numberElementsConditions, ); export default function (this: ICalculationStore) {