|
@@ -5,6 +5,7 @@ import {
|
|
|
deleteWorkThunk,
|
|
|
lockWorkInWorklistThunk,
|
|
|
} from '@/states/patient/worklist/slices/workSlice';
|
|
|
+import { deleteWorkThunk as deleteWorkThunkFromHistory } from '@/states/patient/worklist/slices/history';
|
|
|
import { switchToSendPanel } from '@/states/patient/worklist/slices/historyPanelSwitchSlice';
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
import { AppDispatch, RootState, useAppSelector } from '@/states/store';
|
|
@@ -53,15 +54,41 @@ const ActionPanel: React.FC = () => {
|
|
|
const workEntitiesFromHistory = useSelector(
|
|
|
(state: RootState) => state.historyEntities.data
|
|
|
);
|
|
|
+
|
|
|
+ const getSelectedWorkIds = () => {
|
|
|
+ const selectedIds =
|
|
|
+ currentKey === 'worklist' ? workSelectedIds : historySelectedIds;
|
|
|
+ return selectedIds;
|
|
|
+ };
|
|
|
+ const getDeleteThunk = (): typeof deleteWorkThunk => {
|
|
|
+ return currentKey === 'worklist'
|
|
|
+ ? deleteWorkThunk
|
|
|
+ : deleteWorkThunkFromHistory;
|
|
|
+ };
|
|
|
+ const getSelectedWorks = () => {
|
|
|
+ const selectedIds = getSelectedWorkIds();
|
|
|
+ if (currentKey === 'worklist') {
|
|
|
+ return workEntities.find((w) => selectedIds.includes(w.StudyID));
|
|
|
+ } else if (currentKey === 'historylist') {
|
|
|
+ return workEntitiesFromHistory.find((w) =>
|
|
|
+ selectedIds.includes(w.StudyID)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ };
|
|
|
// 使用 worklist 或 history 的选中项,取决于哪个有值
|
|
|
- const selectedIds =
|
|
|
- workSelectedIds.length > 0 ? workSelectedIds : historySelectedIds;
|
|
|
+ const selectedIds = getSelectedWorkIds();
|
|
|
|
|
|
const handleDelete = () => {
|
|
|
if (selectedIds.length === 0) {
|
|
|
message.warning('请先选择要删除的项目');
|
|
|
return;
|
|
|
}
|
|
|
+ //判断是否锁定
|
|
|
+ const selectedWork = getSelectedWorks();
|
|
|
+ if (selectedWork?.StudyLock === 'Locked') {
|
|
|
+ message.warning('锁定状态不可删除');
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
Modal.confirm({
|
|
|
title: '确认删除',
|
|
@@ -71,7 +98,8 @@ const ActionPanel: React.FC = () => {
|
|
|
okButtonProps: { danger: true },
|
|
|
centered: true,
|
|
|
onOk: () => {
|
|
|
- dispatch(deleteWorkThunk(selectedIds));
|
|
|
+ const delThunk = getDeleteThunk();
|
|
|
+ dispatch(delThunk(selectedIds));
|
|
|
},
|
|
|
});
|
|
|
};
|
|
@@ -83,11 +111,6 @@ const ActionPanel: React.FC = () => {
|
|
|
const handleShowReport = () => {
|
|
|
dispatch(setVisible(true));
|
|
|
};
|
|
|
- const getSelectedWorkIds = () => {
|
|
|
- const selectedIds =
|
|
|
- currentKey === 'worklist' ? workSelectedIds : historySelectedIds;
|
|
|
- return selectedIds;
|
|
|
- };
|
|
|
|
|
|
const getWorksFromWorklistOrHistory = () => {
|
|
|
return currentKey === 'worklist' ? workEntities : workEntitiesFromHistory;
|