94 lines
2.1 KiB
TypeScript
94 lines
2.1 KiB
TypeScript
import type { BaseTableColumn } from '@core/type/baseTable'
|
|
|
|
const triggerLabel: Record<string, string> = {
|
|
schedule: 'زماندار',
|
|
event: 'رویداد',
|
|
price: 'حرکت قیمت',
|
|
}
|
|
|
|
function channelText(record: any): string {
|
|
const ch = Array.isArray(record.channels) ? record.channels : []
|
|
const parts: string[] = []
|
|
if (ch.includes('sms')) parts.push('پیامک')
|
|
if (ch.includes('in_app')) parts.push('اعلان')
|
|
return parts.join(' / ') || '—'
|
|
}
|
|
|
|
function previewBody(text: unknown): string {
|
|
const s = String(text || '').replace(/\s+/g, ' ').trim()
|
|
if (!s) return '—'
|
|
return s.length > 48 ? `${s.slice(0, 48)}…` : s
|
|
}
|
|
|
|
export const cols: BaseTableColumn[] = [
|
|
{
|
|
title: 'ردیف',
|
|
dataIndex: 'id',
|
|
key: 'id',
|
|
customRender: (record: any) => record.index + 1,
|
|
},
|
|
{
|
|
title: 'نام',
|
|
dataIndex: 'name',
|
|
key: 'name',
|
|
type: 'Text',
|
|
},
|
|
{
|
|
title: 'کد',
|
|
dataIndex: 'code',
|
|
key: 'code',
|
|
},
|
|
{
|
|
title: 'عنوان',
|
|
dataIndex: 'title',
|
|
key: 'title',
|
|
type: 'Text',
|
|
},
|
|
{
|
|
title: 'متن',
|
|
dataIndex: 'body',
|
|
key: 'body',
|
|
customRender: ({ record }) => previewBody(record.body),
|
|
},
|
|
{
|
|
title: 'نوع',
|
|
dataIndex: 'trigger_type',
|
|
key: 'trigger_type',
|
|
customRender: ({ record }) => triggerLabel[record.trigger_type] || record.trigger_type,
|
|
},
|
|
{
|
|
title: 'کانال',
|
|
dataIndex: 'channels',
|
|
key: 'channels',
|
|
customRender: ({ record }) => channelText(record),
|
|
},
|
|
{
|
|
title: 'فعال',
|
|
dataIndex: 'is_active',
|
|
key: 'is_active',
|
|
slot: 'is_active',
|
|
width: 90,
|
|
},
|
|
{
|
|
title: 'ارسال شده',
|
|
dataIndex: 'sent_count',
|
|
key: 'sent_count',
|
|
customRender: ({ record }) => Number(record.sent_count ?? 0),
|
|
},
|
|
{
|
|
title: 'ناموفق',
|
|
dataIndex: 'failed_count',
|
|
key: 'failed_count',
|
|
customRender: ({ record }) => Number(record.failed_count ?? 0),
|
|
},
|
|
{
|
|
title: 'عملیات',
|
|
dataIndex: 'action',
|
|
key: 'action',
|
|
slot: 'action',
|
|
fixed: 'right',
|
|
filterable: false,
|
|
width: 120,
|
|
},
|
|
]
|