From 6fb5bb763b59da9fc13869ded92aa3571fe048e2 Mon Sep 17 00:00:00 2001 From: safavimohadeseh78 Date: Tue, 30 Dec 2025 11:12:13 +0330 Subject: [PATCH] show balance_gold/cash --- src/core/utils/usePrice.ts | 8 +++++ .../hooks/transactionsColumns.tsx | 36 ++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/core/utils/usePrice.ts b/src/core/utils/usePrice.ts index 4e89d78..3f435b8 100644 --- a/src/core/utils/usePrice.ts +++ b/src/core/utils/usePrice.ts @@ -6,6 +6,14 @@ export function usePrice(price: number, digit = true, unit = 'ریال') { return `${_price} ${unit}` } +export function usePriceWithoutType(price?: number, digit = true, unit = 'ریال') { + let _price = price?.toString() + if (digit) { + _price = _price?.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') + } + return `${_price}` +} + export function useTowDecimal(num: string | number): string | number { const temp = num.toString().match(/^-?\d+(?:\.\d{0,2})?/) if (temp && temp.length > 0) return temp[0] diff --git a/src/pages/menuPages/transactions/hooks/transactionsColumns.tsx b/src/pages/menuPages/transactions/hooks/transactionsColumns.tsx index 801ba8d..6569e07 100644 --- a/src/pages/menuPages/transactions/hooks/transactionsColumns.tsx +++ b/src/pages/menuPages/transactions/hooks/transactionsColumns.tsx @@ -1,7 +1,7 @@ import type {BaseTableColumn} from '@core/type/baseTable' import {toJalaliNoTime, toTime} from '@core/utils/useDataTime' import CustomTag from '@/components/CustomTag.vue' -import {usePrice} from '@core/utils/usePrice' +import { usePrice, usePriceWithoutType } from "@core/utils/usePrice"; /*import BudgetSelect from '@/components/BudgetSelect.vue' import { useStaticApiListsStore } from '@/store/staticApisStore' import type { FilterSelect } from '@/model/filterSelect' @@ -84,6 +84,40 @@ export const cols: BaseTableColumn[] = [ key: 'customer.name', type: 'Text' }, + { + title: 'موجودی طلایی بعد تراکنش (گرم)', + dataIndex: 'balance_gold', + key: 'balance_gold', + type: 'Number', + customRender: ({record}) => { + return record.balance_gold > 0 ? ( +
+
{record?.balance_gold ?? '_'}
+
+ ) : ( +
+
{record?.balance_gold ?? '_'}
+
+ ) + } + }, + { + title: 'موجودی ریالی بعد تراکنش (ریال)', + dataIndex: 'balance_cash', + key: 'balance_cash', + type: 'Number', + customRender: ({record}) => { + return record?.balance_cash > 0 ? ( +
+
{usePriceWithoutType(record?.balance_cash) ?? '_'}
+
+ ) : ( +
+
{usePriceWithoutType(record?.balance_cash) ?? '_'}
+
+ ) + } + }, { title: 'مقدار طلا طی تراکنش (گرم)', dataIndex: 'gold',