|
@@ -8,31 +8,40 @@ import {
|
|
|
} from '../../states/exam/bodyPositionListSlice';
|
|
} from '../../states/exam/bodyPositionListSlice';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 从历史记录进入打印页面
|
|
|
|
|
|
|
+ * 从选中的工作清单或历史清单进入打印页面
|
|
|
* @param selectedIds - 选中的 StudyID 数组
|
|
* @param selectedIds - 选中的 StudyID 数组
|
|
|
|
|
+ * @param source - 数据源类型 ('worklist' | 'historylist')
|
|
|
*/
|
|
*/
|
|
|
-const historyToPrint = async (selectedIds: string[]) => {
|
|
|
|
|
|
|
+const selectedWorksToPrint = async (selectedIds: string[], source: 'worklist' | 'historylist' = 'historylist') => {
|
|
|
const dispatch = store.dispatch;
|
|
const dispatch = store.dispatch;
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
+ console.log('[selectedWorksToPrint] Called with:', { selectedIds, source });
|
|
|
|
|
+
|
|
|
if (selectedIds.length === 0) {
|
|
if (selectedIds.length === 0) {
|
|
|
- console.warn('[historyToPrint] No studies selected');
|
|
|
|
|
|
|
+ console.warn('[selectedWorksToPrint] No studies selected');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- console.log('[historyToPrint] Loading data for print page:', selectedIds);
|
|
|
|
|
|
|
+ console.log('[selectedWorksToPrint] Loading data for print page:', selectedIds);
|
|
|
|
|
|
|
|
// Clear existing works in the cache
|
|
// Clear existing works in the cache
|
|
|
await dispatch(clearWorks());
|
|
await dispatch(clearWorks());
|
|
|
|
|
|
|
|
// 获取选中的 Task 对象
|
|
// 获取选中的 Task 对象
|
|
|
const state = store.getState();
|
|
const state = store.getState();
|
|
|
- const selectedTasks = state.historyEntities.data.filter((task) =>
|
|
|
|
|
|
|
+ // 根据数据源类型选择正确的实体数据
|
|
|
|
|
+ const entityData = source === 'worklist' ? state.workEntities.data : state.historyEntities.data;
|
|
|
|
|
+ console.log('[selectedWorksToPrint] Using entity data from:', source, 'entity count:', entityData.length);
|
|
|
|
|
+
|
|
|
|
|
+ const selectedTasks = entityData.filter((task) =>
|
|
|
selectedIds.includes(task.StudyID)
|
|
selectedIds.includes(task.StudyID)
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
|
|
+ console.log('[selectedWorksToPrint] Found matching tasks:', selectedTasks.length);
|
|
|
|
|
+
|
|
|
if (selectedTasks.length === 0) {
|
|
if (selectedTasks.length === 0) {
|
|
|
- console.warn('[historyToPrint] No matching tasks found');
|
|
|
|
|
|
|
+ console.warn('[selectedWorksToPrint] No matching tasks found in', source);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -49,15 +58,15 @@ const historyToPrint = async (selectedIds: string[]) => {
|
|
|
await dispatch(setBodyPositions(bodyPositions));
|
|
await dispatch(setBodyPositions(bodyPositions));
|
|
|
|
|
|
|
|
console.log(
|
|
console.log(
|
|
|
- '[historyToPrint] Data loaded successfully, navigating to print page'
|
|
|
|
|
|
|
+ '[selectedWorksToPrint] Data loaded successfully, navigating to print page'
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
// 切换到打印页面
|
|
// 切换到打印页面
|
|
|
await dispatch(setBusinessFlow('print'));
|
|
await dispatch(setBusinessFlow('print'));
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
- console.error('[historyToPrint] Error:', error);
|
|
|
|
|
|
|
+ console.error('[selectedWorksToPrint] Error:', error);
|
|
|
throw error;
|
|
throw error;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-export default historyToPrint;
|
|
|
|
|
|
|
+export default selectedWorksToPrint;
|