|
@@ -1,16 +1,15 @@
|
|
|
-import React from 'react';
|
|
|
+import React, { useEffect } from 'react';
|
|
|
import { useSelector, useDispatch } from 'react-redux';
|
|
|
-import {
|
|
|
- setSelectedBodyPosition,
|
|
|
- ExtendedBodyPosition,
|
|
|
-} from '../../../states/exam/bodyPositionListSlice';
|
|
|
-import { setBodyPositionDetail } from '../../../states/exam/bodyPositionDetailSlice';
|
|
|
-import { RootState } from '../../../states/store';
|
|
|
-import { Button, message, Image } from 'antd';
|
|
|
+import { ExtendedBodyPosition } from '../../../states/exam/bodyPositionListSlice';
|
|
|
+import { RootState, AppDispatch } from '../../../states/store';
|
|
|
+import { Button, Image } from 'antd';
|
|
|
import AppendViewIcon from '@/assets/imgs/append-view.svg';
|
|
|
import ImageViewer from './ImageViewer';
|
|
|
import { getExposedImageUrl, getViewIconUrl } from '../../../API/bodyPosition';
|
|
|
-import { changeBodyPosition } from '@/API/exam/changeBodyPosition';
|
|
|
+import {
|
|
|
+ manualSelectBodyPosition,
|
|
|
+ autoSelectFirstBodyPosition,
|
|
|
+} from '@/domain/exam/bodyPositionSelection';
|
|
|
|
|
|
interface BodyPositionListProps {
|
|
|
layout: 'horizontal' | 'vertical';
|
|
@@ -21,43 +20,14 @@ const BodyPositionList: React.FC<BodyPositionListProps> = ({
|
|
|
layout,
|
|
|
showAddButton = true,
|
|
|
}) => {
|
|
|
- const dispatch = useDispatch();
|
|
|
- const handleImageClick = (bodyPosition: ExtendedBodyPosition) => {
|
|
|
- message.info(`Clicked on ${bodyPosition.view_name}`);
|
|
|
- dispatch(setSelectedBodyPosition(bodyPosition));
|
|
|
- dispatch(
|
|
|
- setBodyPositionDetail({
|
|
|
- view_name: bodyPosition.view_name,
|
|
|
- view_description: bodyPosition.view_description,
|
|
|
- view_icon_name: bodyPosition.view_icon_name,
|
|
|
- patient_name: bodyPosition.patient_name,
|
|
|
- patient_id: bodyPosition.patient_id,
|
|
|
- registration_number: bodyPosition.registration_number,
|
|
|
- study_description: bodyPosition.study_description,
|
|
|
- body_position_image: bodyPosition.view_big_icon_name,
|
|
|
- collimator_length: bodyPosition.collimator_length,
|
|
|
- collimator_width: bodyPosition.collimator_width,
|
|
|
- sid: bodyPosition.sid,
|
|
|
- })
|
|
|
- );
|
|
|
- if (currentKey === 'exam') {
|
|
|
- changeBodyPosition(bodyPosition.sop_instance_uid)
|
|
|
- .then(() => {
|
|
|
- message.success(
|
|
|
- `'Body position changed successfully' ${bodyPosition.sop_instance_uid}`
|
|
|
- );
|
|
|
- })
|
|
|
- .catch((error) => {
|
|
|
- console.error('Error changing body position:', error);
|
|
|
- message.error('Failed to change body position');
|
|
|
- });
|
|
|
- } else {
|
|
|
- // message.info(`Current key is ${currentKey}, not executing changeBodyPosition.`);
|
|
|
- }
|
|
|
- };
|
|
|
+ const dispatch = useDispatch<AppDispatch>();
|
|
|
const currentKey = useSelector(
|
|
|
(state: RootState) => state.BusinessFlow.currentKey
|
|
|
);
|
|
|
+
|
|
|
+ const handleImageClick = async (bodyPosition: ExtendedBodyPosition) => {
|
|
|
+ await manualSelectBodyPosition(bodyPosition, dispatch, currentKey);
|
|
|
+ };
|
|
|
const bodyPositions = useSelector(
|
|
|
(state: RootState) => state.bodyPositionList.bodyPositions
|
|
|
);
|
|
@@ -65,6 +35,16 @@ const BodyPositionList: React.FC<BodyPositionListProps> = ({
|
|
|
(state: RootState) => state.bodyPositionList.selectedBodyPosition
|
|
|
);
|
|
|
|
|
|
+ // 在组件装载完成后,自动选中第一个体位
|
|
|
+ useEffect(() => {
|
|
|
+ if (bodyPositions.length > 0 && !selectedBodyPosition) {
|
|
|
+ console.log(
|
|
|
+ '[BodyPositionList] Auto-selecting first body position on component mount'
|
|
|
+ );
|
|
|
+ autoSelectFirstBodyPosition(bodyPositions, dispatch, currentKey);
|
|
|
+ }
|
|
|
+ }, [bodyPositions, selectedBodyPosition, dispatch, currentKey]);
|
|
|
+
|
|
|
const addBodyPositionClick = () => {
|
|
|
// dispatch(addBodyPosition({
|
|
|
// view_name: 'New View',
|