- Add React/Vite frontend for login, dashboard, reports, templates, users, settings, AI, speech, and media workflows. - Add NestJS/Prisma/PostgreSQL backend with auth, dashboard stats, reports, templates, users, departments, settings, files, AI, speech, audit logs, and HTML sanitization. - Add Prisma schema, migrations, seed data, persistent app sessions, Docker/Nginx deployment files, and upload volume configuration. - Add Vitest, Playwright, backend integration tests, and project documentation for requirements, design, permissions, API contracts, testing, deployment, security, and progress. - Configure production local fallback switch and remove unused Gemini direct dependency/env wiring.
54 lines
2.5 KiB
Markdown
54 lines
2.5 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:调用浏览器打印。
|
||
- 导出 JSON:下载结构化字段数据。
|
||
- 批量导出和批量删除:基于表格选中项操作。
|
||
|
||
医生只能编辑或删除自己的报告。
|
||
|
||
## 历史恢复
|
||
|
||
历史版本恢复时,管理页把目标 HTML 写入 `sessionStorage.restore_${reportId}`,再跳转到编辑器。编辑器读取后填入正文并移除 session 键。
|
||
|
||
## 报告查看
|
||
|
||
`ReportView` 优先通过 `GET /api/reports/:id` 获取报告,后端检查查看权限。只有本地回退开启时,失败才会回退本地报告和前端权限判断。报告正文通过 `dangerouslySetInnerHTML` 渲染,保存侧已由后端做第一版 HTML 白名单清洗,页面提供浏览器打印入口。
|
||
|
||
## 后端报告模型
|
||
|
||
后端 `Report` 表保存标题、患者姓名、住院号、HTML 正文、作者、部门、状态和修订版本。`Report.metadata` 暂存患者扩展字段;视频和关键帧文件内容写入 `FileResource`,报告中的媒体引用、排序和抽帧信息写入 `ReportMedia` 关系表。Reports API 返回时仍组装成前端兼容的 `videos` 和 `capturedFrames` 字段。
|
||
|
||
## 导出 JSON 内容
|
||
|
||
当前报告 JSON 导出主要包含:
|
||
|
||
- `meta`:报告 ID、标题、创建/更新时间、作者和状态。
|
||
- `fields`:按 `DEFAULT_FORM_FIELDS` 提取的报告字段。
|
||
|
||
报告正文 HTML 和视频帧数据不在这个结构化字段导出范围内。
|