2026-01-24 17:45:54 +03:30
|
|
|
import type { BaseTableColumn } from '@core/type/baseTable'
|
2026-06-23 22:31:07 +03:30
|
|
|
import { toJalali } from '@core/utils/useDataTime'
|
2026-01-24 17:45:54 +03:30
|
|
|
import CustomTag from '@/components/CustomTag.vue'
|
|
|
|
|
import { usePrice } from '@core/utils/usePrice'
|
2026-06-23 22:31:07 +03:30
|
|
|
import { getCashBalance } from '@/components/mobile/utils/wallet'
|
|
|
|
|
import { customerWalletMetalBalanceTitle } from '@/utils/adminMetalLabels'
|
|
|
|
|
import { formatMetalDisplayValue, metalCellValue } from '@/utils/metalWeight'
|
2026-01-24 17:45:54 +03:30
|
|
|
|
2026-06-23 22:31:07 +03:30
|
|
|
export type CustomerMetalColumn = { metal_id: number; label: string; display_unit?: string }
|
2026-01-24 17:45:54 +03:30
|
|
|
|
2026-06-23 22:31:07 +03:30
|
|
|
export function buildCustomerColumns(metals: CustomerMetalColumn[] = []): BaseTableColumn[] {
|
|
|
|
|
const baseColumns: BaseTableColumn[] = [
|
|
|
|
|
{
|
|
|
|
|
title: 'ردیف',
|
|
|
|
|
dataIndex: 'id',
|
|
|
|
|
key: 'id',
|
2026-01-24 17:45:54 +03:30
|
|
|
filterable: false,
|
|
|
|
|
sortable: false,
|
2026-06-23 22:31:07 +03:30
|
|
|
customRender: (record: any) => {
|
|
|
|
|
return record.index + 1
|
2026-01-24 17:45:54 +03:30
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
2026-06-23 22:31:07 +03:30
|
|
|
title: 'کد کاربری',
|
|
|
|
|
dataIndex: 'id',
|
|
|
|
|
key: 'id',
|
|
|
|
|
type: 'Number'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'نام و نام خانوادگی',
|
|
|
|
|
dataIndex: 'name',
|
|
|
|
|
key: 'name',
|
|
|
|
|
type: 'Text'
|
2026-01-24 17:45:54 +03:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'شماره موبایل',
|
|
|
|
|
dataIndex: 'mobile',
|
2026-06-23 22:31:07 +03:30
|
|
|
key: 'mobile',
|
|
|
|
|
type: 'Number'
|
2026-01-24 17:45:54 +03:30
|
|
|
},
|
|
|
|
|
{
|
2026-06-23 22:31:07 +03:30
|
|
|
title: 'نوع کاربر',
|
|
|
|
|
dataIndex: 'type_str',
|
|
|
|
|
key: 'type_str',
|
|
|
|
|
type: 'Text'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'کد معرف',
|
|
|
|
|
dataIndex: 'referral_id',
|
|
|
|
|
key: 'referral_id',
|
|
|
|
|
type: 'Text'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'نام معرف کاربر',
|
|
|
|
|
dataIndex: 'referral.name',
|
|
|
|
|
key: 'referral.name',
|
|
|
|
|
type: 'Text'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'موجودی ریالی (ریال)',
|
|
|
|
|
dataIndex: 'wallet.cash',
|
|
|
|
|
key: 'wallet.cash',
|
|
|
|
|
type: 'Number',
|
|
|
|
|
customRender(data) {
|
|
|
|
|
return usePrice(getCashBalance(data.record?.wallet, { walletCash: data.record?.wallet_cash }), true, '')
|
2026-01-24 17:45:54 +03:30
|
|
|
}
|
2026-06-23 22:31:07 +03:30
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
const metalColumns: BaseTableColumn[] =
|
|
|
|
|
metals.length > 0
|
|
|
|
|
? metals.map((metal) => ({
|
|
|
|
|
title: customerWalletMetalBalanceTitle(metal.metal_id, metal.label),
|
|
|
|
|
dataIndex: `wallet_metal_gold_${metal.metal_id}`,
|
|
|
|
|
key: `wallet_metal_${metal.metal_id}`,
|
|
|
|
|
type: 'Number',
|
|
|
|
|
filterable: false,
|
|
|
|
|
customRender(data) {
|
|
|
|
|
const value = metalCellValue(data.record, metal.metal_id, 'wallet_metal_gold')
|
|
|
|
|
return formatMetalDisplayValue(value, metal.metal_id)
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
: [
|
|
|
|
|
{
|
|
|
|
|
title: customerWalletMetalBalanceTitle(1, 'طلا'),
|
|
|
|
|
dataIndex: 'wallet.gold',
|
|
|
|
|
key: 'wallet.gold',
|
|
|
|
|
type: 'Number',
|
|
|
|
|
filterable: false,
|
|
|
|
|
customRender(data) {
|
|
|
|
|
const value = Number(data.record?.wallet_gold ?? 0)
|
|
|
|
|
return formatMetalDisplayValue(value, 1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
...baseColumns,
|
|
|
|
|
...metalColumns,
|
|
|
|
|
{
|
|
|
|
|
title: 'اخرین بازدید',
|
|
|
|
|
dataIndex: 'last_seen_at',
|
|
|
|
|
key: 'last_seen_at',
|
|
|
|
|
type: 'DateTime',
|
|
|
|
|
customRender(data) {
|
|
|
|
|
return toJalali(data.record.last_seen_at)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'وضعیت کاربر',
|
|
|
|
|
dataIndex: 'active',
|
|
|
|
|
key: 'active',
|
|
|
|
|
type: 'Boolean',
|
|
|
|
|
customRender: ({ record }) => {
|
|
|
|
|
return record.active ? (
|
|
|
|
|
<div class="flex justify-center">
|
|
|
|
|
<CustomTag textColor="#25855A" bgColor="#E3F4E9" class={'font-bold px-6'}>
|
|
|
|
|
فعال
|
|
|
|
|
</CustomTag>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div class="flex justify-center">
|
|
|
|
|
<CustomTag textColor="#C53030" bgColor="#FECACA" class={'font-bold px-6'}>
|
|
|
|
|
غیر فعال
|
|
|
|
|
</CustomTag>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'وضعیت سفارش دهی',
|
|
|
|
|
dataIndex: 'trade_active',
|
|
|
|
|
key: 'trade_active',
|
|
|
|
|
sortable: false,
|
|
|
|
|
type: 'Boolean',
|
|
|
|
|
customRender: ({ record }) => {
|
|
|
|
|
return record.trade_active ? (
|
|
|
|
|
<div class="flex justify-center">
|
|
|
|
|
<CustomTag textColor="#25855A" bgColor="#E3F4E9" class={'font-bold px-6'}>
|
|
|
|
|
مجاز
|
|
|
|
|
</CustomTag>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div class="flex justify-center">
|
|
|
|
|
<CustomTag textColor="#C53030" bgColor="#FECACA" class={'font-bold px-6'}>
|
|
|
|
|
غیر مجاز
|
|
|
|
|
</CustomTag>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: 'عملیات',
|
|
|
|
|
dataIndex: 'action',
|
|
|
|
|
key: 'action',
|
|
|
|
|
slot: 'action',
|
|
|
|
|
filterable: false
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getCustomerColumns(): BaseTableColumn[] {
|
|
|
|
|
return buildCustomerColumns()
|
|
|
|
|
}
|