diff --git a/components/modal.vue b/components/modal.vue index e392dad..195e6ce 100644 --- a/components/modal.vue +++ b/components/modal.vue @@ -4,6 +4,7 @@ import type { ralTypes } from '@/components/ral' const config = useRuntimeConfig() const apiBase = config.public.apiBase +const { data: calculatorData } = await useFetch(`${apiBase}/calculator/5/`) const isModalOpen = useState('modal_open', () => false) @@ -85,6 +86,26 @@ const submit = (e: any) => { modal_data.name = undefined isModalOpen.value = false } +const roubleSign = new Intl.NumberFormat('ru-RU', { + style: 'currency', + currency: 'RUB', +}); +const total = computed(() => { + const { mortgage, pillar, lamella } = calculatorData.value + const pillar_count = (section_count.value + 1) + const pil = (parseFloat(mortgage) + parseFloat(pillar)) * pillar_count + + const lam_count = lamelles_count.value * section_count.value + const lam = lam_count * lamella + + const top_count = section_count.value + const top = top_count * lamella + return [ + `Столб, ${pillar_count}: ${roubleSign.format(pil)}`, + `Ламели, ${lam_count}: ${roubleSign.format(lam)}`, + `Верхняя планка, ${top_count}: ${roubleSign.format(top)}`, + ] +})