Bläddra i källkod

fix (1.30.1 -> 1.30.2): 解决从任务清单进入打印的问题

- 重构 historyToPrint 函数为 selectedWorksToPrint,添加 source 参数动态选择数据源
- 修复从任务清单页面点击打印时,代码错误地从 historyEntities 而非 workEntities 查找数据的问题
- 在 BasicLayout.tsx 中传递当前页面类型参数,确保数据源选择正确
- 添加详细的调试日志,便于问题排查和功能验证
- 重命名文件从 historyToPrint.ts 到 selectedWorksToPrint.ts,提升代码语义性

改动文件:
- src/domain/patient/selectedWorksToPrint.ts (新增,重构自 historyToPrint.ts)
- src/layouts/BasicLayout.tsx (修改,更新函数调用和导入)
- src/domain/patient/historyToPrint.ts (删除)
- CHANGELOG.md (更新)
- package.json (版本更新: 1.30.1 -> 1.30.2)
dengdx 2 veckor sedan
förälder
incheckning
5e8a9e3f64
4 ändrade filer med 54 tillägg och 13 borttagningar
  1. 32 0
      CHANGELOG.md
  2. 1 1
      package.json
  3. 18 9
      src/domain/patient/selectedWorksToPrint.ts
  4. 3 3
      src/layouts/BasicLayout.tsx

+ 32 - 0
CHANGELOG.md

@@ -2,6 +2,38 @@
 
 本项目的所有重要变更都将记录在此文件中。
 
+## [1.30.2] - 2025-12-26 14:19
+
+### 修复 (Fixed)
+- **修复任务清单打印按钮无响应问题** - 重构打印功能,支持从任务清单和历史清单正确进入打印页面
+  - 重构 `historyToPrint` 函数为 `selectedWorksToPrint`,添加 `source` 参数动态选择数据源
+  - 修复从任务清单页面点击打印时,代码错误地从 `historyEntities` 而非 `workEntities` 查找数据的问题
+  - 在 `BasicLayout.tsx` 中传递当前页面类型参数,确保数据源选择正确
+  - 添加详细的调试日志,便于问题排查和功能验证
+  - 重命名文件从 `historyToPrint.ts` 到 `selectedWorksToPrint.ts`,提升代码语义性
+
+**核心改进:**
+- 数据源选择修复:根据页面类型动态选择正确的实体数据(workEntities 或 historyEntities)
+- 代码重构:函数重命名和参数化,提升代码复用性和可维护性
+- 调试增强:添加关键步骤的日志输出,方便问题定位
+- 用户体验:确保任务清单和历史清单的打印功能都正常工作
+
+**技术实现:**
+- 重构 `selectedWorksToPrint` 函数,添加 `source: 'worklist' | 'historylist'` 参数
+- 动态实体选择:`const entityData = source === 'worklist' ? state.workEntities.data : state.historyEntities.data`
+- 函数调用更新:`selectedWorksToPrint(selectedIds, currentKey as 'worklist' | 'historylist')`
+- 文件重命名:从 `historyToPrint.ts` 重命名为 `selectedWorksToPrint.ts`
+- 调试日志:添加数据源选择、实体数量、匹配任务数量等关键信息输出
+
+**改动文件:**
+- src/domain/patient/selectedWorksToPrint.ts (新增,重构自 historyToPrint.ts)
+- src/layouts/BasicLayout.tsx (修改,更新函数调用和导入)
+- src/domain/patient/historyToPrint.ts (删除)
+- CHANGELOG.md
+- package.json (版本更新: 1.30.1 -> 1.30.2)
+
+---
+
 ## [1.30.1] - 2025-12-26 12:53
 
 ### 修复 (Fixed)

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "zsis",
-  "version": "1.30.1",
+  "version": "1.30.2",
   "private": true,
   "description": "医学成像系统",
   "main": "main.js",

+ 18 - 9
src/domain/patient/historyToPrint.ts → src/domain/patient/selectedWorksToPrint.ts

@@ -8,31 +8,40 @@ import {
 } from '../../states/exam/bodyPositionListSlice';
 
 /**
- * 从历史记录进入打印页面
+ * 从选中的工作清单或历史清单进入打印页面
  * @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;
 
   try {
+    console.log('[selectedWorksToPrint] Called with:', { selectedIds, source });
+
     if (selectedIds.length === 0) {
-      console.warn('[historyToPrint] No studies selected');
+      console.warn('[selectedWorksToPrint] No studies selected');
       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
     await dispatch(clearWorks());
 
     // 获取选中的 Task 对象
     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)
     );
 
+    console.log('[selectedWorksToPrint] Found matching tasks:', selectedTasks.length);
+
     if (selectedTasks.length === 0) {
-      console.warn('[historyToPrint] No matching tasks found');
+      console.warn('[selectedWorksToPrint] No matching tasks found in', source);
       return;
     }
 
@@ -49,15 +58,15 @@ const historyToPrint = async (selectedIds: string[]) => {
     await dispatch(setBodyPositions(bodyPositions));
 
     console.log(
-      '[historyToPrint] Data loaded successfully, navigating to print page'
+      '[selectedWorksToPrint] Data loaded successfully, navigating to print page'
     );
 
     // 切换到打印页面
     await dispatch(setBusinessFlow('print'));
   } catch (error) {
-    console.error('[historyToPrint] Error:', error);
+    console.error('[selectedWorksToPrint] Error:', error);
     throw error;
   }
 };
 
-export default historyToPrint;
+export default selectedWorksToPrint;

+ 3 - 3
src/layouts/BasicLayout.tsx

@@ -25,7 +25,7 @@ import { setBusinessFlow } from '@/states/BusinessFlowSlice';
 import ImageProcessingPage from '@/pages/view/ImageProcessingPage';
 import PrintPage from '@/pages/output/print/PrintPage';
 import { pageLayoutConfig } from '@/config/pageLayout';
-import historyToPrint from '@/domain/patient/historyToPrint';
+import selectedWorksToPrint from '@/domain/patient/selectedWorksToPrint';
 import { message } from 'antd';
 
 // import { Link } from 'react-router-dom';
@@ -91,8 +91,8 @@ const BasicLayout: React.FC<BasicLayoutProps> = () => {
       }
 
       try {
-        // 调用 historyToPrint 加载数据并跳转
-        await historyToPrint(selectedIds);
+        // 调用 selectedWorksToPrint 加载数据并跳转
+        await selectedWorksToPrint(selectedIds, currentKey as 'worklist' | 'historylist');
       } catch (error) {
         console.error('[BusinessZone] Print error:', error);
         message.error('加载打印数据失败,请重试');