fix lable of katod
This commit is contained in:
@@ -607,6 +607,7 @@ export type TransactionTradeProductSource = {
|
|||||||
product?: (ProductUnitSource & { title?: string | null }) | null
|
product?: (ProductUnitSource & { title?: string | null }) | null
|
||||||
wallet?: { product?: (ProductUnitSource & { title?: string | null }) | null } | null
|
wallet?: { product?: (ProductUnitSource & { title?: string | null }) | null } | null
|
||||||
title?: string | null
|
title?: string | null
|
||||||
|
order?: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
/** محصول معاملهشده — نه لزوماً همان کیف پول (مثلاً خرید مفتول با کیف کاتد) */
|
/** محصول معاملهشده — نه لزوماً همان کیف پول (مثلاً خرید مفتول با کیف کاتد) */
|
||||||
@@ -654,6 +655,53 @@ export function getTransactionTradePriceLabel(product?: (ProductUnitSource & { t
|
|||||||
return `قیمت هر ${getWeightUnit()} ${getTradePriceUnitLabel()}`
|
return `قیمت هر ${getWeightUnit()} ${getTradePriceUnitLabel()}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** برچسب «موجودی کیف …» برای سطر موجودی فلز در جزئیات معامله */
|
||||||
|
export function getTransactionMetalWalletBalanceLabel(
|
||||||
|
item?: TransactionTradeProductSource | null,
|
||||||
|
): string {
|
||||||
|
if (!item) {
|
||||||
|
return getGoldWalletLabel()
|
||||||
|
}
|
||||||
|
|
||||||
|
const tradeProduct = item.order ? resolveTransactionTradeProduct(item) : null
|
||||||
|
const walletProduct = item.wallet?.product
|
||||||
|
const tradeTitle = (tradeProduct?.title ?? '').trim()
|
||||||
|
const walletTitle = (walletProduct?.title ?? '').trim()
|
||||||
|
|
||||||
|
if (tradeTitle) {
|
||||||
|
if (!walletTitle) {
|
||||||
|
return `موجودی کیف ${tradeTitle}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return `موجودی ${tradeTitle}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (walletTitle) {
|
||||||
|
return `موجودی ${walletTitle}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return getGoldWalletLabel(item.wallet?.product?.group_type)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** واحد نمایش موجودی فلز در جزئیات معامله */
|
||||||
|
export function getTransactionMetalWalletBalanceUnit(
|
||||||
|
item?: TransactionTradeProductSource | null,
|
||||||
|
): string {
|
||||||
|
const tradeProduct = item?.order ? resolveTransactionTradeProduct(item) : null
|
||||||
|
const walletProduct = item?.wallet?.product
|
||||||
|
const product = tradeProduct?.title ? tradeProduct : walletProduct
|
||||||
|
|
||||||
|
if (product && usesQuantityTrade(product)) {
|
||||||
|
return getProductQuantityUnit(product)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (product?.title) {
|
||||||
|
return getWeightUnit()
|
||||||
|
}
|
||||||
|
|
||||||
|
return getWeightUnit()
|
||||||
|
}
|
||||||
|
|
||||||
/** وزن کل زیر مقدار مبادلهشده — فقط محصول تعدادی (نه trade_by_quantity) */
|
/** وزن کل زیر مقدار مبادلهشده — فقط محصول تعدادی (نه trade_by_quantity) */
|
||||||
export function shouldShowTransactionTotalWeightLine(product?: ProductUnitSource | null) {
|
export function shouldShowTransactionTotalWeightLine(product?: ProductUnitSource | null) {
|
||||||
if (!product || usesQuantityTrade(product) || !hasProductUnitWeight(product)) {
|
if (!product || usesQuantityTrade(product) || !hasProductUnitWeight(product)) {
|
||||||
|
|||||||
@@ -60,29 +60,23 @@
|
|||||||
ریال
|
ریال
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="item.wallet?.product" :class="variant === 'desktop' ? 'dtxn-detail__row' : 'flex justify-between mb-3'">
|
<div
|
||||||
|
v-if="showMetalWalletBalance"
|
||||||
|
:class="variant === 'desktop' ? 'dtxn-detail__row' : 'flex justify-between mb-3'"
|
||||||
|
>
|
||||||
<div :class="variant === 'desktop' ? 'dtxn-detail__label' : 'text-primary'">
|
<div :class="variant === 'desktop' ? 'dtxn-detail__label' : 'text-primary'">
|
||||||
موجودی {{ item.wallet.product.title }}:
|
{{ metalWalletBalanceLabel }}:
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col items-end text-xs text-yellow-700">
|
<div class="flex flex-col items-end text-xs text-yellow-700">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<div class="text-base ml-1">{{ formatGoldAmount(item.balance_gold) }}</div>
|
<div class="text-base ml-1">{{ formatGoldAmount(item.balance_gold) }}</div>
|
||||||
{{ getProductQuantityUnit(item.wallet.product) }}
|
{{ metalWalletBalanceUnit }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="getProductUnitWeightLabel(item.wallet.product)" class="text-gray-500">
|
<div v-if="getProductUnitWeightLabel(metalWalletProduct)" class="text-gray-500">
|
||||||
هر عدد {{ getProductUnitWeightLabel(item.wallet.product) }}
|
هر عدد {{ getProductUnitWeightLabel(metalWalletProduct) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else :class="variant === 'desktop' ? 'dtxn-detail__row' : 'flex justify-between mb-3'">
|
|
||||||
<div :class="variant === 'desktop' ? 'dtxn-detail__label' : 'text-primary'">
|
|
||||||
{{ getGoldWalletLabel(item.wallet?.product?.group_type) }}:
|
|
||||||
</div>
|
|
||||||
<div class="flex text-xs text-yellow-700 items-center">
|
|
||||||
<div class="text-base ml-1">{{ formatGoldAmount(item.balance_gold) }}</div>
|
|
||||||
{{ getWeightUnit() }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div :class="variant === 'desktop' ? 'dtxn-detail__row' : 'flex justify-between mb-3'">
|
<div :class="variant === 'desktop' ? 'dtxn-detail__row' : 'flex justify-between mb-3'">
|
||||||
<div :class="variant === 'desktop' ? 'dtxn-detail__label' : 'text-primary'">وضعیت:</div>
|
<div :class="variant === 'desktop' ? 'dtxn-detail__label' : 'text-primary'">وضعیت:</div>
|
||||||
<div class="flex text-xs items-center">
|
<div class="flex text-xs items-center">
|
||||||
@@ -112,13 +106,12 @@ import { formatGoldAmount, usePriceWithoutType } from '@/utils/usePrice'
|
|||||||
import type { Transaction } from '@/models/transaction'
|
import type { Transaction } from '@/models/transaction'
|
||||||
import {
|
import {
|
||||||
getCashWalletLabel,
|
getCashWalletLabel,
|
||||||
getGoldWalletLabel,
|
|
||||||
getMeltedGoldTradeLabel,
|
|
||||||
getProductQuantityUnit,
|
|
||||||
getProductTotalWeightLabel,
|
getProductTotalWeightLabel,
|
||||||
getProductUnitWeightLabel,
|
getProductUnitWeightLabel,
|
||||||
|
getTransactionMetalWalletBalanceLabel,
|
||||||
|
getTransactionMetalWalletBalanceUnit,
|
||||||
getTransactionTradePriceLabel,
|
getTransactionTradePriceLabel,
|
||||||
getWeightUnit,
|
getMeltedGoldTradeLabel,
|
||||||
resolveTransactionTradeProduct,
|
resolveTransactionTradeProduct,
|
||||||
shouldShowTransactionTotalWeightLine,
|
shouldShowTransactionTotalWeightLine,
|
||||||
} from '@/utils/productDealMethod'
|
} from '@/utils/productDealMethod'
|
||||||
@@ -136,4 +129,19 @@ const tradeProduct = computed(() => resolveTransactionTradeProduct(props.item))
|
|||||||
const tradeProductLabel = computed(
|
const tradeProductLabel = computed(
|
||||||
() => (tradeProduct.value?.title ?? '').trim() || getMeltedGoldTradeLabel(),
|
() => (tradeProduct.value?.title ?? '').trim() || getMeltedGoldTradeLabel(),
|
||||||
)
|
)
|
||||||
|
const metalWalletProduct = computed(() => {
|
||||||
|
if (props.item.order && tradeProduct.value?.title) {
|
||||||
|
return tradeProduct.value
|
||||||
|
}
|
||||||
|
|
||||||
|
return props.item.wallet?.product ?? tradeProduct.value ?? null
|
||||||
|
})
|
||||||
|
const metalWalletBalanceLabel = computed(() => getTransactionMetalWalletBalanceLabel(props.item))
|
||||||
|
const metalWalletBalanceUnit = computed(() => getTransactionMetalWalletBalanceUnit(props.item))
|
||||||
|
const showMetalWalletBalance = computed(
|
||||||
|
() =>
|
||||||
|
props.item.order != null
|
||||||
|
|| props.item.wallet?.product != null
|
||||||
|
|| Math.abs(Number(props.item.balance_gold) || 0) > 0,
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user