fix some bugs

This commit is contained in:
2026-06-23 22:31:07 +03:30
parent 4e7d6bca00
commit 71764f7e9a
68 changed files with 1941 additions and 1288 deletions
@@ -3,21 +3,29 @@
<template #default="{ item: row }">
<MobileSheetHeader :title="sheetTitle" :subtitle="dateLabel(row)" :show-title="isMobile" />
<div class="flex items-center gap-2">
<div class="flex flex-wrap items-center gap-2">
<span class="rounded-lg border px-2 py-0.5 text-xs font-600" :class="typeTagClass(row)">
{{ typeLabel(row) }}
</span>
<span
v-if="!isMoneyType(row) && row.transaction_metal_label"
class="rounded-lg border border-amber-300 bg-amber-50 px-2 py-0.5 text-xs font-600 text-amber-700"
>
{{ row.transaction_metal_label }}
</span>
</div>
<div class="space-y-2">
<MobileStatCard
v-for="entry in metalEntries(row)"
:key="entry.metal_id"
bordered
:variant="(row.gold ?? 0) > 0 ? 'success' : 'danger'"
label="مقدار طلا (گرم)"
:value="goldLabel(row)"
:variant="entry.value > 0 ? 'success' : 'danger'"
:label="transactionMetalAmountTitle(entry.metal_id, entry.label)"
:value="entry.display"
>
<template #prefix>
<BaseIcon icon="vuesax-linear:coin" size="18" :color="(row.gold ?? 0) > 0 ? '#15803d' : '#dc2626'" />
<BaseIcon icon="vuesax-linear:coin" size="18" :color="entry.value > 0 ? '#15803d' : '#dc2626'" />
</template>
</MobileStatCard>
<MobileStatCard
@@ -33,6 +41,7 @@
</div>
<MobileInfoGrid>
<MobileDetailRow label="نوع فلز" :value="isMoneyType(row) ? '-' : (row.transaction_metal_label ?? '-')" />
<MobileDetailRow label="کد تراکنش" :value="row.id ?? '-'" />
<MobileDetailRow label="نام تراکنش" :value="row.type_str || '-'" />
<MobileDetailRow label="علت تراکنش" full-width :value="noteLabel(row)" />
@@ -53,10 +62,14 @@ import MobileStatCard from '@/components/mobile/MobileStatCard.vue'
import { isMobile } from '@core/utils/is'
import { toJalaliNoTime } from '@core/utils/useDataTime'
import { usePrice } from '@core/utils/usePrice'
import { metalLabel, transactionMetalAmountTitle } from '@/utils/adminMetalLabels'
import { formatMetalDisplayValue, metalCellValue } from '@/utils/metalWeight'
import type { TransactionMetalColumn } from '../hooks/transactionsColumns'
const props = defineProps<{
visible: boolean
item: Transaction | null
metals?: TransactionMetalColumn[]
}>()
const emit = defineEmits<{
@@ -75,7 +88,7 @@ function isMoneyType(row: Transaction) {
}
function typeLabel(row: Transaction) {
return isMoneyType(row) ? 'پول' : 'طلا'
return isMoneyType(row) ? 'پول' : 'فلز'
}
function typeTagClass(row: Transaction) {
@@ -88,14 +101,26 @@ function dateLabel(row: Transaction) {
return row.created_at ? toJalaliNoTime(row.created_at) : '-'
}
function goldLabel(row: Transaction) {
const gold = row.gold
if (gold == null) return '-'
return `${Number(Number(gold).toFixed(3))} گرم`
}
function noteLabel(row: Transaction) {
if (row.note == null) return '-'
return String(row.note)
}
function metalEntries(row: Transaction) {
const metals = props.metals?.length
? props.metals
: [{ metal_id: row.transaction_metal_id ?? 1, label: row.transaction_metal_label ?? 'طلا' }]
return metals
.map((metal) => {
const value = metalCellValue(row as Record<string, unknown>, metal.metal_id)
return {
metal_id: metal.metal_id,
label: metal.label,
value,
display: value ? formatMetalDisplayValue(value, metal.metal_id) : '-'
}
})
.filter((entry) => entry.value !== 0)
}
</script>