Files
boursecu_admin/src/pages/menuPages/priceTriggers/hooks/priceTriggersColumns.tsx
T
2026-07-25 16:47:12 +03:30

228 lines
5.8 KiB
TypeScript

import type { BaseTableColumn } from '@core/type/baseTable'
import { toJalali } from '@core/utils/useDataTime'
import CustomTag from '@/components/CustomTag.vue'
/*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 cols: BaseTableColumn[] = [
{
title: 'ردیف',
dataIndex: 'id',
key: 'id',
customRender: (record: any) => {
return record.index + 1
}
},
{
title: 'مشتری',
dataIndex: 'customer',
key: 'customer',
type: 'Text',
customRender: ({ record }) => {
const name = record.customer?.name?.trim()
return name ? `${name} (${record.customer_id})` : String(record.customer_id ?? '-')
},
},
{
title: 'کد مشتری',
dataIndex: 'customer_id',
key: 'customer_id',
type: 'Number'
},
{
title: 'قیمت هدف',
dataIndex: 'target_price',
key: 'target_price',
type: 'Number'
},
{
title: 'شرط',
dataIndex: 'price_condition',
key: 'price_condition',
type: 'Text',
customRender: ({ record }) => {
return record.price_condition==">" ? (
<CustomTag>بزرگتر</CustomTag>
) : (
<CustomTag>کوچکتر</CustomTag>
)
}
},
{
title: 'زمان ایجاد',
dataIndex: 'created_at',
key: 'created_at',
type: 'Text',
customRender: ({ record }) => {
return toJalali(record.created_at)
}
},
{
title: 'زمان بروزرسانی',
dataIndex: 'updated_at',
key: 'updated_at',
type: 'Text',
customRender: ({ record }) => {
return toJalali(record.updated_at)
}
},
{
title: 'زمان اعلام',
dataIndex: 'triggered_at',
key: 'triggered_at',
type: 'Text',
customRender: ({ record }) => {
return record.triggered_at? toJalali(record.triggered_at) : '_'
}
},
{
title: 'وضعیت',
dataIndex: 'is_active',
key: 'is_active',
type: 'Boolean',
customRender: ({ record }) => {
return record.is_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>
)
},
// customRender: ({ record }) => {
// if(record.is_active) {
// return (
// <div class="flex justify-center">
// <CustomTag textColor="#C53030" bgColor="#FECACA">
// فروش
// </CustomTag>
// </div>
// )
// return (
// <div class="flex justify-center">
// <CustomTag textColor="#25855A" bgColor="#E3F4E9">
// خرید
// </CustomTag>
// </div>
// )
// }
// }
},
/* {
title: 'وضعیت',
dataIndex: 'active',
key: 'active',
customRender: ({ record }) => {
return record.active ? (
<div class="flex justify-center">
<CustomTag textColor="#25855A" bgColor="#E3F4E9">
فعال
</CustomTag>
</div>
) : (
<div class="flex justify-center">
<CustomTag textColor="#C53030" bgColor="#FECACA">
غیر فعال
</CustomTag>
</div>
)
}
},*/
/*{
title: 'سمت',
dataIndex: 'post_user',
key: 'post_user',
type: 'Text'
},
{
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: 'created_at',
key: 'created_at',
type: 'DateTime',
customRender: (record: any) => {
return toJalali(record.record.created_at)
}
},*/
{
title: 'روش ارسال',
dataIndex: 'action',
key: 'notify_action',
customRender: ({ record }) => (record.action === 'email' ? 'ایمیل' : 'پیامک'),
},
{
title: 'عملیات',
dataIndex: 'row_action',
key: 'row_action',
slot: 'action',
fixed: 'right',
filterable: false,
},
]