From a99db338cd90124353df3b4db69330bb6d5e7d96 Mon Sep 17 00:00:00 2001 From: andrei Date: Sat, 1 Mar 2025 17:13:43 +0500 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD=D0=B7=20=D0=B2=20=D0=B2=D0=B8=D0=B4=D0=B5=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=80=D1=82=D0=BE=D1=87=D0=B5=D0=BA=20=D0=B8=20?= =?UTF-8?q?=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D1=8B,=20=D0=B8=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB=20=D0=BC=D0=BE=D0=B4=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=BE=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=B6=D0=B4=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B0=20=D0=B2?= =?UTF-8?q?=D1=81=D0=BF=D0=BB=D1=8B=D0=B2=D0=B0=D1=8E=D1=89=D1=83=D1=8E=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/lenses/LensListCard.jsx | 29 +-- .../components/patients/PatientListCard.jsx | 30 +-- web-app/src/components/sets/SetListCard.jsx | 51 ++--- web-app/src/pages/LensesPage.jsx | 175 ++++++++++++++---- web-app/src/pages/PatientsPage.jsx | 5 +- 5 files changed, 205 insertions(+), 85 deletions(-) diff --git a/web-app/src/components/lenses/LensListCard.jsx b/web-app/src/components/lenses/LensListCard.jsx index 54d4c0f..3b6fccb 100644 --- a/web-app/src/components/lenses/LensListCard.jsx +++ b/web-app/src/components/lenses/LensListCard.jsx @@ -1,4 +1,4 @@ -import {Card, Modal, Tooltip} from "antd"; +import {Card, Popconfirm, Tooltip} from "antd"; import PropTypes from "prop-types"; import {DeleteOutlined, EditOutlined, EyeOutlined} from "@ant-design/icons"; import {useState} from "react"; @@ -7,15 +7,9 @@ import LensViewModal from "./LensViewModal.jsx"; const LensListCard = ({lens, handleEditLens, handleDeleteLens}) => { const [showModalInfo, setShowModalInfo] = useState(false); - const deleteLensConfirm = () => { - Modal.confirm({ - title: "Удаление линзы", - content: `Вы уверены, что хотите удалить линзу с параметрами ${lens.side} ${lens.diameter}мм?`, - okText: "Да, удалить", - cancelText: "Отмена", - onOk: () => handleDeleteLens(lens.id), - }); - }; + const deleteLens = () => { + handleDeleteLens(lens.id); + } const handleViewLens = () => { setShowModalInfo(true); @@ -29,10 +23,17 @@ const LensListCard = ({lens, handleEditLens, handleDeleteLens}) => { handleEditLens(lens)}/> , - + + + , ]; diff --git a/web-app/src/components/patients/PatientListCard.jsx b/web-app/src/components/patients/PatientListCard.jsx index 70553cb..60f4ff8 100644 --- a/web-app/src/components/patients/PatientListCard.jsx +++ b/web-app/src/components/patients/PatientListCard.jsx @@ -1,4 +1,4 @@ -import {Card, Modal, Tooltip} from "antd"; +import {Card, Modal, Popconfirm, Tooltip} from "antd"; import PropTypes from "prop-types"; import {DeleteOutlined, EditOutlined, EyeOutlined} from "@ant-design/icons"; import {useState} from "react"; @@ -9,14 +9,9 @@ const PatientListCard = ({patient, handleEditPatient, handleDeletePatient}) => { const birthday = new Date(patient.birthday) - const deletePatientConfirm = () => { - Modal.confirm({ - title: "Удаление пациента", - content: `Вы уверены, что хотите удалить пациента ${patient.last_name} ${patient.first_name}?`, - okText: "Да, удалить", - cancelText: "Отмена", - onOk: () => handleDeletePatient(patient.id), - }); + + const deletePatient = () => { + handleDeletePatient(patient.id); }; const handleViewPatient = () => { @@ -38,10 +33,17 @@ const PatientListCard = ({patient, handleEditPatient, handleDeletePatient}) => { /> , - + + + , ]; @@ -66,7 +68,7 @@ const PatientListCard = ({patient, handleEditPatient, handleDeletePatient}) => { onCancel={() => setShowModalInfo(false)} patient={patient} /> - + ); }; diff --git a/web-app/src/components/sets/SetListCard.jsx b/web-app/src/components/sets/SetListCard.jsx index cb014ab..20f84fb 100644 --- a/web-app/src/components/sets/SetListCard.jsx +++ b/web-app/src/components/sets/SetListCard.jsx @@ -1,34 +1,30 @@ import PropTypes from "prop-types"; -import {Card, Modal, Tooltip} from "antd"; +import {Card, Modal, Popconfirm, Tooltip} from "antd"; import {DeleteOutlined, EditOutlined, PlusOutlined} from "@ant-design/icons"; const SetListCard = ({set, handleEditSet, handleDeleteSet, handleAppendSet}) => { - const confirmSetDelete = () => { - Modal.confirm({ - title: "Удаление набора", - content: `Вы уверены, что хотите удалить набор ${set.title}?`, - okText: "Да, удалить", - cancelText: "Отмена", - onOk: () => handleDeleteSet(set.id), - }); + + const deleteSet = () => { + handleDeleteSet(set.id); }; - const confirmAppendSet = () => { - Modal.confirm({ - title: "Добавление набора", - content: `Вы уверены, что хотите добавить набор ${set.title} в общий список линз?`, - okText: "Да, добавить", - cancelText: "Отмена", - onOk: () => handleAppendSet(set), - }); + + const appendSet = () => { + handleAppendSet(set); }; const actions = [ - + + + , @@ -40,10 +36,17 @@ const SetListCard = ({set, handleEditSet, handleDeleteSet, handleAppendSet}) => , - + + + , ]; diff --git a/web-app/src/pages/LensesPage.jsx b/web-app/src/pages/LensesPage.jsx index c1a3e50..ee02f21 100644 --- a/web-app/src/pages/LensesPage.jsx +++ b/web-app/src/pages/LensesPage.jsx @@ -10,7 +10,7 @@ import { Button, Form, InputNumber, - Card, Grid, notification + Card, Grid, notification, Dropdown, Table, Popconfirm } from "antd"; import {LoadingOutlined, PlusOutlined, DownOutlined, UpOutlined} from "@ant-design/icons"; import LensCard from "../components/lenses/LensListCard.jsx"; @@ -32,6 +32,7 @@ const LensesPage = () => { const [pageSize, setPageSize] = useState(10); const [searchText, setSearchText] = useState(""); + const [viewMode, setViewMode] = useState("tile"); const [lenses, setLenses] = useState([]); const [loading, setLoading] = useState(true); const [isModalVisible, setIsModalVisible] = useState(false); @@ -183,10 +184,137 @@ const LensesPage = () => { setIsModalVisible(false); }; + const TileView = () => ( + ( + + handleDeleteLens(lens.id)} + handleEditLens={() => handleEditLens(lens)} + /> + + )} + pagination={{ + current, + pageSize, + showSizeChanger: true, + pageSizeOptions: ["5", "10", "20", "50"], + onChange: (page, newPageSize) => { + setCurrent(page); + setPageSize(newPageSize); + }, + }} + /> + ); + + + const columns = [ + { + title: "Тор", + dataIndex: "tor", + key: "tor", + sorter: (a, b) => a.tor - b.tor, + }, + { + title: "Диаметр", + dataIndex: "diameter", + key: "diameter", + sorter: (a, b) => a.diameter - b.diameter, + }, + { + title: "Пресетная рефракция", + dataIndex: "preset_refraction", + key: "preset_refraction", + sorter: (a, b) => a.preset_refraction - b.preset_refraction, + }, + { + title: "Периферия торичность", + dataIndex: "periphery_toricity", + key: "periphery_toricity", + sorter: (a, b) => a.periphery_toricity - b.periphery_toricity, + }, + { + title: "FVC", + dataIndex: "fvc", + key: "fvc", + sorter: (a, b) => a.fvc - b.fvc, + }, + { + title: "Trial", + dataIndex: "trial", + key: "trial", + sorter: (a, b) => a.trial - b.trial, + }, + { + title: "Сторона", + dataIndex: "side", + key: "side", + filters: [ + {text: "Левая", value: "левая"}, + {text: "Правая", value: "правая"}, + ], + onFilter: (value, record) => record.side === value, + }, + { + title: "Выдана", + dataIndex: "issued", + key: "issued", + render: (issued) => (issued ? "Да" : "Нет"), + filters: [ + {text: "Да", value: true}, + {text: "Нет", value: false}, + ], + onFilter: (value, record) => record.issued === value, + }, + { + title: "Действия", + key: "actions", + fixed: 'right', + render: (text, record) => ( +
+ + + handleDeleteLens(record.id)} + okText="Да, удалить" + cancelText="Отмена" + > + + +
+ ), + }, + ]; + + const TableView = () => ( + { + setCurrent(page); + setPageSize(newPageSize); + }, + }} + /> + ); + + return (
-
+ { Расширенный поиск + + + {showAdvancedSearch && ( @@ -324,38 +462,13 @@ const LensesPage = () => { )} {loading ? ( -
+
}/>
+ ) : viewMode === "tile" ? ( + ) : ( - ( - - handleDeleteLens(lens.id)} - handleEditLens={() => handleEditLens(lens)} - /> - - )} - pagination={{ - current, - pageSize, - showSizeChanger: true, - pageSizeOptions: ["5", "10", "20", "50"], - onChange: (page, newPageSize) => { - setCurrent(page); - setPageSize(newPageSize); - }, - }} - /> + )} { if (selectedPatient) { await editPatient(newPatient); } else { - await addPatient(newPatient); + await addNewPatient(newPatient); } setIsModalVisible(false); await fetchPatients(); } catch (error) { + console.log(error); notification.error({ message: "Ошибка", description: error.response?.status === 401 @@ -147,7 +148,7 @@ const PatientsPage = () => { }); }; - const addPatient = async (patient) => { + const addNewPatient = async (patient) => { await addPatient(user.token, patient); notification.success({ message: "Пациент добавлен",