refactor: Перенос AppointmentViewModal в папку Dummies
Перемещены компоненты и хуки для AppointmentViewModal. Обновлены импорты в HomePage и AppointmentsPage. Добавлено вывод на печать результатов приема
This commit is contained in:
parent
6cfa2dcca2
commit
01a27978e6
@ -22,6 +22,7 @@ const AppointmentViewModal = () => {
|
|||||||
downloadFile,
|
downloadFile,
|
||||||
deletingFiles,
|
deletingFiles,
|
||||||
deleteFile,
|
deleteFile,
|
||||||
|
printResults,
|
||||||
} = useAppointmentView();
|
} = useAppointmentView();
|
||||||
|
|
||||||
if (!selectedAppointment) {
|
if (!selectedAppointment) {
|
||||||
@ -103,7 +104,6 @@ const AppointmentViewModal = () => {
|
|||||||
{deletingFiles[file.id] ? labels.deleting : labels.delete}
|
{deletingFiles[file.id] ? labels.deleting : labels.delete}
|
||||||
</Button>
|
</Button>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<Divider/>
|
<Divider/>
|
||||||
</Row>
|
</Row>
|
||||||
@ -113,6 +113,13 @@ const AppointmentViewModal = () => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Row justify="end" style={footerRowStyle}>
|
<Row justify="end" style={footerRowStyle}>
|
||||||
|
<Button
|
||||||
|
style={footerButtonStyle}
|
||||||
|
onClick={printResults}
|
||||||
|
disabled={!selectedAppointment.results || selectedAppointment.results === labels.resultsNotSpecified}
|
||||||
|
>
|
||||||
|
{labels.printResults}
|
||||||
|
</Button>
|
||||||
<Button style={footerButtonStyle} onClick={onCancel}>
|
<Button style={footerButtonStyle} onClick={onCancel}>
|
||||||
{labels.closeButton}
|
{labels.closeButton}
|
||||||
</Button>
|
</Button>
|
||||||
@ -45,6 +45,7 @@ const useAppointmentView = () => {
|
|||||||
delete: "Удалить",
|
delete: "Удалить",
|
||||||
deleting: "Удаление...",
|
deleting: "Удаление...",
|
||||||
confirmDelete: "Вы уверены, что хотите удалить файл?",
|
confirmDelete: "Вы уверены, что хотите удалить файл?",
|
||||||
|
printResults: "Печать результатов",
|
||||||
};
|
};
|
||||||
|
|
||||||
const visible = !!selectedAppointment;
|
const visible = !!selectedAppointment;
|
||||||
@ -113,7 +114,6 @@ const useAppointmentView = () => {
|
|||||||
link.click();
|
link.click();
|
||||||
link.remove();
|
link.remove();
|
||||||
window.URL.revokeObjectURL(downloadUrl);
|
window.URL.revokeObjectURL(downloadUrl);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error downloading file:", error);
|
console.error("Error downloading file:", error);
|
||||||
notification.error({
|
notification.error({
|
||||||
@ -147,6 +147,69 @@ const useAppointmentView = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const printResults = () => {
|
||||||
|
if (!selectedAppointment?.results || selectedAppointment.results === labels.resultsNotSpecified) {
|
||||||
|
notification.error({
|
||||||
|
message: "Ошибка печати",
|
||||||
|
description: "Результаты приема отсутствуют.",
|
||||||
|
placement: "topRight",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const results = getResults(selectedAppointment.results);
|
||||||
|
const patientName = getPatientName(selectedAppointment.patient);
|
||||||
|
const appointmentTime = getAppointmentTime(selectedAppointment.appointment_datetime);
|
||||||
|
|
||||||
|
const printWindow = window.open('', '_blank', 'width=800,height=600');
|
||||||
|
if (!printWindow) {
|
||||||
|
notification.error({
|
||||||
|
message: "Ошибка печати",
|
||||||
|
description: "Не удалось открыть окно для печати. Проверьте настройки блокировки всплывающих окон.",
|
||||||
|
placement: "topRight",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printWindow.document.write(`
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Результаты приема - ${patientName}</title>
|
||||||
|
<style>
|
||||||
|
body { font-family: Arial, sans-serif; margin: 20px; }
|
||||||
|
h1 { font-size: 24px; }
|
||||||
|
h2 { font-size: 18px; margin-bottom: 10px; }
|
||||||
|
.results { font-size: 16px; line-height: 1.5; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Результаты приема</h1>
|
||||||
|
<h2>Пациент: ${patientName}</h2>
|
||||||
|
<h2>Дата и время приема: ${appointmentTime}</h2>
|
||||||
|
<div class="results">${results}</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`);
|
||||||
|
printWindow.document.close();
|
||||||
|
|
||||||
|
printWindow.onload = () => {
|
||||||
|
printWindow.focus();
|
||||||
|
printWindow.print();
|
||||||
|
setTimeout(() => {
|
||||||
|
printWindow.close();
|
||||||
|
}, 500);
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error printing results:", error);
|
||||||
|
notification.error({
|
||||||
|
message: "Ошибка печати",
|
||||||
|
description: "Не удалось выполнить печать. Попробуйте снова.",
|
||||||
|
placement: "topRight",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
modalWidth,
|
modalWidth,
|
||||||
blockStyle,
|
blockStyle,
|
||||||
@ -168,6 +231,7 @@ const useAppointmentView = () => {
|
|||||||
deletingFiles,
|
deletingFiles,
|
||||||
deleteFile,
|
deleteFile,
|
||||||
isDeletingFile,
|
isDeletingFile,
|
||||||
|
printResults,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ import {
|
|||||||
setSelectedAppointment,
|
setSelectedAppointment,
|
||||||
setSelectedScheduledAppointment
|
setSelectedScheduledAppointment
|
||||||
} from "../../../Redux/Slices/appointmentsSlice.js";
|
} from "../../../Redux/Slices/appointmentsSlice.js";
|
||||||
import AppointmentViewModal from "../../Widgets/AppointmentViewModal/AppointmentViewModal.jsx";
|
import AppointmentViewModal from "../../Dummies/AppointmentViewModal/AppointmentViewModal.jsx";
|
||||||
import ScheduledAppointmentFormModal
|
import ScheduledAppointmentFormModal
|
||||||
from "../../Dummies/ScheduledAppintmentFormModal/ScheduledAppointmentFormModal.jsx";
|
from "../../Dummies/ScheduledAppintmentFormModal/ScheduledAppointmentFormModal.jsx";
|
||||||
import ScheduledAppointmentsViewModal
|
import ScheduledAppointmentsViewModal
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import {
|
|||||||
import AppointmentFormModal from "../../Dummies/AppointmentFormModal/AppointmentFormModal.jsx";
|
import AppointmentFormModal from "../../Dummies/AppointmentFormModal/AppointmentFormModal.jsx";
|
||||||
import ScheduledAppointmentFormModal
|
import ScheduledAppointmentFormModal
|
||||||
from "../../Dummies/ScheduledAppintmentFormModal/ScheduledAppointmentFormModal.jsx";
|
from "../../Dummies/ScheduledAppintmentFormModal/ScheduledAppointmentFormModal.jsx";
|
||||||
import AppointmentViewModal from "../../Widgets/AppointmentViewModal/AppointmentViewModal.jsx";
|
import AppointmentViewModal from "../../Dummies/AppointmentViewModal/AppointmentViewModal.jsx";
|
||||||
import ScheduledAppointmentsViewModal
|
import ScheduledAppointmentsViewModal
|
||||||
from "../../Widgets/ScheduledAppointmentsViewModal/ScheduledAppointmentsViewModal.jsx";
|
from "../../Widgets/ScheduledAppointmentsViewModal/ScheduledAppointmentsViewModal.jsx";
|
||||||
import PatientFormModal from "../../Dummies/PatientFormModal/PatientFormModal.jsx";
|
import PatientFormModal from "../../Dummies/PatientFormModal/PatientFormModal.jsx";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user