Browse Source

为tabbar和浮动菜单中的患者管理菜单项添加导航功能

dengdx 2 months ago
parent
commit
dcf16057eb
3 changed files with 118 additions and 7 deletions
  1. 10 4
      src/layouts/BasicLayout.tsx
  2. 8 3
      src/layouts/NavbarFloat.tsx
  3. 100 0
      src/pages/patient/PatientManagement.tsx

+ 10 - 4
src/layouts/BasicLayout.tsx

@@ -14,6 +14,7 @@ import HistorylistPage from '@/pages/patient/HistoryList';
 import ArchivelistPage from '@/pages/patient/ArchiveList';
 import ArchivelistPage from '@/pages/patient/ArchiveList';
 import BinPage from '@/pages/patient/Bin';
 import BinPage from '@/pages/patient/Bin';
 import OutputlistPage from '@/pages/patient/OutputList';
 import OutputlistPage from '@/pages/patient/OutputList';
+import PatientManagement from '@/pages/patient/PatientManagement';
 
 
 // import { Link } from 'react-router-dom';
 // import { Link } from 'react-router-dom';
 // import { MenuOutlined } from '@ant-design/icons';
 // import { MenuOutlined } from '@ant-design/icons';
@@ -52,6 +53,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = () => {
     archivelist: <ArchivelistPage />,
     archivelist: <ArchivelistPage />,
     bin: <BinPage />,
     bin: <BinPage />,
     outputlist: <OutputlistPage />,
     outputlist: <OutputlistPage />,
+    patient_management: <PatientManagement />,
   };
   };
   //感知菜单项点击
   //感知菜单项点击
   const handleMenuClick = (key: string) => {
   const handleMenuClick = (key: string) => {
@@ -148,17 +150,20 @@ const BasicLayout: React.FC<BasicLayoutProps> = () => {
         </Row>
         </Row>
         {/* Tabbar:固定在底部,仅在手机屏幕显示 */}
         {/* Tabbar:固定在底部,仅在手机屏幕显示 */}
         <div className="sticky bottom-0 w-full bg-red xl:hidden">
         <div className="sticky bottom-0 w-full bg-red xl:hidden">
-          <TabBar className="xl:hidden lg:hidden md:hidden sm:block xs:block">
+          <TabBar
+            className="xl:hidden lg:hidden md:hidden sm:block xs:block"
+            onChange={(key) => handleMenuClick(key)}
+          >
             <TabBar.Item
             <TabBar.Item
               className="text-red-500"
               className="text-red-500"
               title="患者管理"
               title="患者管理"
-              key="home"
+              key="patient_management"
               icon={<div>🏠</div>}
               icon={<div>🏠</div>}
             />
             />
             <TabBar.Item
             <TabBar.Item
               className="text-red-500"
               className="text-red-500"
               title="检查"
               title="检查"
-              key="profile"
+              key="examination"
               icon={<div>👤</div>}
               icon={<div>👤</div>}
             />
             />
             <TabBar.Item
             <TabBar.Item
@@ -170,7 +175,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = () => {
             <TabBar.Item
             <TabBar.Item
               className="text-red-500"
               className="text-red-500"
               title="图像处理"
               title="图像处理"
-              key="image-handling"
+              key="process"
               icon={<div>⚙️</div>}
               icon={<div>⚙️</div>}
             />
             />
             <TabBar.Item
             <TabBar.Item
@@ -184,6 +189,7 @@ const BasicLayout: React.FC<BasicLayoutProps> = () => {
         <NavbarFloat
         <NavbarFloat
           className="fixed hidden sm:hidden xs:hidden md:block lg:hidden xl:hidden"
           className="fixed hidden sm:hidden xs:hidden md:block lg:hidden xl:hidden"
           position="right"
           position="right"
+          onMenuClick={handleMenuClick}
         />
         />
       </Layout>
       </Layout>
     </ConfigProvider>
     </ConfigProvider>

+ 8 - 3
src/layouts/NavbarFloat.tsx

@@ -13,11 +13,13 @@ import type { MenuProps } from 'antd';
 interface NavbarFloatProps {
 interface NavbarFloatProps {
   position?: 'left' | 'right';
   position?: 'left' | 'right';
   className?: string;
   className?: string;
+  onMenuClick?: (key: string) => void; // 新增
 }
 }
 
 
 const NavbarFloat: React.FC<NavbarFloatProps> = ({
 const NavbarFloat: React.FC<NavbarFloatProps> = ({
   position = 'left',
   position = 'left',
   className,
   className,
+  ...props
 }) => {
 }) => {
   const [open, setOpen] = useState(false);
   const [open, setOpen] = useState(false);
   const [btnPos, setBtnPos] = useState({ x: 100, y: 100 });
   const [btnPos, setBtnPos] = useState({ x: 100, y: 100 });
@@ -63,9 +65,10 @@ const NavbarFloat: React.FC<NavbarFloatProps> = ({
     document.removeEventListener('mouseup', onMouseUp);
     document.removeEventListener('mouseup', onMouseUp);
   };
   };
 
 
+  // 菜单项key与BasicLayout的contentMap保持一致
   const menuItems = [
   const menuItems = [
     {
     {
-      key: 'patient',
+      key: 'patient_management',
       icon: <Button shape="circle" icon={<UserOutlined />} />,
       icon: <Button shape="circle" icon={<UserOutlined />} />,
       label: '患者',
       label: '患者',
     },
     },
@@ -92,7 +95,9 @@ const NavbarFloat: React.FC<NavbarFloatProps> = ({
   ];
   ];
 
 
   const handleClick: MenuProps['onClick'] = (e) => {
   const handleClick: MenuProps['onClick'] = (e) => {
-    console.log('clicked ', e.key);
+    if (props.onMenuClick) {
+      props.onMenuClick(e.key as string);
+    }
     setOpen(false); // 点击菜单后自动关闭抽屉
     setOpen(false); // 点击菜单后自动关闭抽屉
   };
   };
 
 
@@ -141,7 +146,7 @@ const NavbarFloat: React.FC<NavbarFloatProps> = ({
         open={open}
         open={open}
         onClose={() => setOpen(false)}
         onClose={() => setOpen(false)}
         closable={false}
         closable={false}
-        width={120}
+        width={320}
         maskClosable={true}
         maskClosable={true}
         style={{
         style={{
           top: 0,
           top: 0,

+ 100 - 0
src/pages/patient/PatientManagement.tsx

@@ -0,0 +1,100 @@
+import React, { Suspense, lazy } from 'react';
+import { Tabs } from 'antd';
+import { FormattedMessage } from 'react-intl';
+
+// 懒加载各子页面
+const WorklistPage = lazy(() => import('./worklist'));
+const OutputListPage = lazy(() => import('./OutputList'));
+const HistoryListPage = lazy(() => import('./HistoryList'));
+const ArchiveListPage = lazy(() => import('./ArchiveList'));
+const BinPage = lazy(() => import('./Bin'));
+const RegisterPage = lazy(() => import('./register'));
+
+const { TabPane } = Tabs;
+
+const PatientManagement: React.FC = () => {
+  return (
+    <div className="h-full flex flex-col">
+      <Tabs
+        defaultActiveKey="worklist"
+        type="line"
+        className="flex-1 h-full"
+        tabBarGutter={32}
+        destroyInactiveTabPane
+      >
+        <TabPane
+          tab={
+            <FormattedMessage
+              id="patient.tab.worklist"
+              defaultMessage="Worklist"
+            />
+          }
+          key="worklist"
+        >
+          <Suspense fallback={null}>
+            <WorklistPage />
+          </Suspense>
+        </TabPane>
+        <TabPane
+          tab={
+            <FormattedMessage id="patient.tab.output" defaultMessage="Output" />
+          }
+          key="output"
+        >
+          <Suspense fallback={null}>
+            <OutputListPage />
+          </Suspense>
+        </TabPane>
+        <TabPane
+          tab={
+            <FormattedMessage
+              id="patient.tab.history"
+              defaultMessage="History"
+            />
+          }
+          key="history"
+        >
+          <Suspense fallback={null}>
+            <HistoryListPage />
+          </Suspense>
+        </TabPane>
+        <TabPane
+          tab={
+            <FormattedMessage
+              id="patient.tab.archive"
+              defaultMessage="Archive"
+            />
+          }
+          key="archive"
+        >
+          <Suspense fallback={null}>
+            <ArchiveListPage />
+          </Suspense>
+        </TabPane>
+        <TabPane
+          tab={<FormattedMessage id="patient.tab.bin" defaultMessage="Bin" />}
+          key="bin"
+        >
+          <Suspense fallback={null}>
+            <BinPage />
+          </Suspense>
+        </TabPane>
+        <TabPane
+          tab={
+            <FormattedMessage
+              id="patient.tab.register"
+              defaultMessage="Register"
+            />
+          }
+          key="register"
+        >
+          <Suspense fallback={null}>
+            <RegisterPage />
+          </Suspense>
+        </TabPane>
+      </Tabs>
+    </div>
+  );
+};
+
+export default PatientManagement;