47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import { readDocumentLibrary, writeDocumentLibrary } from '@/utils/mock-document-library'
|
||
import type { SigningDocumentData } from '@/utils/signing-document'
|
||
|
||
import type { DocumentDepartment, DocumentStatus } from './types'
|
||
|
||
const documentStatusLabels: Record<DocumentStatus, string> = {
|
||
enabled: '启用中',
|
||
draft: '草稿',
|
||
archived: '归档',
|
||
review: '需复审',
|
||
}
|
||
|
||
export const documentStatusOptions = Object.entries(documentStatusLabels).map(([key, label]) => ({
|
||
key: key as DocumentStatus,
|
||
label,
|
||
}))
|
||
|
||
export { documentStatusLabels }
|
||
|
||
// 演示文书库的种子与读取逻辑都在 utils/mock-document-library:
|
||
// 文档库页面和签署工作台必须读同一份数据,否则会出现「文档库里维护的模板,签署端选不到」,
|
||
// 或者签署端混着一批文档库里看不到、也无法维护的模板。
|
||
/** 读取演示文书库:优先用本地保存的,没有则用种子(调用方负责再克隆一份使用) */
|
||
export function loadDocumentLibrary(): DocumentDepartment[] {
|
||
return readDocumentLibrary()
|
||
}
|
||
|
||
/** 保存演示文书库,刷新后仍可继续编辑、预览与发起签署 */
|
||
export function saveDocumentLibrary(library: DocumentDepartment[]): void {
|
||
writeDocumentLibrary(library)
|
||
}
|
||
|
||
/**
|
||
* 签署预览使用的示例患者快照(脱敏演示数据)。
|
||
* 创建文书时还没有真实签署任务,用固定示例值让科室看到占位符被填充后的版式;
|
||
* 真实签署仍以任务创建时的患者/就诊快照为准。
|
||
*/
|
||
export const signingPreviewPatient: SigningDocumentData = {
|
||
patientName: '李某某',
|
||
sex: '男',
|
||
age: 46,
|
||
visitNo: 'V20260914001',
|
||
visitDate: '2026-09-14',
|
||
phone: '138****5678',
|
||
signedAt: '',
|
||
}
|