|
@@ -9,7 +9,8 @@ import {
|
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
import { v4 as uuidv4 } from 'uuid';
|
|
|
import { getDcmImageUrl } from '@/API/bodyPosition';
|
|
import { getDcmImageUrl } from '@/API/bodyPosition';
|
|
|
import { useDispatch } from 'react-redux';
|
|
import { useDispatch } from 'react-redux';
|
|
|
-import { addImageToCell, Film } from '@/states/print/printSlice';
|
|
|
|
|
|
|
+import { addImageToCell, Film, toggleCellSelection } from '@/states/print/printSlice';
|
|
|
|
|
+import { useAppSelector } from '@/states/store';
|
|
|
// import { dicomWebImageLoader } from '@cornerstonejs/dicom-web-image-loader';
|
|
// import { dicomWebImageLoader } from '@cornerstonejs/dicom-web-image-loader';
|
|
|
|
|
|
|
|
// // 初始化图像加载器(关键:必须提前注册)
|
|
// // 初始化图像加载器(关键:必须提前注册)
|
|
@@ -43,6 +44,14 @@ const ViewportContainer = ({ imageId, className, currentFilm, indexOfCell }: Vie
|
|
|
[currentFilm.id, indexOfCell]
|
|
[currentFilm.id, indexOfCell]
|
|
|
);
|
|
);
|
|
|
const dispatch = useDispatch();
|
|
const dispatch = useDispatch();
|
|
|
|
|
+
|
|
|
|
|
+ // 生成格子的唯一标识符
|
|
|
|
|
+ const cellId = `${currentFilm.id}-${indexOfCell}`;
|
|
|
|
|
+
|
|
|
|
|
+ // 检查当前格子是否被选中
|
|
|
|
|
+ const isSelected = useAppSelector(state =>
|
|
|
|
|
+ state.print.selectedCells.includes(cellId)
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
// 统一的图像加载函数,供两种场景使用
|
|
// 统一的图像加载函数,供两种场景使用
|
|
|
const loadImage = async (targetImageId: string, source: 'props' | 'drag' = 'props'): Promise<boolean> => {
|
|
const loadImage = async (targetImageId: string, source: 'props' | 'drag' = 'props'): Promise<boolean> => {
|
|
@@ -231,22 +240,35 @@ const ViewportContainer = ({ imageId, className, currentFilm, indexOfCell }: Vie
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ // 处理格子点击事件
|
|
|
|
|
+ const handleCellClick = (e: React.MouseEvent) => {
|
|
|
|
|
+ e.stopPropagation();
|
|
|
|
|
+ dispatch(toggleCellSelection(cellId));
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // 动态样式
|
|
|
|
|
+ const containerStyle = {
|
|
|
|
|
+ width: '100%',
|
|
|
|
|
+ height: '600px',
|
|
|
|
|
+ border: isSelected ? '3px solid #0066cc' : '2px dashed #666',
|
|
|
|
|
+ borderRadius: '8px',
|
|
|
|
|
+ position: 'relative' as const,
|
|
|
|
|
+ cursor: 'pointer',
|
|
|
|
|
+ backgroundColor: isSelected ? 'rgba(0, 102, 204, 0.1)' : 'transparent',
|
|
|
|
|
+ boxShadow: isSelected ? '0 0 10px rgba(0, 102, 204, 0.3)' : 'none',
|
|
|
|
|
+ transition: 'all 0.2s ease-in-out'
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div
|
|
<div
|
|
|
className="viewport-container"
|
|
className="viewport-container"
|
|
|
|
|
+ onClick={handleCellClick}
|
|
|
onDragOver={(e) => {
|
|
onDragOver={(e) => {
|
|
|
e.preventDefault(); // 允许放置
|
|
e.preventDefault(); // 允许放置
|
|
|
e.dataTransfer.dropEffect = 'copy';
|
|
e.dataTransfer.dropEffect = 'copy';
|
|
|
}}
|
|
}}
|
|
|
onDrop={handleDrop}
|
|
onDrop={handleDrop}
|
|
|
- style={{
|
|
|
|
|
- width: '100%',
|
|
|
|
|
- height: '600px',
|
|
|
|
|
- border: '2px dashed #666',
|
|
|
|
|
- borderRadius: '8px',
|
|
|
|
|
- position: 'relative'
|
|
|
|
|
- }}
|
|
|
|
|
|
|
+ style={containerStyle}
|
|
|
>
|
|
>
|
|
|
{/* Cornerstone 渲染挂载点 */}
|
|
{/* Cornerstone 渲染挂载点 */}
|
|
|
<div ref={viewportRef} style={{ width: '100%', height: '100%' }} />
|
|
<div ref={viewportRef} style={{ width: '100%', height: '100%' }} />
|