diff --git a/components/calcValues.vue b/components/calcValues.vue index 210f7f5..9d08b18 100644 --- a/components/calcValues.vue +++ b/components/calcValues.vue @@ -9,23 +9,26 @@ const lamelle_color = useState('lamelle_color', () => '1002') const section_count = useState('section_count', () => 1) const extra_section = useState('extra_section', () => 0) -const parametric = { - length: { - min: 1000, - max: 2400, - step: 1, - }, - total_length: { - min: 1, - max: undefined, - step: 0.1, - }, - height: { - min: 675, - max: 2400, - step: 115, +const parametric_state = useState('parametric', () => { + return { + length: { + min: 1000, + max: 2400, + step: 1, + }, + total_length: { + min: 1, + max: undefined, + step: 0.1, + }, + height: { + min: 675, + max: 2400, + step: 115, + } } -} +}) +const parametric = parametric_state.value const form_state = reactive({ length: fence_section.value * 1000, fence_length: 100, @@ -35,11 +38,6 @@ const form_state = reactive({ full_sections: 1, extra_section: 0 }) -const form_errors = reactive({ - length: false, - height: false, - total_length: false, -}) const form_refs = { length: ref(), height: ref(), @@ -89,6 +87,12 @@ const changeParametres = () => { if (form_state.extra_section && form_state.extra_section < parametric.length.min) { form_refs.total_length.value.setCustomValidity('Расчет невозможен') } + setTimeout(() => { + if (form_state.total_length < parametric.total_length.min) { + form_state.total_length = parametric.total_length.min + form_state.length = parametric.length.min + } + }, 300) } }