outbound-qc-pilot-view-sections.ts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import type { OutboundQcDetail } from '@/api/qc-work-order'
  2. import type { ViewField, ViewSection } from '@/components/business/system-view-dialog/index.vue'
  3. import { maskIdCard } from '@/utils/mask-sensitive'
  4. import {
  5. applicationStatusLabel,
  6. applicationStatusTagType,
  7. infusionMethodLabel,
  8. infusionStatusLabel,
  9. infusionStatusTagType,
  10. qcStatusLabel,
  11. qcStatusTagType,
  12. scheduleStatusLabel,
  13. scheduleStatusTagType,
  14. sexLabel
  15. } from '@/utils/status-tag-registry'
  16. export type OutboundViewContextVariant = 'pilot_service' | 'clinical_application'
  17. const SECTION_TITLES: Record<
  18. OutboundViewContextVariant,
  19. { application: string; schedule: string }
  20. > = {
  21. pilot_service: {
  22. application: '中试服务申请单信息',
  23. schedule: '本次输注计划信息'
  24. },
  25. clinical_application: {
  26. application: '临床应用申请信息',
  27. schedule: '临床应用输注计划信息'
  28. }
  29. }
  30. /** 出库工单/质检:申请单 / 患者 / 输注方案 / 输注计划 / 产品明细(码值转中文标签) */
  31. export function buildOutboundPilotContextSections(
  32. detail: OutboundQcDetail,
  33. variant: OutboundViewContextVariant = 'pilot_service'
  34. ): ViewSection[] {
  35. const app = detail.application
  36. const patient = detail.patient
  37. const plan = detail.infusionPlan
  38. const schedule = detail.infusionSchedule
  39. const products = detail.products || []
  40. const titles = SECTION_TITLES[variant]
  41. const result: ViewSection[] = []
  42. if (app) {
  43. result.push({
  44. title: titles.application,
  45. fields: [
  46. { label: '申请单号', value: app.applicationNo || '—' },
  47. { label: '申请单名称', value: app.applicationName || '—' },
  48. {
  49. label: '申请单状态',
  50. value: applicationStatusLabel(app.applicationStatus || ''),
  51. tagType: applicationStatusTagType(app.applicationStatus || '') as ViewField['tagType']
  52. },
  53. { label: '渠道名称', value: app.channelName || '—' }
  54. ]
  55. })
  56. }
  57. if (patient) {
  58. result.push({
  59. title: '患者信息',
  60. fields: [
  61. { label: '患者姓名', value: patient.patientName || '—' },
  62. { label: '性别', value: sexLabel(String(patient.sex ?? '')) || '—' },
  63. { label: '年龄', value: patient.age || '—' },
  64. { label: '联系电话', value: patient.phoneNo || '—' },
  65. {
  66. label: '身份证号',
  67. value: patient.idCardNo ? maskIdCard(patient.idCardNo) : '—'
  68. },
  69. { label: '紧急联系人', value: patient.emergencyContact || '—' },
  70. { label: '紧急联系电话', value: patient.emergencyPhone || '—' },
  71. { label: '临床诊断', value: patient.clinicalDiagnosis || '—', span: true }
  72. ],
  73. slotTitle: '诊断附件',
  74. slotTitleStyle: 'field',
  75. slot: 'diagnosis-attachments'
  76. })
  77. }
  78. if (plan) {
  79. result.push({
  80. title: '输注方案信息',
  81. fields: [
  82. {
  83. label: '总疗程数',
  84. value: plan.totalCourseCount != null ? String(plan.totalCourseCount) : '—'
  85. },
  86. { label: '疗程间隔', value: plan.courseInterval || '—' },
  87. { label: '输注开始日期', value: plan.infusionStartDate || '—' }
  88. ]
  89. })
  90. }
  91. if (schedule) {
  92. const scheduleFields: ViewField[] = [
  93. { label: '输注时间', value: schedule.infusionTime || '—' },
  94. { label: '输注地点', value: schedule.infusionLocation || '—' },
  95. { label: '输注方式', value: infusionMethodLabel(schedule.infusionMethod || '') },
  96. {
  97. label: '计划状态',
  98. value: scheduleStatusLabel(schedule.scheduleStatus || ''),
  99. tagType: scheduleStatusTagType(schedule.scheduleStatus || '') as ViewField['tagType']
  100. },
  101. {
  102. label: '输注状态',
  103. value: infusionStatusLabel(schedule.infusionStatus || ''),
  104. tagType: infusionStatusTagType(schedule.infusionStatus || '') as ViewField['tagType']
  105. },
  106. {
  107. label: '质检状态',
  108. value: qcStatusLabel(schedule.qcStatus || ''),
  109. tagType: qcStatusTagType(schedule.qcStatus || '') as ViewField['tagType']
  110. }
  111. ]
  112. if (schedule.cancelReason) {
  113. scheduleFields.push({ label: '取消原因', value: schedule.cancelReason, span: true })
  114. }
  115. result.push({ title: titles.schedule, fields: scheduleFields })
  116. }
  117. if (products.length) {
  118. result.push({
  119. title: '产品明细',
  120. fields: [],
  121. slot: 'product-table'
  122. })
  123. }
  124. return result
  125. }
  126. export function isOutboundPilotServiceQcTask(d?: {
  127. qcBizType?: string
  128. receptionSource?: string
  129. } | null): boolean {
  130. return d?.qcBizType === 'outbound' && d?.receptionSource === 'pilot_service'
  131. }