f
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script setup>
|
||||
import PriceInputPopup from '@/components/PriceInputPopup.vue'
|
||||
import VipBanner from '@/components/VipBanner.vue'
|
||||
import { calculatePromotionPricing, safeTruncate } from '@/utils/promotionPricing'
|
||||
|
||||
definePage({ layout: 'default' })
|
||||
|
||||
@@ -30,39 +31,12 @@ const availableReportTypes = computed(() => {
|
||||
.filter(item => !!item.value)
|
||||
})
|
||||
|
||||
const costPrice = computed(() => {
|
||||
if (!pickerProductConfig.value)
|
||||
return '0.00'
|
||||
let platformPricing = 0
|
||||
platformPricing += pickerProductConfig.value.cost_price
|
||||
if (formData.value.clientPrice > pickerProductConfig.value.p_pricing_standard) {
|
||||
platformPricing += (formData.value.clientPrice - pickerProductConfig.value.p_pricing_standard) * pickerProductConfig.value.p_overpricing_ratio
|
||||
}
|
||||
|
||||
if (pickerProductConfig.value.a_pricing_standard > platformPricing && pickerProductConfig.value.a_pricing_end > platformPricing && pickerProductConfig.value.a_overpricing_ratio > 0) {
|
||||
if (formData.value.clientPrice > pickerProductConfig.value.a_pricing_standard) {
|
||||
if (formData.value.clientPrice > pickerProductConfig.value.a_pricing_end) {
|
||||
platformPricing += (pickerProductConfig.value.a_pricing_end - pickerProductConfig.value.a_pricing_standard) * pickerProductConfig.value.a_overpricing_ratio
|
||||
}
|
||||
else {
|
||||
platformPricing += (formData.value.clientPrice - pickerProductConfig.value.a_pricing_standard) * pickerProductConfig.value.a_overpricing_ratio
|
||||
}
|
||||
}
|
||||
}
|
||||
return safeTruncate(platformPricing)
|
||||
const pricingResult = computed(() => {
|
||||
return calculatePromotionPricing(formData.value.clientPrice, pickerProductConfig.value)
|
||||
})
|
||||
|
||||
const promotionRevenue = computed(() => {
|
||||
return safeTruncate(formData.value.clientPrice - costPrice.value)
|
||||
})
|
||||
|
||||
function safeTruncate(num, decimals = 2) {
|
||||
if (Number.isNaN(num) || !Number.isFinite(num))
|
||||
return '0.00'
|
||||
const factor = 10 ** decimals
|
||||
const scaled = Math.trunc(num * factor)
|
||||
return (scaled / factor).toFixed(decimals)
|
||||
}
|
||||
const costPrice = computed(() => pricingResult.value.costPrice)
|
||||
const promotionRevenue = computed(() => pricingResult.value.promotionRevenue)
|
||||
|
||||
function selectProductType(reportTypeValue) {
|
||||
const reportType = availableReportTypes.value.find(item => item.id === reportTypeValue || item.value === reportTypeValue)
|
||||
|
||||
Reference in New Issue
Block a user