bx-935-calc #1
|
@ -99,16 +99,25 @@ const total_txt = computed(() => {
|
||||||
const pillar = parseFloat(calculatorData.value.pillar)
|
const pillar = parseFloat(calculatorData.value.pillar)
|
||||||
const pillar_base = parseFloat(calculatorData.value.pillar_base)
|
const pillar_base = parseFloat(calculatorData.value.pillar_base)
|
||||||
const lamelles_block = parseFloat(calculatorData.value.lamelles_block)
|
const lamelles_block = parseFloat(calculatorData.value.lamelles_block)
|
||||||
|
const { discount } = calculatorData.value
|
||||||
|
|
||||||
const sections = section_count.value as number
|
const sections = section_count.value as number
|
||||||
const extra_m = extra_section.value as number * 0.001
|
const extra_m = extra_section.value as number * 0.001
|
||||||
const length_m = fence_section.value as number
|
const length_m = fence_section.value as number
|
||||||
const lam_count = lamelles_count.value as number
|
const lam_count = lamelles_count.value as number
|
||||||
|
|
||||||
|
let discountValue = 1
|
||||||
|
discount.forEach(element => {
|
||||||
|
if (sections >= element.min_quantity) {
|
||||||
|
if (element.max_quantitt && sections >= element.max_quantitt) return
|
||||||
|
discountValue -= element.percent * 0.01
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const prices = {
|
const prices = {
|
||||||
pillar_length: pillar,
|
pillar_length: discountValue * pillar,
|
||||||
pillar: (pillar * lam_count * 0.115) + pillar_base,
|
pillar: discountValue * ((pillar * lam_count * 0.115) + pillar_base),
|
||||||
lam_quad: lamelles_block * lam_count * 0.115,
|
lam_quad: discountValue * (lamelles_block * lam_count * 0.115),
|
||||||
}
|
}
|
||||||
|
|
||||||
const extra = {
|
const extra = {
|
||||||
|
@ -131,7 +140,7 @@ const total_txt = computed(() => {
|
||||||
txt: `Блок ламелей с направляющей, ${sections} шт`,
|
txt: `Блок ламелей с направляющей, ${sections} шт`,
|
||||||
value: prices.lam_quad * length_m * sections
|
value: prices.lam_quad * length_m * sections
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
const total = [extra, regular].map(item => Object.values(item).map(el => el ? el.value : 0)).flat().reduce((a, b) => a + b, 0)
|
const total = [extra, regular].map(item => Object.values(item).map(el => el ? el.value : 0)).flat().reduce((a, b) => a + b, 0)
|
||||||
|
|
||||||
|
|
|
@ -49,11 +49,17 @@ type ApiAdvantageType = {
|
||||||
title: string
|
title: string
|
||||||
content: string
|
content: string
|
||||||
}
|
}
|
||||||
|
type DiscountType = {
|
||||||
|
id: number
|
||||||
|
min_quantity: number
|
||||||
|
max_quantitt?: number
|
||||||
|
percent: number
|
||||||
|
}
|
||||||
type ApiCalcType = {
|
type ApiCalcType = {
|
||||||
id: number
|
id: number
|
||||||
title: string
|
title: string
|
||||||
pillar: string
|
pillar: string
|
||||||
pillar_base: string
|
pillar_base: string
|
||||||
lamelles_block: string
|
lamelles_block: string
|
||||||
|
discount: DiscountType[]
|
||||||
}
|
}
|
Loading…
Reference in New Issue