|
@@ -1,9 +1,10 @@
|
|
|
-import React from 'react';
|
|
|
+import React, { useEffect } from 'react';
|
|
|
import { Row, Col, Image, Card, Typography, Tag, Empty } from 'antd';
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
-import { useSelector } from 'react-redux';
|
|
|
-import { RootState } from '@/states/store';
|
|
|
+import { useDispatch, useSelector } from 'react-redux';
|
|
|
+import store, { AppDispatch, RootState } from '@/states/store';
|
|
|
import { dview } from '@/domain/dview';
|
|
|
+import { clearThumbnails, updateThumbnailsFromHistorySelection } from '@/states/patient/worklist/slices/thumbnailListSlice';
|
|
|
|
|
|
const { Text, Title } = Typography;
|
|
|
|
|
@@ -12,14 +13,35 @@ interface ThumbnailListProps {
|
|
|
}
|
|
|
|
|
|
const ThumbnailList: React.FC<ThumbnailListProps> = ({ className }) => {
|
|
|
+ const dispatch = useDispatch<AppDispatch>();
|
|
|
const thumbnails = useSelector(
|
|
|
(state: RootState) => state.thumbnailList.thumbnails
|
|
|
);
|
|
|
+ const currentKey = useSelector(
|
|
|
+ (state: RootState) => state.BusinessFlow.currentKey
|
|
|
+ );
|
|
|
const loading = useSelector(
|
|
|
(state: RootState) => state.thumbnailList.loading
|
|
|
);
|
|
|
const error = useSelector((state: RootState) => state.thumbnailList.error);
|
|
|
-
|
|
|
+ const workSelectedIds = useSelector((state: RootState) => state.workSelection.selectedIds);
|
|
|
+ const workHistorySelectedIds = useSelector((state: RootState) => state.historySelection.selectedIds);
|
|
|
+ useEffect(() => {
|
|
|
+ // 组件挂载时清空
|
|
|
+ // 基于currentKey,查找history或者worklist中的选中项,
|
|
|
+ if (currentKey === 'worklist') {
|
|
|
+ const selectedId = store.getState().workSelection.selectedIds;
|
|
|
+ if (selectedId.length > 0) { dispatch(updateThumbnailsFromHistorySelection(selectedId)); }
|
|
|
+ }
|
|
|
+ if (currentKey === 'historylist') {
|
|
|
+ const selectedId = store.getState().historySelection.selectedIds;
|
|
|
+ if (selectedId.length > 0) { dispatch(updateThumbnailsFromHistorySelection(selectedId)); }
|
|
|
+ }
|
|
|
+ // 组件卸载时清空
|
|
|
+ return () => {
|
|
|
+ dispatch(clearThumbnails());
|
|
|
+ };
|
|
|
+ }, [dispatch,workHistorySelectedIds,workSelectedIds]);
|
|
|
if (error) {
|
|
|
return (
|
|
|
<div className={`p-4 ${className}`}>
|