feat(签署文书): 统一签署态文书样式并精简演示种子为单份麻精同意书
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
/**
|
||||
* 文档库的展示口径:状态、归属、文档类型。
|
||||
*
|
||||
* 状态口径取自原型 V10.2 的 libStatuses(启用中 / 草稿 / 归档 / 需复审 / 停用),
|
||||
* **不是**后端模板状态枚举(DRAFT / PENDING_REVIEW / APPROVED / PUBLISHED /
|
||||
* DISABLED / ARCHIVED)。原型已经彻底抛弃「发布 → 审核」那条工作流,
|
||||
* 页签若继续按后端枚举铺开,界面上会多出一堆科室看不懂也点不动的状态。
|
||||
*
|
||||
* 因此这里只做一件事:把后端原始状态**折叠**成原型口径。
|
||||
* 反向映射(口径 → 后端)只保留「按状态过滤」这一处需要,见 toBackendStatusFilter。
|
||||
*/
|
||||
import type { DocumentRecord, DocumentStatus } from '@/api/management/types'
|
||||
|
||||
/** 文档库页签与卡片上的状态,取值即显示文案 */
|
||||
export type DocumentLibraryStatus = '启用中' | '草稿' | '归档' | '需复审' | '停用'
|
||||
|
||||
/** 页签固定顺序,与原型 libStatuses 一致:启用中排最前,停用排最后 */
|
||||
export const DOCUMENT_LIBRARY_STATUSES: DocumentLibraryStatus[] = [
|
||||
'启用中',
|
||||
'草稿',
|
||||
'归档',
|
||||
'需复审',
|
||||
'停用',
|
||||
]
|
||||
|
||||
/** 状态色调:决定徽标配色(与原型 stDot 的取色一致) */
|
||||
export type DocumentStatusTone = 'enabled' | 'draft' | 'archived' | 'review' | 'stopped'
|
||||
|
||||
const STATUS_TONES: Record<DocumentLibraryStatus, DocumentStatusTone> = {
|
||||
启用中: 'enabled',
|
||||
草稿: 'draft',
|
||||
归档: 'archived',
|
||||
需复审: 'review',
|
||||
停用: 'stopped',
|
||||
}
|
||||
|
||||
/** 原型 stDot:状态徽标前的圆点颜色 */
|
||||
export const DOCUMENT_STATUS_DOT: Record<DocumentStatusTone, string> = {
|
||||
enabled: '#0f9d6c',
|
||||
draft: '#8a9aa3',
|
||||
archived: '#8a9aa3',
|
||||
review: '#d9821f',
|
||||
stopped: '#c0c8cd',
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端原始状态 → 原型口径。
|
||||
*
|
||||
* 折叠是有损的,且是刻意的:
|
||||
* - APPROVED 与 PUBLISHED 都算「启用中」——原型没有「审核通过但未发布」这一档;
|
||||
* - PENDING_REVIEW 与 REJECTED 都算「需复审」——原型只给一个「需复审」页签,
|
||||
* 至于「还等着审」还是「已被打回」,由卡片上的操作按钮与历史记录去区分;
|
||||
* - DISABLED 算「停用」而不是「归档」:停用是可逆的(还能启用),归档不是。
|
||||
*
|
||||
* 未知状态按「草稿」兜底而不是原样显示:口径是页签的键,多出一个键就多出一个
|
||||
* 原型上没有的页签;草稿是最安全的一档(既不显示为可发起,也不谎称已停用)。
|
||||
*/
|
||||
export function readLibraryStatus(record: {
|
||||
status: DocumentStatus
|
||||
backendStatus?: string
|
||||
}): DocumentLibraryStatus {
|
||||
switch (record.backendStatus) {
|
||||
case 'PUBLISHED':
|
||||
case 'APPROVED':
|
||||
return '启用中'
|
||||
case 'PENDING_REVIEW':
|
||||
case 'REJECTED':
|
||||
return '需复审'
|
||||
case 'ARCHIVED':
|
||||
return '归档'
|
||||
case 'DISABLED':
|
||||
return '停用'
|
||||
case 'DRAFT':
|
||||
return '草稿'
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
// 没有 backendStatus 的历史数据(演示文库、早期本地缓存)按归一后的状态反推
|
||||
switch (record.status) {
|
||||
case 'published':
|
||||
return '启用中'
|
||||
case 'review':
|
||||
return '需复审'
|
||||
case 'archived':
|
||||
return '归档'
|
||||
case 'draft':
|
||||
default:
|
||||
return '草稿'
|
||||
}
|
||||
}
|
||||
|
||||
export function readStatusTone(status: DocumentLibraryStatus): DocumentStatusTone {
|
||||
return STATUS_TONES[status]
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态页签 → 后端查询参数。
|
||||
*
|
||||
* 只用于「真实模式按状态向服务端过滤」;页面上默认仍是一次拉全量再本地过滤
|
||||
* (口径折叠后一个页签对应多个后端状态,服务端做不到一次查全)。
|
||||
* 映射不上的(需复审要同时含 PENDING_REVIEW 与 REJECTED)返回 undefined,
|
||||
* 调用方据此退回本地过滤,而不是拿一个错的状态去查。
|
||||
*/
|
||||
export function toBackendStatusFilter(status: DocumentLibraryStatus): string | undefined {
|
||||
switch (status) {
|
||||
case '启用中':
|
||||
return 'PUBLISHED'
|
||||
case '草稿':
|
||||
return 'DRAFT'
|
||||
case '归档':
|
||||
return 'ARCHIVED'
|
||||
case '停用':
|
||||
return 'DISABLED'
|
||||
case '需复审':
|
||||
default:
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
/** 只有「启用中」的文书能发起签署:草稿没定稿,停用/归档已下线 */
|
||||
export function canInitiateSigning(status: DocumentLibraryStatus): boolean {
|
||||
return status === '启用中'
|
||||
}
|
||||
|
||||
/** 停用 / 启用只在这两档之间来回(原型 setDocStatus 的取值口径) */
|
||||
export function canToggleStatus(status: DocumentLibraryStatus): boolean {
|
||||
return status === '启用中' || status === '停用'
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档归属:原型把「通用(全院)」当作科室清单里的一个选项一起勾选,
|
||||
* 勾中它就等于全院通用,其余科室勾选一并作废(见 docDeptPicks / openDocProps)。
|
||||
*/
|
||||
export const GENERAL_OWNERSHIP = '通用(全院)'
|
||||
|
||||
/** 归属选项 → 后端可落库的科室 id(勾了通用(全院)就没有科室 id) */
|
||||
export function resolveOwnershipDepartmentId(
|
||||
ownership: string[],
|
||||
departments: Array<{ id: string; name: string }>,
|
||||
): string | null {
|
||||
if (ownership.includes(GENERAL_OWNERSHIP)) {
|
||||
return null
|
||||
}
|
||||
|
||||
const first = ownership.find((name) => name !== GENERAL_OWNERSHIP)
|
||||
|
||||
return first ? (departments.find((department) => department.name === first)?.id ?? null) : null
|
||||
}
|
||||
|
||||
/** 归属徽标文案:全院通用用 🌐,科室用 🏥(与原型 tpl-card 的标签一致) */
|
||||
export function readOwnershipLabel(record: DocumentRecord): string {
|
||||
if (!record.departmentId) {
|
||||
return '🌐 全院通用'
|
||||
}
|
||||
|
||||
const name = record.departmentName ?? '未知科室'
|
||||
|
||||
return `🏥 ${name}`
|
||||
}
|
||||
|
||||
/** 归属是否为全院通用:卡片标签配色与归属勾选回填都要用同一个判据 */
|
||||
export function isGeneralOwnership(record: DocumentRecord): boolean {
|
||||
return !record.departmentId
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档类型。
|
||||
* 与原型 docTypes 同一份取值,属性弹窗用下拉而不是自由输入:
|
||||
* 类型是分组的键,自由输入会让「知情同意书 / 知情同意书 」这类写法分成两组。
|
||||
*/
|
||||
export const DOCUMENT_TYPES = [
|
||||
'知情同意书',
|
||||
'风险告知书',
|
||||
'入院告知',
|
||||
'检查预约单',
|
||||
'授权委托',
|
||||
]
|
||||
|
||||
export const DEFAULT_DOCUMENT_TYPE = '知情同意书'
|
||||
Reference in New Issue
Block a user