for db21b16: валидация перед расчетом по пропсам
This commit is contained in:
parent
db21b16c6f
commit
9c87172a58
@ -209,12 +209,12 @@ const elementsProps: Partial<Record<AllElementsNames, ElementProps>> = {
|
||||
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<Record<ElementsNames, ElementProps>> =
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
console.table(numberElementsProps)
|
||||
|
||||
const moneyResultElementsProps = (
|
||||
[
|
||||
'labelResultTotalGraphwithNDS',
|
||||
|
||||
@ -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<Record<ElementsNames, ValidationCondition>>,
|
||||
);
|
||||
|
||||
const conditions = Object.assign(
|
||||
{},
|
||||
customConditions,
|
||||
elementsConditions,
|
||||
entityElementsConditions,
|
||||
numberElementsConditions,
|
||||
);
|
||||
|
||||
export default function (this: ICalculationStore) {
|
||||
|
||||
Reference in New Issue
Block a user