Files
onboard/resources/js/Pages/Statistic/Components/InfoModal/columns/index.js

54 lines
2.6 KiB
JavaScript

// columns/index.js
import { h } from 'vue'
import { formatDistanceStrict } from 'date-fns'
import { ru } from 'date-fns/locale'
import TooltipColumn from '../../../../Report/Components/DataTableColumns/TooltipColumn.vue'
export function getColumns(type) {
// Базовые общие колонки
const base = [
{ title: '№', key: 'index', width: 30, render: (_, i) => i + 1 },
{ title: 'ФИО', key: 'full_name', width: 200, ellipsis: { tooltip: { arrow: false } } },
{ title: 'Возраст', key: 'age', width: 80, render: row => row.birth_date
? formatDistanceStrict(new Date(row.birth_date), new Date(), { locale: ru })
: '—' },
{ title: 'Диагноз', key: 'diagnosis', width: 90, render: row =>
row.diagnosis_code
? h(TooltipColumn, { triggerText: row.diagnosis_code, contentText: row.diagnosis_name })
: '—' },
{ title: 'Отделение', key: 'department_name', width: 220 },
]
// Дополнительные колонки для конкретных типов
const extra = {
RECIPIENT_ALL: [
{ title: 'Дата поступления', key: 'admission_date', width: 130 },
{ title: 'Тип', key: 'admission_type', width: 100 }, // планово/экстр
],
RECIPIENT_PLAN: [
{ title: 'Дата поступления', key: 'admission_date', width: 130 },
{ title: 'Тип', key: 'admission_type', width: 100 }, // планово/экстр
],
RECIPIENT_EMERGENCY: [
{ title: 'Дата поступления', key: 'admission_date', width: 130 },
{ title: 'Тип', key: 'admission_type', width: 100 }, // планово/экстр
],
SURGICAL_EMERGENCY: [
{ title: 'Дата операции', key: 'operation_date', width: 130 },
{ title: 'Хирург', key: 'surgeon', width: 150 },
{ title: 'Операция', key: 'operation_name', width: 200 },
],
SURGICAL_PLAN: [
{ title: 'Дата операции', key: 'operation_date', width: 130 },
{ title: 'Хирург', key: 'surgeon', width: 150 },
{ title: 'Операция', key: 'operation_name', width: 200 },
],
DECEASED: [
{ title: 'Дата смерти', key: 'death_date', width: 120 },
{ title: 'Причина смерти', key: 'cause_of_death', width: 150 },
],
}
return [...base, ...(extra[type] || [])]
}