// BasicLayout.tsx import React from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { Layout, Row, Col, ConfigProvider } from 'antd'; import { TabBar } from 'antd-mobile'; import logo from '@/assets/imgs/logo-v3.jpg'; import NavbarFloat from './NavbarFloat'; import NavMenu from './NavMenu'; import BottomBar from './BottomBar'; import StatusBar, { StatusBarProps } from './StateBar'; import RegisterPage from '@/pages/patient/register'; import WorklistPage from '@/pages/patient/worklist'; import HistorylistPage from '@/pages/patient/HistoryList'; import ArchivelistPage from '@/pages/patient/ArchiveList'; import BinPage from '@/pages/patient/Bin'; import OutputlistPage from '@/pages/patient/OutputList'; import PatientManagement from '@/pages/patient/PatientManagement'; import MeButton from '@/pages/security/components/MeButton'; import Profile from '@/pages/security/Profile'; import ExamPage from '@/pages/exam/ExamPage'; import { RootState } from '@/states/store'; import store from '@/states/store'; import { setBusinessFlow } from '@/states/BusinessFlowSlice'; import ImageProcessingPage from '@/pages/view/ImageProcessingPage'; import PrintPage from '@/pages/output/print/PrintPage'; import { pageLayoutConfig } from '@/config/pageLayout'; import selectedWorksToPrint from '@/domain/patient/selectedWorksToPrint'; import { message } from 'antd'; // import { Link } from 'react-router-dom'; // import { MenuOutlined } from '@ant-design/icons'; // const { Content, Footer } = Layout; interface BasicLayoutProps { children: React.ReactNode; } // //自定义breakpoint // const breakpoint = { // xs: 480, // 小屏幕设备(手机) // sm: 576, // 中小屏幕设备(平板) // md: 768, // 中等屏幕设备(小桌面显示器) // lg: 992, // 大屏幕设备(桌面显示器) // xl: 1200, // 超大屏幕设备(大桌面显示器) // xxl: 1600 // 超超大屏幕设备(超大桌面显示器) // }; const BasicLayout: React.FC = () => { const status: StatusBarProps = { diskStatus: 'available', // 可用状态 batteryLevel: 0, wifiStrength: 0, heatCapacity: 0, }; const dispatch = useDispatch(); const currentKey = useSelector( (state: RootState) => state.BusinessFlow.currentKey ); // key和内容组件的映射 const contentMap = { exam: , process: , view: , register: , worklist: , historylist: , archivelist: , bin: , outputlist: , patient_management: , profile: , // 需确保已引入 Profile 组件 print: , }; //感知菜单项点击 const handleMenuClick = async (key: string) => { // 特殊处理打印按钮 // todo 这一段逻辑后续可以考虑放到 middleware 里处理,即 businessFlowMiddlewareLogic if (key === 'print') { if (currentKey === 'worklist' || currentKey === 'historylist') { // 获取当前选中的记录 const state = store.getState(); const selectedIds = currentKey === 'historylist' ? state.historySelection.selectedIds : currentKey === 'worklist' ? state.workSelection.selectedIds : []; if (selectedIds.length === 0) { message.warning('请先选择要打印的项目'); return; } try { // 调用 selectedWorksToPrint 加载数据并跳转 await selectedWorksToPrint(selectedIds, currentKey as 'worklist' | 'historylist'); } catch (error) { console.error('[BusinessZone] Print error:', error); message.error('加载打印数据失败,请重试'); } } else if(currentKey === 'exam' || currentKey === 'process') { // 其他按钮直接切换页面 dispatch(setBusinessFlow(key)); } } else { // 其他按钮直接切换页面 dispatch(setBusinessFlow(key)); } }; return ( // ConfigProvider 用于自定义 Ant Design 的主题和 breakpoints {/* 第一行:品牌和状态区域 */} {pageLayoutConfig.brandAndStatusPosition === 'top' && ( {/* 品牌区域 */} Logo {/* 状态区域 */} {/* text-[100%] 用于传导父元素的字体大小,最终影响图标大小 */} )} {/* 第二行:导航区域(第1列)和内容区域(第2列) */} {/* 导航区域 */} {/* 内容区域 */} {/* {children} */} {contentMap[currentKey]} {/* 第一行:品牌和状态区域 */} {pageLayoutConfig.brandAndStatusPosition === 'bottom' && ( {/* 品牌区域 */} {/* 底部通栏:仅在桌面端显示 */} {/* 状态区域 */} {/* text-[100%] 用于传导父元素的字体大小,最终影响图标大小 */} )} {/* Tabbar:固定在底部,仅在手机屏幕显示 */}
handleMenuClick(key)} > 🏠
} /> 👤} /> ⚙️} /> ⚙️} /> ⚙️} /> handleMenuClick('profile')} // 不传递username /> } />
); }; export default BasicLayout;