Bladeren bron

feat: add delete confirmation dialog in ActionPanel

- Add Modal.confirm for delete confirmation in worklist and history pages
- Add warning message when no items selected
- Support both workSelection and historySelection states
- File: src/pages/patient/components/ActionPanel.tsx
sw 6 dagen geleden
bovenliggende
commit
67e2a3a8d1
1 gewijzigde bestanden met toevoegingen van 25 en 3 verwijderingen
  1. 25 3
      src/pages/patient/components/ActionPanel.tsx

+ 25 - 3
src/pages/patient/components/ActionPanel.tsx

@@ -1,5 +1,5 @@
 import React from 'react';
-import { Button, Tooltip } from 'antd';
+import { Button, Tooltip, Modal, message } from 'antd';
 import { useDispatch, useSelector } from 'react-redux';
 import { deleteWorkThunk } from '@/states/patient/worklist/slices/workSlice';
 import { switchToSendPanel } from '@/states/patient/worklist/slices/historyPanelSwitchSlice';
@@ -28,15 +28,37 @@ const ActionButton: React.FC<ActionButtonProps> = ({
 
 const ActionPanel: React.FC = () => {
   const dispatch = useDispatch<AppDispatch>();
-  const selectedIds = useSelector(
+  const workSelectedIds = useSelector(
     (state: RootState) => state.workSelection.selectedIds
   );
+  const historySelectedIds = useSelector(
+    (state: RootState) => state.historySelection.selectedIds
+  );
   const visible = useSelector(
     (state: RootState) => state.diagnosticReport.visible
   );
 
+  // 使用 worklist 或 history 的选中项,取决于哪个有值
+  const selectedIds =
+    workSelectedIds.length > 0 ? workSelectedIds : historySelectedIds;
+
   const handleDelete = () => {
-    dispatch(deleteWorkThunk(selectedIds)); // Use the selected IDs from the Redux state
+    if (selectedIds.length === 0) {
+      message.warning('请先选择要删除的项目');
+      return;
+    }
+
+    Modal.confirm({
+      title: '确认删除',
+      content: `确定要删除选中的 ${selectedIds.length} 个项目吗?此操作不可撤销。`,
+      okText: '确认删除',
+      cancelText: '取消',
+      okButtonProps: { danger: true },
+      centered: true,
+      onOk: () => {
+        dispatch(deleteWorkThunk(selectedIds));
+      },
+    });
   };
 
   const handleSend = () => {