diff --git a/src/api/qc.ts b/src/api/qc.ts new file mode 100644 index 0000000..2fac823 --- /dev/null +++ b/src/api/qc.ts @@ -0,0 +1,153 @@ +import { http } from '@/api/http' +import type { Elder } from '@/api/elder' +import type { Order } from '@/api/order' +import type { ChangePlanData, Plan } from '@/api/plan' +import type { ServiceRecordDetail } from '@/api/record' + +/** + * 质控闸门(qc / ho_record_correction)API。 + * 字段锚点见 shared/data-model spec(qc / ho_record_correction)。 + * - 时间字段(qcTime/passTime/correctedAt/createdAt/updatedAt)后端经 TransformInterceptor 序列化为毫秒时间戳; + * - 待放行队列项含 record 摘要 + correctionCount + focus(补正≥3)+ waitMinutes(已等待分钟数)。 + */ + +/** 质控结果(qc_result)。 */ +export const QC_RESULTS = ['pending', 'passed', 'returned'] as const + +/** 质控类型(qc_type)。 */ +export const QC_TYPES = ['normal', 'recheck'] as const + +export const QC_RESULT_TAG_MAP: Record = { + pending: { label: '待质控', type: 'warning' }, + passed: { label: '已放行', type: 'success' }, + returned: { label: '已退回', type: 'danger' }, +} + +/** 质控记录(qc)。 */ +export interface QcRecord { + id: string + tenantCode: string + recordId: string + qcType: string + qcResult: string + qcNote: string | null + qcStaffId: string | null + qcTime: number | null + passTime: number | null + firstQcId: string | null + createdAt: number + createdBy: string | null + updatedAt: number + deletedAt: number | null +} + +/** 待放行队列项的留痕摘要。 */ +export interface PendingQcRecordSummary { + id: string + elderId: string + assigneeId: string + checkinTime: number | null + recordStatus: string +} + +/** 待放行队列项:qc + 留痕摘要 + 补正计数/质控重点/已等待。 */ +export interface PendingQcItem extends QcRecord { + record: PendingQcRecordSummary | null + correctionCount: number + focus: boolean + waitMinutes: number +} + +/** 单类待办计数 + 消除条件。 */ +export interface CountWithCondition { + count: number + clearCondition: string +} + +/** 住院仍有派单:老人 + 活跃工单。 */ +export interface HospActiveItem { + elder: Elder + order: Order +} + +/** 五类主动推送聚合结果。 */ +export interface PendingListResult { + abnormalOpen: CountWithCondition + overdue: CountWithCondition & { list: Order[] } + hospActive: CountWithCondition & { list: HospActiveItem[] } + missingPlan: CountWithCondition & { list: Elder[] } + pendingQc: CountWithCondition & { list: PendingQcItem[] } +} + +/** 补正说明(ho_record_correction)。 */ +export interface QcCorrection { + id: string + tenantCode: string + recordId: string + qcId: string | null + correctionNote: string + correctedBy: string + correctedAt: number +} + +/** 质控详情:qc + 关联留痕全文 + 补正历史。 */ +export interface QcDetail extends QcRecord { + record: ServiceRecordDetail + corrections: QcCorrection[] +} + +/** 退回入参(qc_note 必填)。 */ +export interface ReturnQcData { + qcNote: string +} + +/** 补正入参。 */ +export interface CorrectData { + recordId: string + correctionNote: string +} + +/** 批量放行入参。 */ +export interface BatchPassData { + recordIds: string[] +} + +/** 异常联动改计划入参:复用 plan.change 字段 + abnormalId。 */ +export interface ExceptionLinkData extends ChangePlanData { + abnormalId: string +} + +/** 五类待办聚合。 */ +export function pendingList(signal?: AbortSignal): Promise { + return http.get('/qc/pending/list', { signal }) +} + +/** 质控详情(留痕全文/项目/照片/异常/定位/补正历史)。 */ +export function getQcDetail(id: string): Promise { + return http.get(`/qc/${id}`) +} + +/** 放行(后端自检 1004/3001/4001,错误 ApiError.message 直接显示)。 */ +export function passQc(id: string): Promise { + return http.post(`/qc/${id}/pass`) +} + +/** 退回(qc_note 必填)。 */ +export function returnQc(id: string, data: ReturnQcData): Promise { + return http.post(`/qc/${id}/return`, data) +} + +/** 批量放行(后端拦不可批量项)。 */ +export function batchPassQc(data: BatchPassData): Promise<{ passed: number }> { + return http.post<{ passed: number }>('/qc/batch-pass', data) +} + +/** 异常联动改计划(复用 plan.change + 回填 link_plan_change)。 */ +export function exceptionLink(data: ExceptionLinkData): Promise { + return http.post('/qc/exception/link', data) +} + +/** 补正(写更正说明 + 生成 recheck qc)。 */ +export function correctQc(data: CorrectData): Promise { + return http.post('/qc/correct', data) +} diff --git a/src/pages/ltc/qc/index.vue b/src/pages/ltc/qc/index.vue index 2f14557..2387438 100644 --- a/src/pages/ltc/qc/index.vue +++ b/src/pages/ltc/qc/index.vue @@ -1,28 +1,391 @@