change prices &...

This commit is contained in:
2026-06-03 11:57:40 +03:30
parent f4b98576f5
commit b055cd4a5d
16 changed files with 305 additions and 25 deletions
+37 -6
View File
@@ -308,8 +308,17 @@ const finalPrice = computed(() => {
}
})
const payablePrice = computed(() => finalPrice.value)
const equivalentPrice = computed(() => usePriceWithoutType(((isBuy ? price.value?.buy ?? 0 : price.value?.sell ?? 0) * (parseFloat(((form.value?.goldValue ?? 0) * 0.01).toFixed(4))) ).toFixed(0)) )
const payablePrice = computed(() =>
isBuy.value ? finalPrice.value + feeInRial.value : finalPrice.value - feeInRial.value
)
const feeInGrams = computed(() =>
parseFloat(((form.value?.goldValue ?? 0) * 0.01).toFixed(4))
)
const unitPrice = computed(() =>
(props?.ProductItem?.price_profit ?? 0) + (props?.ProductItem?.price ?? 0)
)
const feeInRial = computed(() => unitPrice.value * feeInGrams.value)
const equivalentPrice = computed(() => usePriceWithoutType(feeInRial.value.toFixed(0)))
const disableTransaction = computed(() =>
loading.value ||
@@ -506,6 +515,28 @@ const limitedPrice = computed(() => {
}
}
}*/
function syncFormWithLatestPrice() {
if (!price.value) return
const goldValue = form.value.goldValue
if (goldValue !== undefined && goldValue !== null && goldValue !== '' && !isNaN(Number(goldValue))) {
calculateCash(Number(goldValue))
return
}
const goldCash = form.value.goldCash
if (goldCash !== undefined && goldCash !== null && goldCash !== '' && !isNaN(Number(goldCash))) {
calculateGold(Number(goldCash))
}
}
watch(
() => [basePriceValue.value, isBuy.value],
() => {
syncFormWithLatestPrice()
}
)
function calculateCash(val: number) {
priceErrorVisible.value = false
if (price.value) {
@@ -597,10 +628,10 @@ const formatter = (value: number) => {
const price = computed((): Price => <Price>lastPrice.value ?? 0)
const goldPriceValue = computed(() => {
if (!price.value) return 0
return isBuy.value
? (price.value.buy ?? 0)
: (price.value.sell ?? 0)
if (!lastPrice.value?.price) return 0
return isBuy.value
? (lastPrice.value.buy ?? 0)
: (lastPrice.value.sell ?? 0)
})
async function initPrice() {