feat(文书管理): 增加版本工作流与版本历史

- 模板状态按后端原始状态展示与筛选,待审核与已驳回分开展示
- 仅已发布模板可发起签署,新增提交审核/审核通过/驳回等动作
- 新增版本历史弹窗,复用统一的模板时间格式化方法
- 演示数据补齐已签署任务的签名图,并提供获取签名 dataURL 的接口
- 修复编辑器插入占位符时未定位光标导致内容落到文首的问题
This commit is contained in:
yelan
2026-09-17 16:44:54 +08:00
parent 81922d774f
commit 97c5182ba4
13 changed files with 982 additions and 64 deletions
@@ -195,3 +195,38 @@ export function downloadSigningArtifact(artifactId: string): Promise<Blob> {
responseType: 'blob',
})
}
/** Blob → dataURL */
function blobToDataUrl(blob: Blob): Promise<string> {
return new Promise((resolve, reject) => {
const reader = new FileReader()
reader.onload = () => {
resolve(typeof reader.result === 'string' ? reader.result : '')
}
reader.onerror = () => {
reject(new Error('签名图读取失败'))
}
reader.readAsDataURL(blob)
})
}
/**
* 取回签名图并转成 dataURL,供文书渲染使用。
*
* 签名在后端是独立的 SIGNATURE_IMAGE 产物,任务接口(SignTaskResponseDto)
* **不返回任何签名字段**,所以前端必须自己把它取回来——否则文书里的签名位
* 永远是「待患者签名」,导出的 PDF 也就没有患者签名。
*
* 这里刻意转成 dataURL 而不是直接把下载地址塞给 <img>:文书导出 PDF 走
* html2canvas 截图,跨域的 <img src="http://..."> 会被画布安全策略拦掉
* (`useCORS` 只在服务端返回 CORS 响应头时才生效),表现为
* 「页面上看得到签名、导出的 PDF 里却是空的」。
*/
export async function fetchSignatureDataUrl(artifact: SigningArtifact): Promise<string> {
try {
return await blobToDataUrl(await downloadSigningArtifact(artifact.id))
} catch {
// 取签名图失败不该让整个详情页失败:正文、审计轨迹、产物列表都还能看
return ''
}
}