| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579 |
- /**
- * 状态标签注册表 — 全局集中定义所有枚举字段的 label + tagType
- *
- * 使用方式:
- * import { protocolStatusLabel, protocolStatusTagType } from '@/utils/status-tag-registry'
- * <el-tag :type="protocolStatusTagType(row.status)">{{ protocolStatusLabel(row.status) }}</el-tag>
- *
- * 规范:同一枚举值在任何地方(表格、查看弹窗、导出)颜色必须一致。
- * tagType 语义色:success=正常/已完成, warning=进行中/已过期, danger=异常/已作废,
- * info=待执行/停用, primary=特殊分类/转出, ''=默认
- */
- // ── 类型定义 ──────────────────────────────────────────────────────────────────
- /** el-tag 的 type 属性值 */
- export type TagType = 'success' | 'warning' | 'danger' | 'info' | '' | 'primary'
- /** 单条枚举映射 */
- export interface StatusItem {
- label: string
- tagType: TagType
- }
- /** 注册表类型 */
- export type StatusRegistry = Record<string, StatusItem>
- // ── 工厂函数 ──────────────────────────────────────────────────────────────────
- function createLabelGetter(registry: StatusRegistry) {
- return (code: string): string => registry[code]?.label ?? code ?? '—'
- }
- function createTagTypeGetter(registry: StatusRegistry) {
- return (code: string): TagType => registry[code]?.tagType ?? 'info'
- }
- // ══════════════════════════════════════════════════════════════════════════════
- // 协议 / 存储 域
- // ══════════════════════════════════════════════════════════════════════════════
- export const protocolStatus: StatusRegistry = {
- dsx: { label: '待生效', tagType: 'info' },
- sxz: { label: '生效中', tagType: 'success' },
- ygq: { label: '已过期', tagType: 'warning' },
- yzf: { label: '已作废', tagType: 'danger' },
- zky: { label: '转科研', tagType: 'primary' }
- }
- export const protocolStatusLabel = createLabelGetter(protocolStatus)
- export const protocolStatusTagType = createTagTypeGetter(protocolStatus)
- export const donationStatus: StatusRegistry = {
- dsx: { label: '待生效', tagType: 'info' },
- sxz: { label: '生效中', tagType: 'success' },
- ygq: { label: '已过期', tagType: 'warning' },
- yzf: { label: '已作废', tagType: 'danger' },
- zckc: { label: '转细胞存储', tagType: 'primary' }
- }
- export const donationStatusLabel = createLabelGetter(donationStatus)
- export const donationStatusTagType = createTagTypeGetter(donationStatus)
- export const sampleStatus: StatusRegistry = {
- ycj: { label: '已采集', tagType: 'primary' },
- jcz: { label: '检测中', tagType: 'warning' },
- yrk: { label: '已入库', tagType: 'success' },
- yzf: { label: '已作废', tagType: 'danger' }
- }
- export const sampleStatusLabel = createLabelGetter(sampleStatus)
- export const sampleStatusTagType = createTagTypeGetter(sampleStatus)
- export const payStatus: StatusRegistry = {
- dfj: { label: '待缴费', tagType: 'info' },
- jfqrz: { label: '缴费确认中', tagType: 'warning' },
- yjf: { label: '已缴费', tagType: 'success' },
- tfqrz: { label: '退费确认中', tagType: 'warning' },
- ytf: { label: '已退费', tagType: 'danger' }
- }
- export const payStatusLabel = createLabelGetter(payStatus)
- export const payStatusTagType = createTagTypeGetter(payStatus)
- export const auditStatus: StatusRegistry = {
- shtg: { label: '审核通过', tagType: 'success' },
- shth: { label: '审核退回', tagType: 'danger' }
- }
- export const auditStatusLabel = createLabelGetter(auditStatus)
- export const auditStatusTagType = createTagTypeGetter(auditStatus)
- export const payMode: StatusRegistry = {
- dj: { label: '趸交', tagType: 'info' },
- fq: { label: '分期', tagType: 'warning' }
- }
- export const payModeLabel = createLabelGetter(payMode)
- export const payModeTagType = createTagTypeGetter(payMode)
- export const transferType: StatusRegistry = {
- wxzz: { label: '微信转账', tagType: 'success' },
- zzbzz: { label: '支付宝转账', tagType: 'primary' },
- yhkzz: { label: '银行卡转账', tagType: 'info' },
- xj: { label: '现金', tagType: 'warning' }
- }
- export const transferTypeLabel = createLabelGetter(transferType)
- export const transferTypeTagType = createTagTypeGetter(transferType)
- export const transportType: StatusRegistry = {
- kdys: { label: '快递运输', tagType: 'info' },
- ryxd: { label: '人员携带', tagType: 'success' }
- }
- export const transportTypeLabel = createLabelGetter(transportType)
- export const transportTypeTagType = createTagTypeGetter(transportType)
- export const receptionSource: StatusRegistry = {
- cell_storage: { label: '细胞存储', tagType: 'primary' },
- research_donation: { label: '科研捐赠', tagType: 'warning' },
- outbound: { label: '出库', tagType: 'primary' },
- pilot_service: { label: '中试服务', tagType: 'primary' },
- clinical_application: { label: '临床应用', tagType: 'warning' }
- }
- export const receptionSourceLabel = createLabelGetter(receptionSource)
- export const receptionSourceTagType = createTagTypeGetter(receptionSource)
- export const newbornSex: StatusRegistry = {
- '1': { label: '男', tagType: 'primary' },
- '0': { label: '女', tagType: 'success' }
- }
- export const newbornSexLabel = createLabelGetter(newbornSex)
- export const newbornSexTagType = createTagTypeGetter(newbornSex)
- export const deliveryMode: StatusRegistry = {
- sc: { label: '顺产', tagType: 'info' },
- pgc: { label: '剖宫产', tagType: 'warning' }
- }
- export const deliveryModeLabel = createLabelGetter(deliveryMode)
- export const deliveryModeTagType = createTagTypeGetter(deliveryMode)
- export const sourceType: StatusRegistry = {
- direct: { label: '独立新建', tagType: 'info' },
- from_storage: { label: '从存储转来', tagType: 'primary' }
- }
- export const sourceTypeLabel = createLabelGetter(sourceType)
- export const sourceTypeTagType = createTagTypeGetter(sourceType)
- // ══════════════════════════════════════════════════════════════════════════════
- // 质检域
- // ══════════════════════════════════════════════════════════════════════════════
- export const qcBizType: StatusRegistry = {
- inbound: { label: '入库质检', tagType: 'success' },
- outbound: { label: '出库质检', tagType: 'primary' },
- temporary: { label: '临时质检', tagType: 'warning' }
- }
- export const qcBizTypeLabel = createLabelGetter(qcBizType)
- export const qcBizTypeTagType = createTagTypeGetter(qcBizType)
- export const workOrderStatus: StatusRegistry = {
- dpz: { label: '待配置', tagType: 'info' },
- ypz: { label: '已配置', tagType: 'success' },
- ywc: { label: '已完成', tagType: 'success' },
- yzf: { label: '已作废', tagType: 'danger' }
- }
- export const workOrderStatusLabel = createLabelGetter(workOrderStatus)
- export const workOrderStatusTagType = createTagTypeGetter(workOrderStatus)
- export const taskType: StatusRegistry = {
- sysz: { label: '实验室自检', tagType: 'info' },
- dsfjc: { label: '第三方检测', tagType: 'primary' }
- }
- export const taskTypeLabel = createLabelGetter(taskType)
- export const taskTypeTagType = createTagTypeGetter(taskType)
- export const qcConclusion: StatusRegistry = {
- tg: { label: '通过', tagType: 'success' },
- btg: { label: '不通过', tagType: 'danger' }
- }
- export const qcTaskConclusionLabel = createLabelGetter(qcConclusion)
- export const qcTaskConclusionTagType = createTagTypeGetter(qcConclusion)
- export const taskStatus: StatusRegistry = {
- dzx: { label: '待执行', tagType: 'info' },
- jxz: { label: '进行中', tagType: 'warning' },
- ywc: { label: '已完成', tagType: 'success' }
- }
- export const taskStatusLabel = createLabelGetter(taskStatus)
- export const taskStatusTagType = createTagTypeGetter(taskStatus)
- export const acceptConclusion: StatusRegistry = {
- js: { label: '接收', tagType: 'success' },
- bj: { label: '拒收', tagType: 'danger' }
- }
- export const acceptConclusionLabel = createLabelGetter(acceptConclusion)
- export const acceptConclusionTagType = createTagTypeGetter(acceptConclusion)
- // ══════════════════════════════════════════════════════════════════════════════
- // 渠道域
- // ══════════════════════════════════════════════════════════════════════════════
- export const channelType: StatusRegistry = {
- yy: { label: '医院', tagType: 'primary' },
- hzjg: { label: '合作机构', tagType: 'success' },
- zs: { label: '诊所', tagType: 'warning' },
- zfjg: { label: '政府机构', tagType: 'danger' },
- qt: { label: '其他', tagType: 'info' }
- }
- export const channelTypeLabel = createLabelGetter(channelType)
- export const channelTypeTagType = createTagTypeGetter(channelType)
- export const agreementType: StatusRegistry = {
- kyxy: { label: '框架协议', tagType: 'primary' },
- zsxy: { label: '中试协议', tagType: 'success' },
- lcxy: { label: '临床协议', tagType: 'warning' }
- }
- export const agreementTypeLabel = createLabelGetter(agreementType)
- export const agreementTypeTagType = createTagTypeGetter(agreementType)
- export const agreementStatus: StatusRegistry = {
- dsx: { label: '待生效', tagType: 'info' },
- sxz: { label: '生效中', tagType: 'success' },
- yzf: { label: '已作废', tagType: 'danger' }
- }
- export const agreementStatusLabel = createLabelGetter(agreementStatus)
- export const agreementStatusTagType = createTagTypeGetter(agreementStatus)
- export const settlementType: StatusRegistry = {
- yj: { label: '月结', tagType: '' },
- jj: { label: '季结', tagType: 'success' },
- nj: { label: '年结', tagType: 'warning' },
- dcjs: { label: '单次结算', tagType: 'danger' }
- }
- export const settlementTypeLabel = createLabelGetter(settlementType)
- export const settlementTypeTagType = createTagTypeGetter(settlementType)
- // ══════════════════════════════════════════════════════════════════════════════
- // 订单域
- // ══════════════════════════════════════════════════════════════════════════════
- export const orderStatus: StatusRegistry = {
- pending_payment: { label: '待支付', tagType: 'warning' },
- pending_confirm: { label: '待收货', tagType: 'info' },
- completed: { label: '已完成', tagType: 'success' },
- cancelled: { label: '已取消', tagType: 'danger' }
- }
- export const orderStatusLabel = createLabelGetter(orderStatus)
- export const orderStatusTagType = createTagTypeGetter(orderStatus)
- export const deliveryStatusMap: StatusRegistry = {
- pending_dispatch: { label: '待分配配送', tagType: 'info' },
- delivering: { label: '配送中', tagType: 'warning' },
- delivered: { label: '配送完成', tagType: 'success' }
- }
- export const deliveryStatusLabel = createLabelGetter(deliveryStatusMap)
- export const deliveryStatusTagType = createTagTypeGetter(deliveryStatusMap)
- export const paymentMethod: StatusRegistry = {
- online: { label: '线上支付', tagType: 'success' },
- offline: { label: '线下支付', tagType: 'info' }
- }
- export const paymentMethodLabel = createLabelGetter(paymentMethod)
- export const paymentMethodTagType = createTagTypeGetter(paymentMethod)
- export const orderPayStatus: StatusRegistry = {
- pending_payment: { label: '待支付', tagType: 'warning' },
- paid: { label: '已支付', tagType: 'success' }
- }
- export const orderPayStatusLabel = createLabelGetter(orderPayStatus)
- export const orderPayStatusTagType = createTagTypeGetter(orderPayStatus)
- // ══════════════════════════════════════════════════════════════════════════════
- // 系统 / 通用域
- // ══════════════════════════════════════════════════════════════════════════════
- /** 通用启用/停用(数据库 status 字段 1/0) */
- export const enableStatus: StatusRegistry = {
- '1': { label: '正常', tagType: 'success' },
- '0': { label: '停用', tagType: 'danger' }
- }
- export const enableStatusLabel = createLabelGetter(enableStatus)
- export const enableStatusTagType = createTagTypeGetter(enableStatus)
- /** 性别(客户等业务表) */
- export const sex: StatusRegistry = {
- '0': { label: '男', tagType: 'primary' },
- '1': { label: '女', tagType: 'success' }
- }
- export const sexLabel = createLabelGetter(sex)
- export const sexTagType = createTagTypeGetter(sex)
- /** 请假状态 */
- export const leaveStatus: StatusRegistry = {
- draft: { label: '草稿', tagType: 'info' },
- pending: { label: '审批中', tagType: 'warning' },
- approved: { label: '已通过', tagType: 'success' },
- rejected: { label: '已驳回', tagType: 'danger' },
- cancelled: { label: '已取消', tagType: 'info' }
- }
- export const leaveStatusLabel = createLabelGetter(leaveStatus)
- export const leaveStatusTagType = createTagTypeGetter(leaveStatus)
- /** 数据权限范围 */
- export const dataScope: StatusRegistry = {
- '1': { label: '全部数据', tagType: '' },
- '2': { label: '本部门数据', tagType: 'info' },
- '3': { label: '本部门及以下', tagType: 'info' },
- '4': { label: '仅本人', tagType: 'warning' },
- '5': { label: '自定义', tagType: 'primary' }
- }
- export const dataScopeLabel = createLabelGetter(dataScope)
- export const dataScopeTagType = createTagTypeGetter(dataScope)
- /** 洁净室等级 */
- export const cleanRoomGrade: StatusRegistry = {
- A: { label: 'A级', tagType: 'warning' },
- B: { label: 'B级', tagType: '' },
- C: { label: 'C级', tagType: 'info' },
- D: { label: 'D级', tagType: 'info' }
- }
- export const cleanRoomGradeLabel = createLabelGetter(cleanRoomGrade)
- export const cleanRoomGradeTagType = createTagTypeGetter(cleanRoomGrade)
- /** 样本编码类型 */
- export const sampleCodeType: StatusRegistry = {
- zxbm: { label: '造血编码', tagType: 'info' },
- qdbm: { label: '脐带编码', tagType: 'primary' }
- }
- export const sampleCodeTypeLabel = createLabelGetter(sampleCodeType)
- export const sampleCodeTypeTagType = createTagTypeGetter(sampleCodeType)
- /** 耗材包类型 */
- export const packType: StatusRegistry = {
- bzhcb: { label: '标准耗材包', tagType: 'primary' },
- zdyhcb: { label: '自定义耗材包', tagType: 'warning' }
- }
- export const packTypeLabel = createLabelGetter(packType)
- export const packTypeTagType = createTagTypeGetter(packType)
- // ══════════════════════════════════════════════════════════════════════════════
- // 入库放行审核域
- // ══════════════════════════════════════════════════════════════════════════════
- export const storageReleaseConclusion: StatusRegistry = {
- tg: { label: '通过', tagType: 'success' },
- btg: { label: '不通过', tagType: 'danger' }
- }
- export const storageReleaseConclusionLabel = createLabelGetter(storageReleaseConclusion)
- export const storageReleaseConclusionTagType = createTagTypeGetter(storageReleaseConclusion)
- export const storageStatus: StatusRegistry = {
- drk: { label: '待入库', tagType: 'warning' },
- yrk: { label: '已入库', tagType: 'success' }
- }
- export const storageStatusLabel = createLabelGetter(storageStatus)
- export const storageStatusTagType = createTagTypeGetter(storageStatus)
- // ══════════════════════════════════════════════════════════════════════════════
- // 渠道服务订单域
- // ══════════════════════════════════════════════════════════════════════════════
- /** 渠道服务订单类型 */
- export const channelServiceOrderType: StatusRegistry = {
- yfk: { label: '预付款充值', tagType: 'primary' },
- gmcp: { label: '购买产品份数', tagType: 'success' }
- }
- export const channelServiceOrderTypeLabel = createLabelGetter(channelServiceOrderType)
- export const channelServiceOrderTypeTagType = createTagTypeGetter(channelServiceOrderType)
- /** 渠道服务订单状态 */
- export const channelServiceOrderStatus: StatusRegistry = {
- dsx: { label: '待生效', tagType: 'info' },
- dqr: { label: '待确认', tagType: 'warning' },
- yqr: { label: '已确认', tagType: 'success' },
- sxz: { label: '生效中', tagType: 'success' },
- tfqrz: { label: '退款确认中', tagType: 'danger' },
- ytf: { label: '已退款', tagType: 'info' },
- yzf: { label: '已作废', tagType: 'info' }
- }
- export const channelServiceOrderStatusLabel = createLabelGetter(channelServiceOrderStatus)
- export const channelServiceOrderStatusTagType = createTagTypeGetter(channelServiceOrderStatus)
- // ══════════════════════════════════════════════════════════════════════════════
- // 流水域
- // ══════════════════════════════════════════════════════════════════════════════
- // 流水类型
- export const txnTypeLabel = (type: string): string => {
- const map: Record<string, string> = {
- recharge: '充值',
- refund: '退款',
- purchase: '购买产品',
- unsubscribe: '退订产品',
- settlement: '输注结算'
- }
- return map[type] || type
- }
- export const txnTypeTagType = (type: string): string => {
- const map: Record<string, string> = {
- recharge: '',
- refund: 'danger',
- purchase: 'success',
- unsubscribe: 'warning',
- settlement: 'primary'
- }
- return map[type] || 'info'
- }
- // 流水状态
- export const txnStatusLabel = (status: string): string => {
- const map: Record<string, string> = {
- dsx: '待生效',
- dqr: '待财务确认',
- yqr: '已确认',
- yzf: '已作废'
- }
- return map[status] || status
- }
- export const txnStatusTagType = (status: string): string => {
- const map: Record<string, string> = {
- dsx: 'info',
- dqr: 'warning',
- yqr: 'success',
- yzf: 'danger'
- }
- return map[status] || 'info'
- }
- /** 中试申请单状态 */
- export function applicationStatusLabel(status: string): string {
- const map: Record<string, string> = { dks: '待开始', jxz: '进行中', ywc: '已完成', yzf: '已作废' }
- return map[status] || status || '-'
- }
- export function applicationStatusTagType(
- status: string
- ): '' | 'success' | 'warning' | 'danger' | 'info' {
- const map: Record<string, '' | 'success' | 'warning' | 'danger' | 'info'> = {
- dks: 'info',
- jxz: 'warning',
- ywc: 'success',
- yzf: 'danger'
- }
- return map[status] || 'info'
- }
- // ========== 中试服务体检状态 ==========
- export function checkupStatusLabel(status: string): string {
- const map: Record<string, string> = {
- dtj: '待体检',
- ytj: '已体检'
- }
- return map[status] || status || '-'
- }
- export function checkupStatusTagType(status: string): string {
- const map: Record<string, string> = {
- dtj: 'warning',
- ytj: 'success'
- }
- return map[status] || 'info'
- }
- export function feeStatusLabel(status: string): string {
- const map: Record<string, string> = {
- wjs: '未结算',
- yjs: '已结算'
- }
- return map[status] || status || '-'
- }
- export function feeStatusTagType(status: string): string {
- const map: Record<string, string> = {
- wjs: 'info',
- yjs: 'success'
- }
- return map[status] || 'info'
- }
- // ========== 中试服务 - 输注计划状态 ==========
- export function scheduleStatusLabel(status: string): string {
- const map: Record<string, string> = {
- dsc: '待生产',
- ysc: '已生产',
- yjf: '已交付',
- yqx: '已取消'
- }
- return map[status] || status || '-'
- }
- export function scheduleStatusTagType(status: string): string {
- const map: Record<string, string> = {
- dsc: 'info',
- ysc: 'primary',
- yjf: 'success',
- yqx: 'danger'
- }
- return map[status] || 'info'
- }
- // ========== 中试服务 - 输注状态 ==========
- export function infusionStatusLabel(status: string): string {
- const map: Record<string, string> = {
- dtz: '待输注',
- yrqr: '已用户确认',
- yqx: '已取消',
- ywc: '已完成'
- }
- return map[status] || status || '-'
- }
- export function infusionStatusTagType(status: string): string {
- const map: Record<string, string> = {
- dtz: 'info',
- yrqr: 'warning',
- yqx: 'danger',
- ywc: 'success'
- }
- return map[status] || 'info'
- }
- // ========== 中试服务 - 输注方式(字典 szfs) ==========
- export function infusionMethodLabel(method: string): string {
- const map: Record<string, string> = {
- jmsz: '静脉输注',
- pxzs: '皮下注射',
- jbzs: '局部注射',
- qt: '其他'
- }
- return map[method] || method || '—'
- }
- // ========== 中试服务 - 质检状态 ==========
- export function qcStatusLabel(status: string): string {
- const map: Record<string, string> = { dzc: '待质检', yzj: '已质检', yqx: '已取消' }
- return map[status] || status || '-'
- }
- export function qcStatusTagType(status: string): string {
- const map: Record<string, string> = { dzc: 'info', yzj: 'success', yqx: 'danger' }
- return map[status] || 'info'
- }
- // ========== 中试服务 - 放行审核结论 ==========
- export function releaseReviewConclusionLabel(conclusion: string): string {
- const map: Record<string, string> = { tg: '通过', btg: '不通过' }
- return map[conclusion] || conclusion || '-'
- }
- export function releaseReviewConclusionTagType(conclusion: string): string {
- const map: Record<string, string> = { tg: 'success', btg: 'danger' }
- return map[conclusion] || 'info'
- }
- // ========== 中试服务 - 业务类型 ==========
- export function bizTypeLabel(type: string): string {
- const map: Record<string, string> = {
- pilot_service: '中试服务',
- clinical_application: '临床应用'
- }
- return map[type] || type || '-'
- }
- export function bizTypeTagType(type: string): string {
- const map: Record<string, string> = {
- pilot_service: 'primary',
- clinical_application: 'warning'
- }
- return map[type] || 'info'
- }
- // ========== 中试服务 - 产品状态 ==========
- export function productStatusLabel(status: string): string {
- const map: Record<string, string> = {
- dtz: '待输注',
- yrqr: '已用户确认',
- yqx: '已取消',
- ywc: '已完成'
- }
- return map[status] || status || '-'
- }
- export function productStatusTagType(status: string): string {
- const map: Record<string, string> = {
- dtz: 'info',
- yrqr: 'warning',
- yqx: 'danger',
- ywc: 'success'
- }
- return map[status] || 'info'
- }
|