Files
boursecu_admin/src/pages/menuPages/withdraw/hooks/withdrawColumns.tsx
T

320 lines
9.6 KiB
TypeScript
Raw Normal View History

2026-01-24 17:45:54 +03:30
import type { BaseTableColumn } from '@core/type/baseTable'
import { toJalali, toJalaliNoTime, toTime } from '@core/utils/useDataTime'
import CustomTag from '@/components/CustomTag.vue'
import WithdrawStatus from "@/pages/menuPages/withdraw/components/WithdrawStatus.vue";
2026-06-24 01:46:30 +03:30
import {
formatWithdrawAmountDisplay,
isMoneyWithdraw,
withdrawAmountColorClass,
withdrawTypeLabel
} from '@/pages/menuPages/withdraw/utils/withdrawDisplay'
2026-01-24 17:45:54 +03:30
/*import BudgetSelect from '@/components/BudgetSelect.vue'
import { useStaticApiListsStore } from '@/store/staticApisStore'
import type { FilterSelect } from '@/model/filterSelect'
import type { DocItem } from '@/model/docType'*/
//define store
//const store = useStaticApiListsStore()
//document types
/*let docTypes: DocItem[]*/
/*onMounted(async () => {
docTypes = await store.readyDocTypeList()
})
const filteredDocTypes: FilterSelect = docTypes?.map((x: DocItem) => {
return {
label: x.title,
value: x.id
}
})*/
export const WITHDRAW_NOTE_OPTIONS = [
{ label: 'برداشت ریالی', value: 'برداشت ریالی' },
{ label: 'کارت هدیه', value: 'کارت هدیه' },
{ label: 'واریز آنلاین', value: 'واریز آنلاین' },
{ label: 'واریز ریالی', value: 'واریز ریالی' },
{ label: 'واریز درگاه', value: 'واریز درگاه' },
{ label: 'واریز نقدی (فیش بانکی)', value: 'واریز نقدی (فیش بانکی)' },
{ label: 'واریز نقدی', value: 'واریز نقدی' },
{ label: 'شارژ حساب (فیش بانکی)', value: 'شارژ حساب (فیش بانکی)' },
{ label: 'درخواست واریز نقدی (فیش بانکی)', value: 'درخواست واریز نقدی (فیش بانکی)' },
{ label: 'شارژ کیف پول', value: 'شارژ کیف پول' },
{ label: 'کسر از کیف پول', value: 'کسر از کیف پول' },
{ label: 'برداشت فیزیکی', value: 'برداشت فیزیکی' },
{ label: 'خرید اقساطی', value: 'خرید اقساطی' },
{ label: 'پاداش بابت ثبت نام', value: 'پاداش بابت ثبت نام' },
{ label: 'پاداش اولین سفارش', value: 'پاداش اولین سفارش' },
{ label: 'پاداش اولین سفارش زیرمجموعه', value: 'پاداش اولین سفارش زیرمجموعه' },
{ label: 'پاداش خرید اول زیرمجموعه', value: 'پاداش خرید اول زیرمجموعه' },
{ label: 'کارمزد ثبت سفارش شرطی', value: 'کارمزد ثبت سفارش شرطی' },
{ label: 'انتقال به کیف اصلی', value: 'انتقال به کیف اصلی' },
{ label: 'انتقال از کیف محصول', value: 'انتقال از کیف محصول' }
]
2026-06-23 22:31:07 +03:30
export function getWithdrawColumns(): BaseTableColumn[] {
return [
2026-01-24 17:45:54 +03:30
{
title: 'ردیف',
dataIndex: 'id',
key: 'id',
filterable: false,
sortable: false,
customRender: (record: any) => {
return record.index + 1
}
},
{
title: 'علت تراکنش',
dataIndex: 'note',
key: 'note',
type: 'Select',
filterComponentProps: {
placeholder: 'انتخاب علت تراکنش',
allowClear: true,
showSearch: true,
options: WITHDRAW_NOTE_OPTIONS,
filterOption: (input: string, option: any) =>
(option?.label ?? '').toLowerCase().includes(input.toLowerCase())
}
2026-01-24 17:45:54 +03:30
},
{
title: 'شماره پیگیری',
dataIndex: 'tracked_number',
key: 'tracked_number',
type: 'Number',
slot: 'tracked',
customRender: (record: any) => record.record.tracked_number ?? '__'
// className: 'column-money'
},
{
title: 'کد سفارش',
dataIndex: 'id',
key: 'id',
type: 'Number'
// className: 'column-money'
},
{
title: 'کد کاربر',
dataIndex: 'customer_id',
key: 'customer_id',
type: 'Number'
},
{
title: 'نام و نام خانوادگی',
dataIndex: 'customer.name',
key: 'customer.name',
type: 'Text'
},
{
title: 'شناسه واریز',
dataIndex: 'deposit_identifier',
key: 'deposit_identifier',
type: 'Text',
customRender: ({ record }: any) => {
const val = record?.deposit_identifier || record?.customer?.n_code
return val ? <span dir="ltr" class="font-mono text-xs">{val}</span> : '-'
}
},
{
title: 'فیش واریزی',
dataIndex: 'receipt_url',
key: 'receipt_url',
slot: 'receipt',
filterable: false,
sortable: false
},
2026-01-24 17:45:54 +03:30
{
2026-06-24 01:46:30 +03:30
title: 'نوع',
dataIndex: 'asset_type',
key: 'asset_type',
filterable: false,
sortable: false,
2026-01-24 17:45:54 +03:30
customRender: ({ record }) => {
2026-06-24 01:46:30 +03:30
const label = withdrawTypeLabel(record)
if (label === '-') {
return <div class="flex justify-center px-6">-</div>
}
2026-01-24 17:45:54 +03:30
return (
<div class="flex justify-center">
2026-06-24 01:46:30 +03:30
<CustomTag
textColor={isMoneyWithdraw(record) ? '#25855A' : '#ca8a04'}
bgColor={isMoneyWithdraw(record) ? '#E3F4E9' : '#fef3c7'}
class="font-bold px-6"
>
{label}
</CustomTag>
2026-01-24 17:45:54 +03:30
</div>
)
}
},
{
2026-06-24 01:46:30 +03:30
title: 'مقدار',
dataIndex: 'amount',
key: 'amount',
2026-01-24 17:45:54 +03:30
type: 'Number',
2026-06-24 01:46:30 +03:30
customRender: ({ record }) => {
const colorClass = withdrawAmountColorClass(record)
return (
<div class="flex justify-center">
<div class={`font-bold px-6 ${colorClass}`}>{formatWithdrawAmountDisplay(record)}</div>
</div>
)
}
2026-01-24 17:45:54 +03:30
},
{
title: 'شماره کارت',
dataIndex: 'bank_account.cart_number',
key: 'bank_account.cart_number',
type: 'Number',
customRender: (data) => {
return data.record.bank_account?.cart_number ?? '_'
}
},
{
title: 'شماره شبا',
dataIndex: 'bank_account.shaba_number',
key: 'bank_account.shaba_number',
type: 'Text',
customRender: (data) => {
return data.record.bank_account?.shaba_number ?? '_'
}
},
2026-01-24 17:45:54 +03:30
{
title: 'وضعیت',
dataIndex: 'sts',
key: 'sts',
filterable: false,
/*customRender: ({ record }) => {
switch (record.sts) {
case 1:
return (
<div class="flex justify-center font-bold">
<CustomTag textColor="#ca8a04" bgColor="#fef3c7" class="px-2">
{record.sts_str}
</CustomTag>
</div>
)
case 2:
return (
<div class="flex justify-center font-bold px-2">
<CustomTag textColor="#25855A" bgColor="#E3F4E9" class="px-2">
{record.sts_str}
</CustomTag>
</div>
)
case 4:
return (
<div class="flex justify-center font-bold px-2">
<CustomTag textColor="#25855A" bgColor="#E3F4E9" class="px-2">
{record.sts_str}
</CustomTag>
</div>
)
default:
return (
<div class="flex justify-center font-bold px-2">
<CustomTag textColor="#C53030" bgColor="#FECACA" class="px-2">
{record.sts_str}
</CustomTag>
</div>
)
}
}*/
customRender: ({ record }: any) => {
let textColor = '#ca8a04'
let bgColor = '#fef3c7'
if (record?.sts === 2 || record?.sts === 4) {
textColor = '#25855A'
bgColor = '#E3F4E9'
} else if (record?.sts === 3) {
textColor = '#C53030'
bgColor = '#FECACA'
}
2026-01-24 17:45:54 +03:30
return (
<CustomTag textColor={textColor} bgColor={bgColor}>{record?.sts_str || '-'}</CustomTag>
2026-01-24 17:45:54 +03:30
)
},
},
{
title: 'تاریخ ثبت',
dataIndex: 'created_at',
key: 'created_at',
type: 'DateTime',
customRender: (record: any) => {
return toJalali(record.record.created_at)
}
},
{
title: 'عملیات',
dataIndex: 'action',
key: 'action',
width: 200,
slot: 'action',
filterable: false
}
/* {
title: 'تاریخ تایید',
dataIndex: 'updated_at',
key: 'updated_at',
type: 'DateTime',
customRender: (record: any) => {
return toJalaliNoTime(record.record.created_at)
}
},*/
/*{
title: 'نقش',
dataIndex: 'user_type_record',
key: 'user_type_record',
type: 'Select',
filterable: false,
sortable: false,
filterComponentProps: {
multiple: true
},
filterField: 'user_type_obj.id',
filterComponent: ReadyUserTypeSelect,
/!* customRender: (record: any) => {
return record.record.user_type_record?.value
}*!/
customRender: ({ record }) => {
const items = record.is_admin ? (
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
ادمین
</CustomTag>
) : (
record.user_type_obj.map((item: { title: any }, index: any) => {
if (item) {
return (
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
{item?.title}
</CustomTag>
)
}
})
)
return <div class="flex justify-center items-center gap-2">{items}</div>
}
},
{
title: 'حوزه',
dataIndex: 'section',
key: 'section'
},
{
title: 'شماره موبایل',
dataIndex: 'mobile',
type: 'Number',
key: 'mobile'
},*/
/* {
title: 'عملیات',
dataIndex: 'action',
key: 'action',
slot: 'action',
fixed: 'right',
filterable: false
}*/
2026-06-23 22:31:07 +03:30
]
}