import React, { useState, useMemo } from 'react'; import { Select, Button, Space, message } from 'antd'; import { showNotImplemented } from '@/utils/notificationHelper'; import { useAppSelector } from '@/states/store'; import { getPrintManager } from '@/services/print'; const PrintControl: React.FC = () => { const [selectedNode, setSelectedNode] = useState(''); const [selectedSize, setSelectedSize] = useState('14IN×17IN'); const [isPrinting, setIsPrinting] = useState(false); // 获取当前胶片信息 const activeFilm = useAppSelector((state) => { const films = state.print.films; const activeId = state.print.activeFilmId; return films.find(f => f.id === activeId); }); // 创建打印管理器实例 const printManager = useMemo(() => getPrintManager(), []); // TODO: 打印节点需要从后端API获取 const printNodes = [ { value: 'node1', label: 'TestPrinter' }, // { value: 'node2', label: '打印节点2' }, ]; const filmSizes = [ { value: '14IN×17IN', label: '14IN×17IN' }, { value: '14IN×14IN', label: '14IN×14IN' }, { value: '17IN×17IN', label: '17IN×17IN' }, ]; const handleLocalPrint = async () => { if (isPrinting) { message.warning('打印正在进行中,请稍候'); return; } try { setIsPrinting(true); console.log('[本地打印] 开始打印,胶片尺寸:', selectedSize); await printManager.print({ elementId: 'film-print-area', filmSize: selectedSize, orientation: activeFilm?.orientation === 'horizontal' ? 'landscape' : 'portrait', }); message.success('打印完成'); } catch (error) { console.error('[本地打印] 打印失败:', error); message.error(`打印失败: ${error.message || '未知错误'}`); } finally { setIsPrinting(false); } }; const handleDicomPrint = () => { showNotImplemented('DICOM打印'); }; return (
打印设置
{/* 打印节点下拉框 */}
打印节点
{/* 打印按钮 */}
); }; export default PrintControl;