fix(print): enable full multi-page report printing, unconstrain viewport scrollbars, and add executive hospital letterhead
This commit is contained in:
@@ -289,11 +289,11 @@ export function DataTable<TData>({
|
||||
{flexRender(header.column.columnDef.header, header.getContext())}
|
||||
{header.column.getCanSort() && (
|
||||
header.column.getIsSorted() === "asc" ? (
|
||||
<ChevronUp className="h-3 w-3" />
|
||||
<ChevronUp className="h-3 w-3 no-print" />
|
||||
) : header.column.getIsSorted() === "desc" ? (
|
||||
<ChevronDown className="h-3 w-3" />
|
||||
<ChevronDown className="h-3 w-3 no-print" />
|
||||
) : (
|
||||
<ChevronsUpDown className="h-3 w-3 opacity-30" />
|
||||
<ChevronsUpDown className="h-3 w-3 opacity-30 no-print" />
|
||||
)
|
||||
)}
|
||||
</button>
|
||||
@@ -335,23 +335,30 @@ export function DataTable<TData>({
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
visibleRows.map((row) => (
|
||||
<tr
|
||||
key={row.id}
|
||||
className={cn(
|
||||
"hover:bg-blue-50/50 transition-colors",
|
||||
getRowClassName?.(row.original),
|
||||
onRowClick && "cursor-pointer"
|
||||
)}
|
||||
onClick={() => onRowClick?.(row.original)}
|
||||
>
|
||||
{row.getVisibleCells().map((cell) => (
|
||||
<td key={cell.id} className="px-2.5 py-2 sm:px-4 sm:py-3 text-gray-700">
|
||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
))
|
||||
(() => {
|
||||
const visibleRowIdSet = new Set(visibleRows.map((r) => r.id));
|
||||
return filteredRows.map((row) => {
|
||||
const isVisibleOnScreen = visibleRowIdSet.has(row.id);
|
||||
return (
|
||||
<tr
|
||||
key={row.id}
|
||||
className={cn(
|
||||
"hover:bg-blue-50/50 transition-colors",
|
||||
!isVisibleOnScreen && "print-table-row",
|
||||
getRowClassName?.(row.original),
|
||||
onRowClick && "cursor-pointer"
|
||||
)}
|
||||
onClick={() => onRowClick?.(row.original)}
|
||||
>
|
||||
{row.getVisibleCells().map((cell) => (
|
||||
<td key={cell.id} className="px-2.5 py-2 sm:px-4 sm:py-3 text-gray-700">
|
||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
);
|
||||
});
|
||||
})()
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
+64
-26
@@ -21,12 +21,50 @@
|
||||
.print-only {
|
||||
display: none !important;
|
||||
}
|
||||
.print-table-row {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
@page {
|
||||
size: A4 landscape;
|
||||
margin: 8mm 10mm;
|
||||
margin: 8mm 8mm;
|
||||
}
|
||||
|
||||
/* Unconstrain viewport and scroll containers so full multi-page content flows naturally */
|
||||
html,
|
||||
body {
|
||||
height: auto !important;
|
||||
min-height: 0 !important;
|
||||
max-height: none !important;
|
||||
overflow: visible !important;
|
||||
background: #ffffff !important;
|
||||
color: #102C52 !important;
|
||||
font-size: 9.5px !important;
|
||||
line-height: 1.35 !important;
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
}
|
||||
|
||||
#root,
|
||||
#root > div,
|
||||
.h-screen,
|
||||
.overflow-hidden,
|
||||
.overflow-y-auto,
|
||||
.overflow-x-auto,
|
||||
main {
|
||||
height: auto !important;
|
||||
min-height: 0 !important;
|
||||
max-height: none !important;
|
||||
overflow: visible !important;
|
||||
position: static !important;
|
||||
display: block !important;
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
aside,
|
||||
@@ -40,23 +78,11 @@
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #ffffff !important;
|
||||
color: #0f172a !important;
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
font-size: 10px !important;
|
||||
line-height: 1.35 !important;
|
||||
.print-table-row {
|
||||
display: table-row !important;
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
overflow: visible !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
/* Prevent elements from breaking across PDF pages */
|
||||
/* Prevent elements from breaking awkwardly across pages */
|
||||
.print-break-inside-avoid {
|
||||
break-inside: avoid !important;
|
||||
page-break-inside: avoid !important;
|
||||
@@ -67,7 +93,7 @@
|
||||
page-break-before: always !important;
|
||||
}
|
||||
|
||||
/* Clean up card shadows and borders for crisp PDF generation */
|
||||
/* Clean up card shadows and borders for crisp printing */
|
||||
.shadow-sm,
|
||||
.shadow,
|
||||
.shadow-md,
|
||||
@@ -75,11 +101,12 @@
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
/* High-fidelity PDF Table Styling */
|
||||
/* High-fidelity PDF & Print Table Styling */
|
||||
table {
|
||||
border-collapse: collapse !important;
|
||||
width: 100% !important;
|
||||
page-break-inside: auto;
|
||||
table-layout: auto !important;
|
||||
}
|
||||
|
||||
thead {
|
||||
@@ -96,28 +123,39 @@
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #1e3a8a !important;
|
||||
background-color: #102C52 !important;
|
||||
color: #ffffff !important;
|
||||
font-weight: 600 !important;
|
||||
font-size: 9.5px !important;
|
||||
padding: 5px 6px !important;
|
||||
border: 1px solid #1e293b !important;
|
||||
text-align: center !important;
|
||||
font-size: 9px !important;
|
||||
padding: 4px 6px !important;
|
||||
border: 1px solid #102C52 !important;
|
||||
text-align: left !important;
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
}
|
||||
|
||||
td {
|
||||
border: 1px solid #cbd5e1 !important;
|
||||
font-size: 9px !important;
|
||||
padding: 4px 6px !important;
|
||||
font-size: 8.5px !important;
|
||||
padding: 3.5px 5px !important;
|
||||
color: #0f172a !important;
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
}
|
||||
|
||||
tbody tr:nth-child(even) td {
|
||||
background-color: #f8fafc !important;
|
||||
}
|
||||
|
||||
/* Force chart svg visibility */
|
||||
/* Ensure chart SVG visibility in print mode */
|
||||
.recharts-responsive-container {
|
||||
width: 100% !important;
|
||||
min-width: 100% !important;
|
||||
height: 220px !important;
|
||||
}
|
||||
|
||||
.recharts-wrapper {
|
||||
margin: 0 auto !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import {
|
||||
} from "@/api/ai";
|
||||
import { categoriesApi, departmentsApi } from "@/api/masters";
|
||||
import { useAuthStore } from "@/hooks/useAuth";
|
||||
import { formatINR } from "@/lib/format";
|
||||
import { formatDateTime, formatINR } from "@/lib/format";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
|
||||
@@ -527,6 +527,64 @@ export function AIReportPage() {
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Print-Only Official Hospital Letterhead & Scope */}
|
||||
<div className="print-only mb-4 border-b-2 border-[#102C52] pb-3">
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex items-center gap-3.5">
|
||||
<img
|
||||
src="/logo.jpg"
|
||||
alt="XYZ Hospital"
|
||||
className="h-14 w-14 object-contain"
|
||||
/>
|
||||
<div>
|
||||
<div className="text-base font-extrabold text-[#102C52] tracking-tight">
|
||||
XYZ HOSPITAL
|
||||
</div>
|
||||
<div className="text-[11px] font-semibold text-gray-800">
|
||||
NABH Accredited Tertiary Care Hospital • Department of Clinical Engineering
|
||||
</div>
|
||||
<div className="text-[10px] text-gray-500">
|
||||
27, Sadashiv Peth, Pune, Maharashtra 411030 • Tel: +91 20 6609 6000
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right text-[10px] text-gray-600 space-y-0.5 border-l border-gray-200 pl-3">
|
||||
<div className="font-bold text-[#102C52] uppercase tracking-wider">
|
||||
Executive AI & Cost Analysis
|
||||
</div>
|
||||
<div>
|
||||
<strong>Ref:</strong> XYZ-BME-AI-REP
|
||||
</div>
|
||||
<div>
|
||||
<strong>Date:</strong> {formatDateTime(new Date().toISOString())} IST
|
||||
</div>
|
||||
{user?.name && (
|
||||
<div>
|
||||
<strong>Generated by:</strong> {user.name} ({user.role?.replace(/_/g, " ").toUpperCase()})
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Print Filter / Scope summary bar */}
|
||||
<div className="mt-2.5 pt-2 border-t border-gray-200 flex flex-wrap items-center justify-between text-[10px] text-gray-700 bg-gray-50 px-3 py-1.5 rounded">
|
||||
<div className="flex items-center gap-4 flex-wrap">
|
||||
<div>
|
||||
<span className="text-gray-500">Analysis:</span>{" "}
|
||||
<strong>AI Report & Cost Analysis</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-500">Period:</span>{" "}
|
||||
<strong>{period.toUpperCase()}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span className="text-gray-500">Summary Mode:</span>{" "}
|
||||
<strong>{statusChipLabel}</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Header + Mode Segmented Toggle + Status Chip */}
|
||||
<div className="flex flex-wrap items-start justify-between gap-3">
|
||||
<div>
|
||||
@@ -1545,6 +1603,47 @@ export function AIReportPage() {
|
||||
All figures are calculated deterministically from hospital records. Summaries are advisory only and never replace clinical or administrative sign-off.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Hospital Tripartite Sign-off Block (Print / PDF Only) */}
|
||||
<div className="print-only mt-8 pt-4 border-t-2 border-gray-300 print-break-inside-avoid">
|
||||
<div className="flex items-center justify-between text-[10px] font-bold uppercase tracking-wider text-gray-700 mb-4">
|
||||
<span>Hospital Engineering Audit & Verification Sign-off (NABH Chapter FMS)</span>
|
||||
<span>XYZ Hospital</span>
|
||||
</div>
|
||||
<div className="grid grid-cols-3 gap-5 text-[10px]">
|
||||
<div className="border border-gray-300 rounded p-3 space-y-4 bg-gray-50/50">
|
||||
<div className="font-bold text-gray-800">1. PREPARED BY</div>
|
||||
<div className="h-9 border-b border-dashed border-gray-400"></div>
|
||||
<div className="space-y-0.5 text-gray-600">
|
||||
<div>Name: {user?.name || "Biomedical Engineer"}</div>
|
||||
<div>Role: {user?.role?.replace(/_/g, " ").toUpperCase() || "BIOMEDICAL"}</div>
|
||||
<div>Date: {new Date().toLocaleDateString("en-IN")}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="border border-gray-300 rounded p-3 space-y-4 bg-gray-50/50">
|
||||
<div className="font-bold text-gray-800">2. VERIFIED BY</div>
|
||||
<div className="h-9 border-b border-dashed border-gray-400"></div>
|
||||
<div className="space-y-0.5 text-gray-600">
|
||||
<div>Name: __________________________</div>
|
||||
<div>Role: HOD / Biomedical In-Charge</div>
|
||||
<div>Date: ____ / ____ / ________</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="border border-gray-300 rounded p-3 space-y-4 bg-gray-50/50">
|
||||
<div className="font-bold text-gray-800">3. APPROVED BY</div>
|
||||
<div className="h-9 border-b border-dashed border-gray-400"></div>
|
||||
<div className="space-y-0.5 text-gray-600">
|
||||
<div>Name: __________________________</div>
|
||||
<div>Role: Medical Superintendent / Director</div>
|
||||
<div>Date: ____ / ____ / ________</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 pt-2 border-t border-gray-200 text-[9px] text-gray-500 flex items-center justify-between">
|
||||
<span>Official Hospital Record • XYZ Hospital • Confidential • Retain for 7 Years</span>
|
||||
<span>AMS Portal Generated • NABH Compliant</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ export function ReportDetailPage() {
|
||||
return (
|
||||
<div className="space-y-5">
|
||||
{/* Print-Only Official Hospital Letterhead & Scope */}
|
||||
<div className="hidden print:block mb-4 border-b-2 border-[#1e3a8a] pb-3">
|
||||
<div className="print-only mb-4 border-b-2 border-[#102C52] pb-3">
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex items-center gap-3.5">
|
||||
<img
|
||||
@@ -407,7 +407,7 @@ export function ReportDetailPage() {
|
||||
className="h-14 w-14 object-contain"
|
||||
/>
|
||||
<div>
|
||||
<div className="text-base font-extrabold text-[#1e3a8a] tracking-tight">
|
||||
<div className="text-base font-extrabold text-[#102C52] tracking-tight">
|
||||
XYZ HOSPITAL
|
||||
</div>
|
||||
<div className="text-[11px] font-semibold text-gray-800">
|
||||
@@ -419,11 +419,11 @@ export function ReportDetailPage() {
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-right text-[10px] text-gray-600 space-y-0.5 border-l border-gray-200 pl-3">
|
||||
<div className="font-bold text-[#1e3a8a] uppercase tracking-wider">
|
||||
<div className="font-bold text-[#102C52] uppercase tracking-wider">
|
||||
Audit & Operational Record
|
||||
</div>
|
||||
<div>
|
||||
<strong>Ref:</strong> PHRC-BME-{key?.toUpperCase() ?? "REP"}
|
||||
<strong>Ref:</strong> XYZ-BME-{key?.toUpperCase() ?? "REP"}
|
||||
</div>
|
||||
<div>
|
||||
<strong>Date:</strong> {formatDateTime(new Date().toISOString())} IST
|
||||
@@ -1032,7 +1032,7 @@ export function ReportDetailPage() {
|
||||
/>
|
||||
|
||||
{/* Hospital Tripartite Sign-off Block (Print / PDF Only) */}
|
||||
<div className="hidden print:block mt-8 pt-4 border-t-2 border-gray-300 print-break-inside-avoid">
|
||||
<div className="print-only mt-8 pt-4 border-t-2 border-gray-300 print-break-inside-avoid">
|
||||
<div className="flex items-center justify-between text-[10px] font-bold uppercase tracking-wider text-gray-700 mb-4">
|
||||
<span>Hospital Engineering Audit & Verification Sign-off (NABH Chapter FMS)</span>
|
||||
<span>XYZ Hospital</span>
|
||||
|
||||
Reference in New Issue
Block a user