Kaynağa Gözat

选中项删除之后,清空缩略图列表;切换worklist或者history后,自动更新缩略图列表

sw 5 gün önce
ebeveyn
işleme
ba165af0b3
1 değiştirilmiş dosya ile 26 ekleme ve 4 silme
  1. 26 4
      src/pages/patient/components/ThumbnailList.tsx

+ 26 - 4
src/pages/patient/components/ThumbnailList.tsx

@@ -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}`}>