From 34be7a66dca8aecab46b5b536ab014ca3cd4a5ae Mon Sep 17 00:00:00 2001 From: mohammad sedighi Date: Fri, 26 Jun 2026 22:16:44 +0330 Subject: [PATCH] fix wallet ui --- src/api/customer.ts | 4 + .../customer/CustomerWalletBalancePanel.vue | 156 ++++++++++++++++++ src/model/walletAssets.ts | 37 +++++ .../components/CustomerMobileCardList.vue | 1 - .../components/CustomerMobileDetailSheet.vue | 58 +------ src/pages/menuPages/customers/base/index.vue | 23 +-- 6 files changed, 208 insertions(+), 71 deletions(-) create mode 100644 src/components/customer/CustomerWalletBalancePanel.vue create mode 100644 src/model/walletAssets.ts diff --git a/src/api/customer.ts b/src/api/customer.ts index e8628e2..8e63f2f 100644 --- a/src/api/customer.ts +++ b/src/api/customer.ts @@ -2,6 +2,7 @@ import useAxios from '@core/utils/useAxios' import type { AddId, Customer } from '@/model/customer' import type { TableInput } from '@core/type/baseTable' import type {CheckCardRequest, CheckCardResponse} from "@/model/user"; +import type { WalletAssetsSummary } from '@/model/walletAssets' export const createCustomer = async (obj: Customer) => await useAxios.post(`/admin/customer`, obj) @@ -13,6 +14,9 @@ export const updateCustomer = async (id: number, obj: Customer) => export const getCustomerTable = async (params: TableInput) => await useAxios.post>('/admin/customer/table', params) +export const getCustomerAssetsSummary = async (customerId: number) => + await useAxios.get(`/admin/customer/${customerId}/assets`) + export const getCustomersList = async () => await useAxios.get(`/admin/customer/list`) export const changeCustomerActivation = async (id: number) => diff --git a/src/components/customer/CustomerWalletBalancePanel.vue b/src/components/customer/CustomerWalletBalancePanel.vue new file mode 100644 index 0000000..550885d --- /dev/null +++ b/src/components/customer/CustomerWalletBalancePanel.vue @@ -0,0 +1,156 @@ + + + diff --git a/src/model/walletAssets.ts b/src/model/walletAssets.ts new file mode 100644 index 0000000..994e410 --- /dev/null +++ b/src/model/walletAssets.ts @@ -0,0 +1,37 @@ +export interface WalletInventoryCard { + product_id: number + title: string + group_type: string + metal_id: number + quantity: number + unit: string + display_type: 'count' | 'weight' + unit_weight?: string | null + show_in_assets: boolean + is_melted?: boolean + is_main_wallet?: boolean +} + +export interface WalletMetalTotal { + metal_id: number + metal_label: string + label: string + product_weight: number + melted_weight: number + total_weight: number + unit: string +} + +export interface WalletAssetsSummary { + meta: { + metal_ids: number[] + weight_unit: string + single_metal: boolean + } + cash_wallet: number + inventory_cards: WalletInventoryCard[] + count_products: WalletInventoryCard[] + metal_totals: WalletMetalTotal[] + assets_rial_value: number + total_rial_value: number +} diff --git a/src/pages/menuPages/customers/base/components/CustomerMobileCardList.vue b/src/pages/menuPages/customers/base/components/CustomerMobileCardList.vue index 680e41e..38d2f60 100644 --- a/src/pages/menuPages/customers/base/components/CustomerMobileCardList.vue +++ b/src/pages/menuPages/customers/base/components/CustomerMobileCardList.vue @@ -21,7 +21,6 @@ -
- - - - - - -
+ @@ -101,20 +78,15 @@ import { Modal } from 'ant-design-vue' import type { Customer } from '@/model/customer' import { MODAL_ABOVE_ACTION_SHEET_Z_INDEX } from '@/constants/overlayZIndex' import MobileDetailRow from '@/components/mobile/MobileDetailRow.vue' -import MobileStatCard from '@/components/mobile/MobileStatCard.vue' import MobileDetailSheet from '@/components/mobile/MobileDetailSheet.vue' import MobileInfoGrid from '@/components/mobile/MobileInfoGrid.vue' -import { getCashBalance } from '@/components/mobile/utils/wallet' +import CustomerWalletBalancePanel from '@/components/customer/CustomerWalletBalancePanel.vue' import { toJalali } from '@core/utils/useDataTime' -import { usePrice } from '@core/utils/usePrice' -import { customerWalletMetalBalanceTitle, metalLabel } from '@/utils/adminMetalLabels' -import type { CustomerMetalColumn } from '../hooks/customerColumns' -import { formatMetalDisplayValue, metalCellValue, metalDisplayUnit } from '@/utils/metalWeight' +import { metalLabel } from '@/utils/adminMetalLabels' const props = defineProps<{ visible: boolean item: Customer | null - metals?: CustomerMetalColumn[] }>() const emit = defineEmits<{ @@ -163,30 +135,6 @@ function confirmToggleTrade(row: Customer) { }) } -function cashBalance(row: Customer) { - return getCashBalance(row.wallet) -} - -function metalBalanceEntries(row: Customer) { - const metals = props.metals?.length - ? props.metals - : [{ metal_id: 1, label: 'طلا' }] - - return metals - .map((metal) => { - const value = metalCellValue(row as Record, metal.metal_id, 'wallet_metal_gold') - return { - metal_id: metal.metal_id, - label: metal.label, - value: formatMetalDisplayValue(value, metal.metal_id) - } - }) - .filter((entry) => { - const numeric = metalCellValue(row as Record, entry.metal_id, 'wallet_metal_gold') - return numeric !== 0 - }) -} - function lastSeen(row: Customer) { return row.last_seen_at ? toJalali(row.last_seen_at) : '-' } diff --git a/src/pages/menuPages/customers/base/index.vue b/src/pages/menuPages/customers/base/index.vue index 3533288..7f320f7 100644 --- a/src/pages/menuPages/customers/base/index.vue +++ b/src/pages/menuPages/customers/base/index.vue @@ -180,19 +180,7 @@ -
-
- - -
-
+ @@ -226,18 +214,20 @@ @ok="chargeMoneyWallet" @close="showMoneyWalletCharge = false" > + + @@ -255,18 +245,20 @@ @ok="chargeGoldWallet" @close="showGoldWalletCharge = false" > + +