status-tag-registry.ts 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. /**
  2. * 状态标签注册表 — 全局集中定义所有枚举字段的 label + tagType
  3. */
  4. import { resolveVoidTypeLabel } from '@/utils/void-type-dict'
  5. // ── 类型定义 ──────────────────────────────────────────────────────────────────
  6. /** el-tag 的 type 属性值 */
  7. export type TagType = 'success' | 'warning' | 'danger' | 'info' | '' | 'primary'
  8. /** 单条枚举映射 */
  9. export interface StatusItem {
  10. label: string
  11. tagType: TagType
  12. }
  13. /** 注册表类型 */
  14. export type StatusRegistry = Record<string, StatusItem>
  15. // ── 工厂函数 ──────────────────────────────────────────────────────────────────
  16. function createLabelGetter(registry: StatusRegistry) {
  17. return (code: string): string => registry[code]?.label ?? code ?? '—'
  18. }
  19. function createTagTypeGetter(registry: StatusRegistry) {
  20. return (code: string): TagType => registry[code]?.tagType ?? 'info'
  21. }
  22. // ══════════════════════════════════════════════════════════════════════════════
  23. // 协议 / 存储 域
  24. // ══════════════════════════════════════════════════════════════════════════════
  25. export const protocolStatus: StatusRegistry = {
  26. dsx: { label: '待生效', tagType: 'info' },
  27. sxz: { label: '生效中', tagType: 'primary' },
  28. ygq: { label: '已过期', tagType: 'warning' },
  29. yzf: { label: '已作废', tagType: 'danger' },
  30. sdfq: { label: '属地废弃', tagType: 'danger' },
  31. zky: { label: '转科研', tagType: 'primary' }
  32. }
  33. /** 协议/捐赠单无效态(与样本接收、生产工单列表过滤口径一致) */
  34. export const INACTIVE_PROTOCOL_STATUSES = ['yzf', 'sdfq'] as const
  35. export function isInactiveProtocolStatus(status?: string): boolean {
  36. const code = (status || '').trim()
  37. return (INACTIVE_PROTOCOL_STATUSES as readonly string[]).includes(code)
  38. }
  39. export const protocolStatusLabel = createLabelGetter(protocolStatus)
  40. export const protocolStatusTagType = createTagTypeGetter(protocolStatus)
  41. /** 协议状态展示文案;已作废时追加作废类型,如「已作废(客户毁存)」 */
  42. export function protocolStatusDisplayLabel(status: string, voidType?: string): string {
  43. const base = protocolStatusLabel(status)
  44. if ((status || '').trim() !== 'yzf') return base
  45. const vt = resolveVoidTypeLabel(voidType || '')
  46. return vt ? `${base}(${vt})` : base
  47. }
  48. export const donationStatus: StatusRegistry = {
  49. dsx: { label: '待生效', tagType: 'info' },
  50. sxz: { label: '生效中', tagType: 'primary' },
  51. ygq: { label: '已过期', tagType: 'warning' },
  52. yzf: { label: '已作废', tagType: 'danger' },
  53. sdfq: { label: '属地废弃', tagType: 'danger' },
  54. zckc: { label: '转细胞存储', tagType: 'primary' }
  55. }
  56. export const donationStatusLabel = createLabelGetter(donationStatus)
  57. export const donationStatusTagType = createTagTypeGetter(donationStatus)
  58. /** 捐赠协议状态展示文案;已作废时追加作废类型 */
  59. export function donationStatusDisplayLabel(status: string, voidType?: string): string {
  60. const base = donationStatusLabel(status)
  61. if ((status || '').trim() !== 'yzf') return base
  62. const vt = resolveVoidTypeLabel(voidType || '')
  63. return vt ? `${base}(${vt})` : base
  64. }
  65. /** 按来源(细胞存储 / 科研捐赠)展示协议状态,已作废时带作废类型 */
  66. export function protocolStatusDisplayLabelBySource(
  67. status: string,
  68. source: string,
  69. voidType?: string
  70. ): string {
  71. return source === 'research_donation'
  72. ? donationStatusDisplayLabel(status, voidType)
  73. : protocolStatusDisplayLabel(status, voidType)
  74. }
  75. export const sampleStatus: StatusRegistry = {
  76. ycj: { label: '已采集', tagType: 'primary' },
  77. jcz: { label: '检测中', tagType: 'warning' },
  78. yrk: { label: '已入库', tagType: 'success' },
  79. yzf: { label: '已作废', tagType: 'danger' }
  80. }
  81. export const sampleStatusLabel = createLabelGetter(sampleStatus)
  82. export const sampleStatusTagType = createTagTypeGetter(sampleStatus)
  83. export const sampleCollectionFlag: StatusRegistry = {
  84. uncollected: { label: '未采集', tagType: 'info' },
  85. collected: { label: '已采集', tagType: 'success' },
  86. voided: { label: '已作废', tagType: 'danger' }
  87. }
  88. export const sampleCollectionFlagLabel = createLabelGetter(sampleCollectionFlag)
  89. export const sampleCollectionFlagTagType = createTagTypeGetter(sampleCollectionFlag)
  90. export const sampleReceptionFlag: StatusRegistry = {
  91. none: { label: '未接收', tagType: 'info' },
  92. js: { label: '已接收', tagType: 'success' },
  93. bj: { label: '拒收', tagType: 'danger' }
  94. }
  95. export const sampleReceptionFlagLabel = createLabelGetter(sampleReceptionFlag)
  96. export const sampleReceptionFlagTagType = createTagTypeGetter(sampleReceptionFlag)
  97. export const sampleQcFlag: StatusRegistry = {
  98. incomplete: { label: '未完成', tagType: 'warning' },
  99. complete: { label: '已完成', tagType: 'success' },
  100. voided: { label: '已作废', tagType: 'danger' }
  101. }
  102. export const sampleQcFlagLabel = createLabelGetter(sampleQcFlag)
  103. export const sampleQcFlagTagType = createTagTypeGetter(sampleQcFlag)
  104. export const sampleStorageFlag: StatusRegistry = {
  105. none: { label: '未入库', tagType: 'info' },
  106. yrk: { label: '已入库', tagType: 'success' },
  107. rejected: { label: '拒绝入库', tagType: 'danger' }
  108. }
  109. export const sampleStorageFlagLabel = createLabelGetter(sampleStorageFlag)
  110. export const sampleStorageFlagTagType = createTagTypeGetter(sampleStorageFlag)
  111. export const handleDoneFlag: StatusRegistry = {
  112. '1': { label: '已办理', tagType: 'success' },
  113. '0': { label: '未办理', tagType: 'info' }
  114. }
  115. export const handleDoneFlagLabel = createLabelGetter(handleDoneFlag)
  116. export const handleDoneFlagTagType = createTagTypeGetter(handleDoneFlag)
  117. export const payStatus: StatusRegistry = {
  118. dfj: { label: '已付款', tagType: 'primary' },
  119. jfqrz: { label: '付款确认中', tagType: 'warning' },
  120. yjf: { label: '付款完成', tagType: 'success' },
  121. tfqrz: { label: '退费确认中', tagType: 'warning' },
  122. ytf: { label: '已退费', tagType: 'danger' }
  123. }
  124. export const payStatusLabel = createLabelGetter(payStatus)
  125. export const payStatusTagType = createTagTypeGetter(payStatus)
  126. export const auditStatus: StatusRegistry = {
  127. shtg: { label: '审核通过', tagType: 'success' },
  128. shth: { label: '审核退回', tagType: 'danger' }
  129. }
  130. export const auditStatusLabel = createLabelGetter(auditStatus)
  131. export const auditStatusTagType = createTagTypeGetter(auditStatus)
  132. export const payMode: StatusRegistry = {
  133. dj: { label: '趸交', tagType: 'primary' },
  134. fq: { label: '分期', tagType: 'warning' },
  135. djfq: { label: '趸交+分期', tagType: 'warning' },
  136. fgd: { label: '分改趸', tagType: 'warning' }
  137. }
  138. export const payModeLabel = createLabelGetter(payMode)
  139. export const payModeTagType = createTagTypeGetter(payMode)
  140. export const paymentChaseStatus: StatusRegistry = {
  141. overdue: { label: '已逾期', tagType: 'danger' },
  142. upcoming: { label: '即将到期', tagType: 'warning' }
  143. }
  144. export const paymentChaseStatusLabel = createLabelGetter(paymentChaseStatus)
  145. export const paymentChaseStatusTagType = createTagTypeGetter(paymentChaseStatus)
  146. export const periodFinanceAudit: StatusRegistry = {
  147. dfj: { label: '待缴费', tagType: 'info' },
  148. jfqrz: { label: '确认中', tagType: 'warning' },
  149. yjf: { label: '已通过', tagType: 'success' },
  150. partial: { label: '部分到账', tagType: 'primary' }
  151. }
  152. export const periodFinanceAuditLabel = createLabelGetter(periodFinanceAudit)
  153. export const periodFinanceAuditTagType = createTagTypeGetter(periodFinanceAudit)
  154. /** 样本缴费进度 Tag(勿与转账笔 payStatus 混用:payStatus.dfj=已付款) */
  155. export const samplePaymentProgress: StatusRegistry = {
  156. dfj: { label: '待缴费', tagType: 'info' },
  157. bfyj: { label: '部分已缴', tagType: 'primary' },
  158. yjq: { label: '已缴清', tagType: 'success' }
  159. }
  160. export const samplePaymentProgressLabel = createLabelGetter(samplePaymentProgress)
  161. export const samplePaymentProgressTagType = createTagTypeGetter(samplePaymentProgress)
  162. export const transferType: StatusRegistry = {
  163. wxzz: { label: '微信转账', tagType: 'success' },
  164. zzbzz: { label: '支付宝转账', tagType: 'primary' },
  165. yhkzz: { label: '银行卡转账', tagType: 'info' },
  166. xj: { label: '现金', tagType: 'warning' },
  167. lszz: { label: '乐刷', tagType: 'primary' }
  168. }
  169. export const transferTypeLabel = createLabelGetter(transferType)
  170. export const transferTypeTagType = createTagTypeGetter(transferType)
  171. export const transportType: StatusRegistry = {
  172. kdys: { label: '快递运输', tagType: 'info' },
  173. ryxd: { label: '人员携带', tagType: 'success' }
  174. }
  175. export const transportTypeLabel = createLabelGetter(transportType)
  176. export const transportTypeTagType = createTagTypeGetter(transportType)
  177. export const receptionSource: StatusRegistry = {
  178. cell_storage: { label: '细胞存储', tagType: 'primary' },
  179. research_donation: { label: '科研捐赠', tagType: 'warning' },
  180. outbound: { label: '出库', tagType: 'primary' },
  181. pilot_service: { label: '中试服务', tagType: 'primary' },
  182. clinical_application: { label: '临床应用', tagType: 'warning' },
  183. basic_experiment: { label: '基础实验', tagType: 'primary' }
  184. }
  185. export const receptionSourceLabel = createLabelGetter(receptionSource)
  186. export const receptionSourceTagType = createTagTypeGetter(receptionSource)
  187. export const newbornSex: StatusRegistry = {
  188. '1': { label: '男', tagType: 'primary' },
  189. '0': { label: '女', tagType: 'success' }
  190. }
  191. export const newbornSexLabel = createLabelGetter(newbornSex)
  192. export const newbornSexTagType = createTagTypeGetter(newbornSex)
  193. export const deliveryMode: StatusRegistry = {
  194. sc: { label: '顺产', tagType: 'info' },
  195. pgc: { label: '剖宫产', tagType: 'warning' }
  196. }
  197. export const deliveryModeLabel = createLabelGetter(deliveryMode)
  198. export const deliveryModeTagType = createTagTypeGetter(deliveryMode)
  199. export const sourceType: StatusRegistry = {
  200. direct: { label: '独立新建', tagType: 'info' },
  201. from_storage: { label: '从存储转来', tagType: 'primary' }
  202. }
  203. export const sourceTypeLabel = createLabelGetter(sourceType)
  204. export const sourceTypeTagType = createTagTypeGetter(sourceType)
  205. // ══════════════════════════════════════════════════════════════════════════════
  206. // 质检域
  207. // ══════════════════════════════════════════════════════════════════════════════
  208. export const qcBizType: StatusRegistry = {
  209. inbound: { label: '入库质检', tagType: 'success' },
  210. outbound: { label: '出库质检', tagType: 'primary' },
  211. temporary: { label: '临时质检', tagType: 'warning' }
  212. }
  213. export const qcBizTypeLabel = createLabelGetter(qcBizType)
  214. export const qcBizTypeTagType = createTagTypeGetter(qcBizType)
  215. export const workOrderStatus: StatusRegistry = {
  216. dpz: { label: '待配置', tagType: 'info' },
  217. ypz: { label: '已配置', tagType: 'success' },
  218. ywc: { label: '已完成', tagType: 'success' },
  219. yzf: { label: '已作废', tagType: 'danger' }
  220. }
  221. export const workOrderStatusLabel = createLabelGetter(workOrderStatus)
  222. export const workOrderStatusTagType = createTagTypeGetter(workOrderStatus)
  223. export const QC_WORK_ORDER_STATUS_FILTER_OPTIONS = Object.entries(workOrderStatus).map(
  224. ([value, meta]) => ({
  225. value,
  226. label: meta.label
  227. })
  228. )
  229. export function joinWorkOrderStatusFilter(statuses: string[]): string | undefined {
  230. const list = statuses.map((s) => s.trim()).filter(Boolean)
  231. return list.length ? list.join(',') : undefined
  232. }
  233. export function matchesWorkOrderStatusFilter(
  234. status: string,
  235. filter: string | string[] | undefined
  236. ): boolean {
  237. if (!filter) return true
  238. const list = Array.isArray(filter)
  239. ? filter
  240. : filter
  241. .split(',')
  242. .map((s) => s.trim())
  243. .filter(Boolean)
  244. if (!list.length) return true
  245. return list.includes(status)
  246. }
  247. export const productionWorkOrderStatus: StatusRegistry = {
  248. dpz: { label: '待配置', tagType: 'info' },
  249. jxz: { label: '进行中', tagType: 'warning' },
  250. ywc: { label: '已完成', tagType: 'success' },
  251. yzf: { label: '已作废', tagType: 'danger' }
  252. }
  253. export const productionWorkOrderStatusLabel = createLabelGetter(productionWorkOrderStatus)
  254. export const productionWorkOrderStatusTagType = createTagTypeGetter(productionWorkOrderStatus)
  255. export const PRODUCTION_WORK_ORDER_STATUS_FILTER_OPTIONS = Object.entries(
  256. productionWorkOrderStatus
  257. ).map(([value, meta]) => ({
  258. value,
  259. label: meta.label
  260. }))
  261. export const taskType: StatusRegistry = {
  262. sysz: { label: '实验室自检', tagType: 'success' },
  263. dsfjc: { label: '第三方检测', tagType: 'primary' }
  264. }
  265. export const taskTypeLabel = createLabelGetter(taskType)
  266. export const taskTypeTagType = createTagTypeGetter(taskType)
  267. export const qcConclusion: StatusRegistry = {
  268. tg: { label: '通过', tagType: 'success' },
  269. btg: { label: '不通过', tagType: 'danger' }
  270. }
  271. export const qcTaskConclusionLabel = createLabelGetter(qcConclusion)
  272. export const qcTaskConclusionTagType = createTagTypeGetter(qcConclusion)
  273. /** 工单级质检结论(列表卡片):合格 / 不合格;无结论返回空串 */
  274. export const qcWorkOrderConclusionLabelMap: StatusRegistry = {
  275. tg: { label: '合格', tagType: 'success' },
  276. btg: { label: '不合格', tagType: 'danger' }
  277. }
  278. export const qcWorkOrderConclusionLabel = createLabelGetter(qcWorkOrderConclusionLabelMap)
  279. export const qcWorkOrderConclusionTagType = createTagTypeGetter(qcWorkOrderConclusionLabelMap)
  280. /** 无 tg/btg 时展示「待结论」(待办醒目,用 danger) */
  281. export function qcConclusionDisplayLabel(code?: string | null): string {
  282. const c = (code || '').trim()
  283. if (c === 'tg' || c === 'btg') return qcTaskConclusionLabel(c)
  284. return '待结论'
  285. }
  286. export function qcConclusionDisplayTagType(code?: string | null): TagType {
  287. const c = (code || '').trim()
  288. if (c === 'tg' || c === 'btg') return qcTaskConclusionTagType(c)
  289. return 'danger'
  290. }
  291. export const taskStatus: StatusRegistry = {
  292. dzx: { label: '待执行', tagType: 'danger' },
  293. jxz: { label: '进行中', tagType: 'warning' },
  294. ywc: { label: '已完成', tagType: 'success' }
  295. }
  296. export const taskStatusLabel = createLabelGetter(taskStatus)
  297. export const taskStatusTagType = createTagTypeGetter(taskStatus)
  298. export const acceptConclusion: StatusRegistry = {
  299. js: { label: '接收', tagType: 'success' },
  300. bj: { label: '拒收', tagType: 'danger' }
  301. }
  302. export const acceptConclusionLabel = createLabelGetter(acceptConclusion)
  303. export const acceptConclusionTagType = createTagTypeGetter(acceptConclusion)
  304. // ══════════════════════════════════════════════════════════════════════════════
  305. // 渠道域
  306. // ══════════════════════════════════════════════════════════════════════════════
  307. export const channelType: StatusRegistry = {
  308. yy: { label: '医院', tagType: 'primary' },
  309. hzjg: { label: '合作机构', tagType: 'success' },
  310. zs: { label: '诊所', tagType: 'warning' },
  311. zfjg: { label: '政府机构', tagType: 'danger' },
  312. qt: { label: '其他', tagType: 'info' }
  313. }
  314. export const channelTypeLabel = createLabelGetter(channelType)
  315. export const channelTypeTagType = createTagTypeGetter(channelType)
  316. export const agreementType: StatusRegistry = {
  317. kyxy: { label: '框架协议', tagType: 'primary' },
  318. zsxy: { label: '中试协议', tagType: 'success' },
  319. lcxy: { label: '临床协议', tagType: 'warning' },
  320. jcsy: { label: '基础实验', tagType: 'primary' }
  321. }
  322. export const agreementTypeLabel = createLabelGetter(agreementType)
  323. export const agreementTypeTagType = createTagTypeGetter(agreementType)
  324. export const agreementStatus: StatusRegistry = {
  325. dsx: { label: '待生效', tagType: 'info' },
  326. sxz: { label: '生效中', tagType: 'primary' },
  327. yzf: { label: '已作废', tagType: 'danger' }
  328. }
  329. export const agreementStatusLabel = createLabelGetter(agreementStatus)
  330. export const agreementStatusTagType = createTagTypeGetter(agreementStatus)
  331. export const settlementType: StatusRegistry = {
  332. yj: { label: '月结', tagType: '' },
  333. jj: { label: '季结', tagType: 'success' },
  334. nj: { label: '年结', tagType: 'warning' },
  335. dcjs: { label: '单次结算', tagType: 'danger' }
  336. }
  337. export const settlementTypeLabel = createLabelGetter(settlementType)
  338. export const settlementTypeTagType = createTagTypeGetter(settlementType)
  339. // ══════════════════════════════════════════════════════════════════════════════
  340. // 订单域
  341. // ══════════════════════════════════════════════════════════════════════════════
  342. export const orderStatus: StatusRegistry = {
  343. pending_payment: { label: '待支付', tagType: 'warning' },
  344. pending_confirm: { label: '待收货', tagType: 'info' },
  345. completed: { label: '已完成', tagType: 'success' },
  346. cancelled: { label: '已取消', tagType: 'danger' }
  347. }
  348. export const orderStatusLabel = createLabelGetter(orderStatus)
  349. export const orderStatusTagType = createTagTypeGetter(orderStatus)
  350. export const deliveryStatusMap: StatusRegistry = {
  351. pending_dispatch: { label: '待分配配送', tagType: 'info' },
  352. delivering: { label: '配送中', tagType: 'warning' },
  353. delivered: { label: '配送完成', tagType: 'success' }
  354. }
  355. export const deliveryStatusLabel = createLabelGetter(deliveryStatusMap)
  356. export const deliveryStatusTagType = createTagTypeGetter(deliveryStatusMap)
  357. export const paymentMethod: StatusRegistry = {
  358. online: { label: '线上支付', tagType: 'success' },
  359. offline: { label: '线下支付', tagType: 'info' }
  360. }
  361. export const paymentMethodLabel = createLabelGetter(paymentMethod)
  362. export const paymentMethodTagType = createTagTypeGetter(paymentMethod)
  363. export const orderPayStatus: StatusRegistry = {
  364. pending_payment: { label: '待支付', tagType: 'warning' },
  365. paid: { label: '已支付', tagType: 'success' }
  366. }
  367. export const orderPayStatusLabel = createLabelGetter(orderPayStatus)
  368. export const orderPayStatusTagType = createTagTypeGetter(orderPayStatus)
  369. // ══════════════════════════════════════════════════════════════════════════════
  370. // 系统 / 通用域
  371. // ══════════════════════════════════════════════════════════════════════════════
  372. /** 通用启用/停用(数据库 status 字段 1/0) */
  373. export const enableStatus: StatusRegistry = {
  374. '1': { label: '正常', tagType: 'success' },
  375. '0': { label: '停用', tagType: 'danger' }
  376. }
  377. export const enableStatusLabel = createLabelGetter(enableStatus)
  378. export const enableStatusTagType = createTagTypeGetter(enableStatus)
  379. /** 性别(客户等业务表) */
  380. export const sex: StatusRegistry = {
  381. '0': { label: '男', tagType: 'primary' },
  382. '1': { label: '女', tagType: 'success' }
  383. }
  384. export const sexLabel = createLabelGetter(sex)
  385. export const sexTagType = createTagTypeGetter(sex)
  386. /** 预签约订单状态 */
  387. export const presignOrderStatus: StatusRegistry = {
  388. draft: { label: '草稿', tagType: 'info' },
  389. active: { label: '进行中', tagType: 'warning' },
  390. converted: { label: '已转正式', tagType: 'success' },
  391. void: { label: '已作废', tagType: 'danger' }
  392. }
  393. export const presignOrderStatusLabel = createLabelGetter(presignOrderStatus)
  394. export const presignOrderStatusTagType = createTagTypeGetter(presignOrderStatus)
  395. /** 请假状态 */
  396. export const leaveStatus: StatusRegistry = {
  397. draft: { label: '草稿', tagType: 'info' },
  398. pending: { label: '审批中', tagType: 'warning' },
  399. approved: { label: '已通过', tagType: 'success' },
  400. rejected: { label: '已驳回', tagType: 'danger' },
  401. cancelled: { label: '已取消', tagType: 'info' }
  402. }
  403. export const leaveStatusLabel = createLabelGetter(leaveStatus)
  404. export const leaveStatusTagType = createTagTypeGetter(leaveStatus)
  405. /** 数据权限范围 */
  406. export const dataScope: StatusRegistry = {
  407. '1': { label: '全部数据', tagType: '' },
  408. '2': { label: '本部门数据', tagType: 'info' },
  409. '3': { label: '本部门及以下', tagType: 'info' },
  410. '4': { label: '仅本人', tagType: 'warning' },
  411. '5': { label: '自定义', tagType: 'primary' }
  412. }
  413. export const dataScopeLabel = createLabelGetter(dataScope)
  414. export const dataScopeTagType = createTagTypeGetter(dataScope)
  415. /** 洁净室等级 */
  416. export const cleanRoomGrade: StatusRegistry = {
  417. A: { label: 'A级', tagType: 'warning' },
  418. B: { label: 'B级', tagType: '' },
  419. C: { label: 'C级', tagType: 'info' },
  420. D: { label: 'D级', tagType: 'info' }
  421. }
  422. export const cleanRoomGradeLabel = createLabelGetter(cleanRoomGrade)
  423. export const cleanRoomGradeTagType = createTagTypeGetter(cleanRoomGrade)
  424. /** 样本编码类型 */
  425. export const sampleCodeType: StatusRegistry = {
  426. zxbm: { label: '造血编码', tagType: 'info' },
  427. qdbm: { label: '脐带编码', tagType: 'primary' }
  428. }
  429. export const sampleCodeTypeLabel = createLabelGetter(sampleCodeType)
  430. export const sampleCodeTypeTagType = createTagTypeGetter(sampleCodeType)
  431. /** 耗材包类型 */
  432. export const packType: StatusRegistry = {
  433. bzhcb: { label: '标准耗材包', tagType: 'primary' },
  434. zdyhcb: { label: '自定义耗材包', tagType: 'warning' }
  435. }
  436. export const packTypeLabel = createLabelGetter(packType)
  437. export const packTypeTagType = createTagTypeGetter(packType)
  438. /** 生产物料类型 */
  439. export const productionMaterialType: StatusRegistry = {
  440. reagent: { label: '试剂', tagType: 'primary' },
  441. consumable: { label: '耗材', tagType: 'success' },
  442. configured_reagent: { label: '配置试剂', tagType: 'warning' }
  443. }
  444. export const productionMaterialTypeLabel = createLabelGetter(productionMaterialType)
  445. export const productionMaterialTypeTagType = createTagTypeGetter(productionMaterialType)
  446. export const productionMaterialUsageSourceType: StatusRegistry = {
  447. manual_in: { label: '手动入库', tagType: 'success' },
  448. manual_out: { label: '手动出库', tagType: 'warning' },
  449. manual_discard: { label: '手动废弃', tagType: 'danger' },
  450. step_save: { label: '生产扣减', tagType: 'primary' },
  451. prep_consume: { label: '配制消耗', tagType: 'info' },
  452. prep_in: { label: '配制入库', tagType: 'success' }
  453. }
  454. export const productionMaterialUsageSourceTypeLabel = createLabelGetter(
  455. productionMaterialUsageSourceType
  456. )
  457. export const productionMaterialUsageSourceTypeTagType = createTagTypeGetter(
  458. productionMaterialUsageSourceType
  459. )
  460. // ══════════════════════════════════════════════════════════════════════════════
  461. // 入库放行审核域
  462. // ══════════════════════════════════════════════════════════════════════════════
  463. export const storageReleaseConclusion: StatusRegistry = {
  464. tg: { label: '通过', tagType: 'success' },
  465. btg: { label: '不通过', tagType: 'danger' }
  466. }
  467. export const storageReleaseConclusionLabel = createLabelGetter(storageReleaseConclusion)
  468. export const storageReleaseConclusionTagType = createTagTypeGetter(storageReleaseConclusion)
  469. export const storageStatus: StatusRegistry = {
  470. drk: { label: '待入库', tagType: 'warning' },
  471. yrk: { label: '已入库', tagType: 'success' }
  472. }
  473. export const storageStatusLabel = createLabelGetter(storageStatus)
  474. export const storageStatusTagType = createTagTypeGetter(storageStatus)
  475. // ══════════════════════════════════════════════════════════════════════════════
  476. // 渠道服务订单域
  477. // ══════════════════════════════════════════════════════════════════════════════
  478. /** 渠道服务订单类型 */
  479. export const channelServiceOrderType: StatusRegistry = {
  480. yfk: { label: '预付款充值', tagType: 'primary' },
  481. gmcp: { label: '购买产品份数', tagType: 'success' }
  482. }
  483. export const channelServiceOrderTypeLabel = createLabelGetter(channelServiceOrderType)
  484. export const channelServiceOrderTypeTagType = createTagTypeGetter(channelServiceOrderType)
  485. /** 渠道服务订单状态 */
  486. export const channelServiceOrderStatus: StatusRegistry = {
  487. dsx: { label: '待生效', tagType: 'info' },
  488. dqr: { label: '待确认', tagType: 'warning' },
  489. yqr: { label: '已确认', tagType: 'success' },
  490. sxz: { label: '生效中', tagType: 'primary' },
  491. tfqrz: { label: '退款确认中', tagType: 'danger' },
  492. ytf: { label: '已退款', tagType: 'info' },
  493. yzf: { label: '已作废', tagType: 'info' }
  494. }
  495. export const channelServiceOrderStatusLabel = createLabelGetter(channelServiceOrderStatus)
  496. export const channelServiceOrderStatusTagType = createTagTypeGetter(channelServiceOrderStatus)
  497. // ══════════════════════════════════════════════════════════════════════════════
  498. // 流水域
  499. // ══════════════════════════════════════════════════════════════════════════════
  500. // 流水类型
  501. export const txnTypeLabel = (type: string): string => {
  502. const map: Record<string, string> = {
  503. recharge: '充值',
  504. refund: '退款',
  505. purchase: '购买产品',
  506. unsubscribe: '退订产品',
  507. settlement: '输注结算'
  508. }
  509. return map[type] || type
  510. }
  511. export const txnTypeTagType = (type: string): string => {
  512. const map: Record<string, string> = {
  513. recharge: '',
  514. refund: 'danger',
  515. purchase: 'success',
  516. unsubscribe: 'warning',
  517. settlement: 'primary'
  518. }
  519. return map[type] || 'info'
  520. }
  521. // 流水状态
  522. export const txnStatusLabel = (status: string): string => {
  523. const map: Record<string, string> = {
  524. dsx: '待生效',
  525. dqr: '待财务确认',
  526. yqr: '已确认',
  527. yzf: '已作废'
  528. }
  529. return map[status] || status
  530. }
  531. export const txnStatusTagType = (status: string): string => {
  532. const map: Record<string, string> = {
  533. dsx: 'info',
  534. dqr: 'warning',
  535. yqr: 'success',
  536. yzf: 'danger'
  537. }
  538. return map[status] || 'info'
  539. }
  540. /** 中试申请单状态 */
  541. export function applicationStatusLabel(status: string): string {
  542. const map: Record<string, string> = { dks: '待开始', jxz: '进行中', ywc: '已完成', yzf: '已作废' }
  543. return map[status] || status || '-'
  544. }
  545. export function applicationStatusTagType(
  546. status: string
  547. ): '' | 'success' | 'warning' | 'danger' | 'info' {
  548. const map: Record<string, '' | 'success' | 'warning' | 'danger' | 'info'> = {
  549. dks: 'info',
  550. jxz: 'warning',
  551. ywc: 'success',
  552. yzf: 'danger'
  553. }
  554. return map[status] || 'info'
  555. }
  556. // ========== 中试服务体检状态 ==========
  557. export function checkupStatusLabel(status: string): string {
  558. const map: Record<string, string> = {
  559. dtj: '待体检',
  560. ytj: '已体检'
  561. }
  562. return map[status] || status || '-'
  563. }
  564. export function checkupStatusTagType(status: string): string {
  565. const map: Record<string, string> = {
  566. dtj: 'warning',
  567. ytj: 'success'
  568. }
  569. return map[status] || 'info'
  570. }
  571. export function feeStatusLabel(status: string): string {
  572. const map: Record<string, string> = {
  573. wjs: '未结算',
  574. yjs: '已结算'
  575. }
  576. return map[status] || status || '-'
  577. }
  578. export function feeStatusTagType(status: string): string {
  579. const map: Record<string, string> = {
  580. wjs: 'info',
  581. yjs: 'success'
  582. }
  583. return map[status] || 'info'
  584. }
  585. // ========== 中试服务 - 输注计划状态 ==========
  586. export function scheduleStatusLabel(status: string): string {
  587. const map: Record<string, string> = {
  588. dsc: '待生产',
  589. ysc: '已生产',
  590. yjf: '已交付',
  591. yqx: '已取消'
  592. }
  593. return map[status] || status || '-'
  594. }
  595. export function scheduleStatusTagType(status: string): string {
  596. const map: Record<string, string> = {
  597. dsc: 'info',
  598. ysc: 'primary',
  599. yjf: 'success',
  600. yqx: 'danger'
  601. }
  602. return map[status] || 'info'
  603. }
  604. // ========== 中试服务 - 输注状态 ==========
  605. export function infusionStatusLabel(status: string): string {
  606. const map: Record<string, string> = {
  607. dtz: '待输注',
  608. yrqr: '已用户确认',
  609. yqx: '已取消',
  610. ywc: '已完成'
  611. }
  612. return map[status] || status || '-'
  613. }
  614. export function infusionStatusTagType(status: string): string {
  615. const map: Record<string, string> = {
  616. dtz: 'info',
  617. yrqr: 'warning',
  618. yqx: 'danger',
  619. ywc: 'success'
  620. }
  621. return map[status] || 'info'
  622. }
  623. // ========== 中试服务 - 输注方式(字典 szfs) ==========
  624. export function infusionMethodLabel(method: string): string {
  625. const map: Record<string, string> = {
  626. jmsz: '静脉输注',
  627. pxzs: '皮下注射',
  628. jbzs: '局部注射',
  629. qt: '其他'
  630. }
  631. return map[method] || method || '—'
  632. }
  633. // ========== 中试服务 - 质检状态 ==========
  634. export function qcStatusLabel(status: string): string {
  635. const map: Record<string, string> = { dzc: '待质检', yzj: '已质检', yqx: '已取消' }
  636. return map[status] || status || '-'
  637. }
  638. export function qcStatusTagType(status: string): string {
  639. const map: Record<string, string> = { dzc: 'info', yzj: 'success', yqx: 'danger' }
  640. return map[status] || 'info'
  641. }
  642. // ========== 中试服务 - 放行审核结论 ==========
  643. export function releaseReviewConclusionLabel(conclusion: string): string {
  644. const map: Record<string, string> = { tg: '通过', btg: '不通过' }
  645. return map[conclusion] || conclusion || '-'
  646. }
  647. export function releaseReviewConclusionTagType(conclusion: string): string {
  648. const map: Record<string, string> = { tg: 'success', btg: 'danger' }
  649. return map[conclusion] || 'info'
  650. }
  651. // ========== 中试服务 - 业务类型 ==========
  652. export function bizTypeLabel(type: string): string {
  653. const map: Record<string, string> = {
  654. pilot_service: '中试服务',
  655. clinical_application: '临床应用',
  656. basic_experiment: '基础实验'
  657. }
  658. return map[type] || type || '-'
  659. }
  660. export function bizTypeTagType(type: string): string {
  661. const map: Record<string, string> = {
  662. pilot_service: 'primary',
  663. clinical_application: 'warning',
  664. basic_experiment: 'primary'
  665. }
  666. return map[type] || 'info'
  667. }
  668. // ========== 中试服务 - 产品状态 ==========
  669. export function productStatusLabel(status: string, bizType?: string): string {
  670. const isBasicExperiment = bizType === 'basic_experiment'
  671. const map: Record<string, string> = {
  672. dtz: isBasicExperiment ? '待交付' : '待输注',
  673. yrqr: '已用户确认',
  674. yqx: '已取消',
  675. ywc: '已完成'
  676. }
  677. return map[status] || status || '-'
  678. }
  679. export function productStatusTagType(status: string): string {
  680. const map: Record<string, string> = {
  681. dtz: 'info',
  682. yrqr: 'warning',
  683. yqx: 'danger',
  684. ywc: 'success'
  685. }
  686. return map[status] || 'info'
  687. }
  688. // ========== 设备管理 - 设备状态 ==========
  689. export const equipmentStatus: StatusRegistry = {
  690. '1': { label: '正常', tagType: 'success' },
  691. '0': { label: '异常', tagType: 'danger' }
  692. }
  693. export const equipmentStatusLabel = createLabelGetter(equipmentStatus)
  694. export const equipmentStatusTagType = createTagTypeGetter(equipmentStatus)
  695. // ========== 洁净服管理 - 洁净服状态 ==========
  696. export const garmentStatus: StatusRegistry = {
  697. zc: { label: '正常', tagType: 'success' },
  698. yfq: { label: '已废弃', tagType: 'info' }
  699. }
  700. export const garmentStatusLabel = createLabelGetter(garmentStatus)
  701. export const garmentStatusTagType = createTagTypeGetter(garmentStatus)
  702. // ========== 细胞产品库 - 产品状态 ==========
  703. export function cellProductStatusLabel(status: string): string {
  704. const map: Record<string, string> = {
  705. frozen: '已冻存',
  706. in_production: '生产中',
  707. sold: '已售卖',
  708. used: '已使用',
  709. voided: '已作废',
  710. thawed: '已复苏'
  711. }
  712. return map[status] || status || '—'
  713. }
  714. export function cellProductStatusTagType(status: string): string {
  715. const map: Record<string, string> = {
  716. frozen: 'success',
  717. in_production: 'warning',
  718. sold: 'warning',
  719. used: 'info',
  720. voided: 'danger',
  721. thawed: 'info'
  722. }
  723. return map[status] || 'info'
  724. }
  725. /** 细胞产品库状态码(出库物料「出库细胞」台账快照) */
  726. const CELL_PRODUCT_STATUS_CODES = new Set([
  727. 'frozen',
  728. 'in_production',
  729. 'sold',
  730. 'used',
  731. 'voided',
  732. 'thawed'
  733. ])
  734. /** 输注/交付计划产品状态码 */
  735. const SCHEDULE_PRODUCT_STATUS_CODES = new Set(['dtz', 'yrqr', 'yqx', 'ywc'])
  736. const LEGACY_SCHEDULE_PRODUCT_STATUS: Record<string, string> = {
  737. 待输注: 'dtz',
  738. 已用户确认: 'yrqr',
  739. 已取消: 'yqx',
  740. 已完成: 'ywc'
  741. }
  742. function normalizeScheduleProductStatusCode(status: string): string {
  743. const code = (status || '').trim()
  744. return LEGACY_SCHEDULE_PRODUCT_STATUS[code] || code
  745. }
  746. /**
  747. * 出库物料「出库细胞」状态展示:优先细胞产品库状态,兼容计划产品状态码与历史中文值。
  748. */
  749. export function outboundMaterialCellStatusLabel(status: string, bizType?: string): string {
  750. const code = (status || '').trim()
  751. if (!code) return '—'
  752. if (CELL_PRODUCT_STATUS_CODES.has(code)) {
  753. return cellProductStatusLabel(code)
  754. }
  755. const normalized = normalizeScheduleProductStatusCode(code)
  756. if (SCHEDULE_PRODUCT_STATUS_CODES.has(normalized)) {
  757. return productStatusLabel(normalized, bizType)
  758. }
  759. return cellProductStatusLabel(code)
  760. }
  761. export function outboundMaterialCellStatusTagType(status: string, bizType?: string): TagType {
  762. const code = (status || '').trim()
  763. if (!code) return 'info'
  764. if (CELL_PRODUCT_STATUS_CODES.has(code)) {
  765. return cellProductStatusTagType(code) as TagType
  766. }
  767. const normalized = normalizeScheduleProductStatusCode(code)
  768. if (SCHEDULE_PRODUCT_STATUS_CODES.has(normalized)) {
  769. return productStatusTagType(normalized) as TagType
  770. }
  771. return cellProductStatusTagType(code) as TagType
  772. }