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) {