fix set validation tbxCountSeats tbxMaxMass
This commit is contained in:
parent
7724ee1906
commit
abb5b879a9
@ -199,115 +199,6 @@ const autorunEffects: IAutorunEffect[] = [
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
calculationStore => () => {
|
||||
const { leaseObjectType: leaseObjectTypeId } = calculationStore.values;
|
||||
|
||||
calculationStore.setValidation('tbxCountSeats', true);
|
||||
calculationStore.setValidation('tbxMaxMass', true);
|
||||
|
||||
if (!leaseObjectTypeId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const leaseObjectType = calculationStore.options.selectLeaseObjectType?.find(
|
||||
x => x.evo_leasingobject_typeid === leaseObjectTypeId,
|
||||
);
|
||||
|
||||
if (leaseObjectType) {
|
||||
switch (leaseObjectType.evo_id) {
|
||||
case '1': {
|
||||
calculationStore.setValue('leaseObjectCategory', 100000001);
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Disabled,
|
||||
);
|
||||
|
||||
const { countSeats } = calculationStore.values;
|
||||
if (countSeats && countSeats >= 9) {
|
||||
calculationStore.setValidation('tbxCountSeats', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка',
|
||||
description: 'Количество мест должно быть меньше 9',
|
||||
})();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case '2': {
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Default,
|
||||
);
|
||||
calculationStore.setFilter('selectLeaseObjectCategory', options =>
|
||||
options.filter(x => x.value === 100000001 || x.value === 100000002),
|
||||
);
|
||||
|
||||
const { maxMass } = calculationStore.values;
|
||||
if (!maxMass) {
|
||||
calculationStore.setValidation('tbxMaxMass', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка',
|
||||
description:
|
||||
'Разрешенная максимальная масса должна быть больше 0',
|
||||
})();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case '4':
|
||||
case '5': {
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Default,
|
||||
);
|
||||
calculationStore.setFilter('selectLeaseObjectCategory', options =>
|
||||
options.filter(x => x.value === 100000001 || x.value === 100000003),
|
||||
);
|
||||
|
||||
const { countSeats } = calculationStore.values;
|
||||
if (countSeats <= 8) {
|
||||
calculationStore.setValidation('tbxCountSeats', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка',
|
||||
description: 'Кол-во мест должно быть больше 8',
|
||||
})();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case '3':
|
||||
case '7': {
|
||||
calculationStore.setValue('leaseObjectCategory', 100000002);
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Disabled,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
case '8': {
|
||||
calculationStore.setValue('leaseObjectCategory', 100000004);
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Disabled,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Default,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
export default autorunEffects;
|
||||
|
||||
@ -1643,7 +1643,7 @@ const reactionEffects: IReactionEffect[] = [
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const { selectLeaseObjectCategory } = calculationStore.filters;
|
||||
@ -1660,6 +1660,127 @@ const reactionEffects: IReactionEffect[] = [
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
calculationStore => ({
|
||||
expression: () => {
|
||||
const {
|
||||
leaseObjectType: leaseObjectTypeId,
|
||||
countSeats,
|
||||
maxMass,
|
||||
} = calculationStore.values;
|
||||
return { leaseObjectTypeId, countSeats, maxMass };
|
||||
},
|
||||
effect: ({ leaseObjectTypeId, countSeats, maxMass }) => {
|
||||
calculationStore.setValidation('tbxCountSeats', undefined);
|
||||
calculationStore.setValidation('tbxMaxMass', undefined);
|
||||
|
||||
if (!leaseObjectTypeId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const leaseObjectType = calculationStore.options.selectLeaseObjectType?.find(
|
||||
x => x.evo_leasingobject_typeid === leaseObjectTypeId,
|
||||
);
|
||||
|
||||
if (leaseObjectType) {
|
||||
switch (leaseObjectType.evo_id) {
|
||||
case '1': {
|
||||
calculationStore.setValue('leaseObjectCategory', 100000001);
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Disabled,
|
||||
);
|
||||
|
||||
const { countSeats } = calculationStore.values;
|
||||
if (countSeats && countSeats >= 9) {
|
||||
calculationStore.setValidation('tbxCountSeats', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка',
|
||||
description: 'Количество мест должно быть меньше 9',
|
||||
})();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case '2': {
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Default,
|
||||
);
|
||||
calculationStore.setFilter('selectLeaseObjectCategory', options =>
|
||||
options.filter(
|
||||
x => x.value === 100000001 || x.value === 100000002,
|
||||
),
|
||||
);
|
||||
|
||||
const { maxMass } = calculationStore.values;
|
||||
if (!maxMass) {
|
||||
calculationStore.setValidation('tbxMaxMass', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка',
|
||||
description:
|
||||
'Разрешенная максимальная масса должна быть больше 0',
|
||||
})();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case '4':
|
||||
case '5': {
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Default,
|
||||
);
|
||||
calculationStore.setFilter('selectLeaseObjectCategory', options =>
|
||||
options.filter(
|
||||
x => x.value === 100000001 || x.value === 100000003,
|
||||
),
|
||||
);
|
||||
|
||||
const { countSeats } = calculationStore.values;
|
||||
if (countSeats <= 8) {
|
||||
calculationStore.setValidation('tbxCountSeats', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка',
|
||||
description: 'Кол-во мест должно быть больше 8',
|
||||
})();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case '3':
|
||||
case '7': {
|
||||
calculationStore.setValue('leaseObjectCategory', 100000002);
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Disabled,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
case '8': {
|
||||
calculationStore.setValue('leaseObjectCategory', 100000004);
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Disabled,
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
calculationStore.setStatus(
|
||||
'selectLeaseObjectCategory',
|
||||
ElementStatus.Default,
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
export default reactionEffects;
|
||||
|
||||
Reference in New Issue
Block a user