From 663702b8f54073d893e5c4d0d55f37298b8ff54b Mon Sep 17 00:00:00 2001 From: Kseninia Mikhaylova Date: Thu, 20 Jun 2024 11:00:20 +0300 Subject: [PATCH] calc --- components/modal.vue | 68 ++++++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/components/modal.vue b/components/modal.vue index 0945031..0f5aee1 100644 --- a/components/modal.vue +++ b/components/modal.vue @@ -92,46 +92,64 @@ const roubleSign = new Intl.NumberFormat('ru-RU', { currency: 'RUB', }); const total_txt = computed(() => { - const { mortgage, pillar, lamella, rivets, bar, guide } = calculatorData.value + let { mortgage, pillar, lamella, rivets, bar, guide } = calculatorData.value + mortgage = parseFloat(mortgage) + pillar = parseFloat(pillar) + lamella = parseFloat(lamella) + rivets = parseFloat(rivets) + bar = parseFloat(bar) + guide = parseFloat(guide) const sections = section_count.value as number const extra_mm = extra_section.value as number + const length_mm = fence_section.value as number + const lam_count = lamelles_count.value as number - const pillar_count = mortgage + 1 - const pil = (parseFloat(mortgage) + parseFloat(pillar)) * pillar_count - - const length = fence_section.value - - const lam_count = lamelles_count.value * sections - const lam = (lam_count * length * parseFloat(lamella)) + parseFloat(rivets) - - const top_count = section_count.value as number - const top = top_count * bar - - const guides_count = sections * 2 - const guides = guides_count * parseFloat(guide) * lam_count * 0.115 + const prices = { + pillar: mortgage + pillar, + lamella: rivets * 2 + lamella * length_mm, + lamella_extra: rivets * 2 + lamella * extra_mm, + guide: guide * lam_count * 0.115, + top: bar * length_mm, + top_extra: bar * extra_mm + } const extra = { pillar: !remove_pillar.value && { - txt: 'Дополнительная секция, столб, 1 шт', - value: ((parseFloat(mortgage) + parseFloat(pillar)) * 1) + txt: 'Дополнительная секция, столб, 1шт', + value: prices.pillar * 1 }, lamella: { - txt: `Дополнительная секция, ламели, ${lamelles_count.value} шт`, - value: ((parseFloat(mortgage) + parseFloat(pillar)) * top_count) + txt: `Дополнительная секция, ламели, ${lam_count}шт`, + value: prices.lamella_extra * lam_count + }, + guide: { + txt: 'Направляющие, 2шт', + value: prices.guide * 2 + }, + top: { + txt: 'Верхняя планка', + value: prices.top * 1 }, - guide: { txt: 'Направляющие', value: 2 * parseFloat(guide) * lam_count * 0.115 }, - top: { txt: 'Верхняя планка', value: 1 * bar }, } const regular = { pillar: !remove_pillar.value && { - txt: `Столб`, - value: (parseFloat(mortgage) + parseFloat(pillar)) * pillar_count + txt: `Столб, ${(1 + sections)}шт`, + value: prices.pillar * (1 + sections) + }, + lamella: { + txt: `Ламели, ${(lam_count * sections)}`, + value: prices.lamella * (lam_count * sections) + }, + guide: { + txt: `Направляющие`, + value: prices.guide * (2 * sections) + }, + top: { + txt: `Верхняя планка`, + value: prices.top * sections }, - lamella: { txt: 'Ламели', value: (lam_count * length * parseFloat(lamella)) + parseFloat(rivets) }, - guide: { txt: 'Направляющие', value: guides_count * parseFloat(guide) * lam_count * 0.115 }, - top: { txt: 'Верхняя планка', value: top_count * lamella }, } const total = [extra, regular].map(item => Object.values(item).map(el => el ? el.value : 0)).flat().reduce((a, b) => a + b, 0)