diff --git a/src/client/Containers/Calculation/Components/Sections/sectionsList.ts b/src/client/Containers/Calculation/Components/Sections/sectionsList.ts index 402f4ab..8284e9d 100644 --- a/src/client/Containers/Calculation/Components/Sections/sectionsList.ts +++ b/src/client/Containers/Calculation/Components/Sections/sectionsList.ts @@ -328,7 +328,7 @@ const sections: ISection[] = [ { elements: [ 'selectTechnicalCard', - // 'selectFuelCard', + 'selectFuelCard', 'selectInsNSIB', 'radioRequirementTelematic', 'selectTracker', diff --git a/src/client/stores/CalculationStore/Data/values.js b/src/client/stores/CalculationStore/Data/values.js index 6d4cd52..166a4c6 100644 --- a/src/client/stores/CalculationStore/Data/values.js +++ b/src/client/stores/CalculationStore/Data/values.js @@ -1,6 +1,7 @@ import { getValueName } from 'client/Containers/Calculation/Elements/tools'; import initialFilters, { - noResetValueElements + autoSetValuesElements, + noResetValueElements, } from 'client/stores/CalculationStore/config/initialFilters'; import initialStatuses from 'client/stores/CalculationStore/config/initialStatuses'; import { isNil, mergeWith, pick } from 'lodash'; @@ -112,13 +113,23 @@ const valuesActions = { setFilter(elementName, filter) { const valueName = getValueName(elementName); const value = this.getValue(valueName); + + const filteredOptions = filter && filter(this.getOptions(elementName)); + // После установки фильтра проверяем, что значение есть в отфильтрованном списке, иначе сбрасываем значение if ( - filter && - !filter(this.getOptions(elementName)).some(x => x.value === value) && + !filteredOptions?.some(x => x.value === value) && !noResetValueElements.includes(elementName) ) { this.setValue(valueName, null); } + + // После установки фильтра если остается одна запись указываем ее в значение + if ( + autoSetValuesElements.includes(elementName) && + filteredOptions?.length === 1 + ) { + this.setValue(valueName, filteredOptions[0].value); + } this.filters[elementName] = filter; }, // applyFilters(filters) { diff --git a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts index 1b37230..c38fe27 100644 --- a/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts +++ b/src/client/stores/CalculationStore/Effects/reactions/recalcWoRevisionReactions.ts @@ -492,17 +492,6 @@ const reactionEffects: IReactionEffect[] = [ ), ), ); - - if (!calculationProcess.hasProcess(Process.LoadKp)) { - const elementOptions = calculationStore.getOptions( - elementName, - undefined, - true, - ); - //TODO: удалить после рефактора CalculationStore - if (elementOptions?.length === 1) - calculationStore.setValue(valueName, elementOptions[0].value); - } }); }, options: { diff --git a/src/client/stores/CalculationStore/config/initialFilters.ts b/src/client/stores/CalculationStore/config/initialFilters.ts index 2f0fdc4..b7e04c8 100644 --- a/src/client/stores/CalculationStore/config/initialFilters.ts +++ b/src/client/stores/CalculationStore/config/initialFilters.ts @@ -4,5 +4,18 @@ import { TElementFilter } from 'core/types/Calculation/Store/filters'; const initialFilters: Partial> = {}; export const noResetValueElements: ElementsNames[] = ['selectTechnicalCard']; +export const autoSetValuesElements: ElementsNames[] = [ + 'selectProduct', + 'selectLeaseObjectType', + 'selectBrand', + 'selectModel', + 'selectConfiguration', + 'selectTracker', + 'selectTelematic', + 'selectTechnicalCard', + 'selectFuelCard', + 'selectRegistration', + 'selectTownRegistration', +]; export default initialFilters;