- Remove user-visible JSON export options from report editor, report management, template management, bulk template export, and AI debug logs. - Keep HTML template package and PDF/browser print exports as the supported frontend export formats. - Change per-template export to generate reusable HTML template packages. - Preserve legacy JSON template import compatibility without exposing new JSON export buttons. - Update README, AGENTS, feature, requirement, design, module, API contract, progress, and testing docs for the export policy change.
48 lines
2.4 KiB
Markdown
48 lines
2.4 KiB
Markdown
# 模块文档:报告管理与查看
|
||
|
||
## 涉及文件
|
||
|
||
- `src/pages/ReportManage.tsx`
|
||
- `src/pages/ReportView.tsx`
|
||
- `src/api/reports.ts`
|
||
- `server/src/reports/*`
|
||
- `src/utils/print.ts`
|
||
- `src/types.ts`
|
||
|
||
## 报告管理
|
||
|
||
`ReportManage` 优先通过 `src/api/reports.ts` 调用 `GET /api/reports` 读取报告列表,后端根据当前 Session 用户做权限过滤:
|
||
|
||
- 医生只显示本人创建的报告。
|
||
- 管理员只显示本部门报告。
|
||
- 超级管理员显示全部报告。
|
||
|
||
前端仍支持按标题、患者姓名、住院号搜索,按状态和时间筛选。只有开发模式或显式开启 `VITE_ENABLE_LOCAL_FALLBACK=true` 时,API 不可用才会回退读取 `localStorage.reports`,用于迁移期旧数据和离线测试。
|
||
|
||
## 操作能力
|
||
|
||
- 查看:进入 `/report-view/:id`。
|
||
- 编辑:进入 `/report-editor?id=...`。
|
||
- 删除:优先调用 `DELETE /api/reports/:id` 做后端软删除,再同步本地兼容缓存;只有本地回退开启时,API 不可用才会从本地 `reports` 中移除。
|
||
- 历史版本:查看 `Report.history`,可恢复某个历史内容到编辑器。
|
||
- 导出 PDF:调用浏览器打印。
|
||
- 批量导出 PDF 和批量删除:基于表格选中项操作。
|
||
|
||
医生只能编辑或删除自己的报告。
|
||
|
||
## 历史恢复
|
||
|
||
历史版本恢复时,管理页把目标 HTML 写入 `sessionStorage.restore_${reportId}`,再跳转到编辑器。编辑器读取后填入正文并移除 session 键。
|
||
|
||
## 报告查看
|
||
|
||
`ReportView` 优先通过 `GET /api/reports/:id` 获取报告,后端检查查看权限。只有本地回退开启时,失败才会回退本地报告和前端权限判断。报告正文通过 `dangerouslySetInnerHTML` 渲染,保存侧已由后端做第一版 HTML 白名单清洗,页面提供浏览器打印入口。
|
||
|
||
## 后端报告模型
|
||
|
||
后端 `Report` 表保存标题、患者姓名、住院号、HTML 正文、作者、部门、状态和修订版本。`Report.metadata` 暂存患者扩展字段;视频和关键帧文件内容写入 `FileResource`,报告中的媒体引用、排序和抽帧信息写入 `ReportMedia` 关系表。Reports API 返回时仍组装成前端兼容的 `videos` 和 `capturedFrames` 字段。
|
||
|
||
## JSON 导出
|
||
|
||
前端用户可见的报告 JSON 导出入口已移除。当前报告导出只保留浏览器打印/PDF 路径,结构化数据交换后续如需要应走后端 API 或数据库层能力。
|