This commit is contained in:
zlwu committed 2026-05-19 23:12:56 +08:00
1 parent 93cd506a90
commit 3b875ec370
93 files changed
+11514 -2304

No files matched your search

+10 -39
View File
@@ -1,40 +1,13 @@
export function protocolStatusLabel(s: string) {
const map: Record<string, string> = {
dsx: '待生效',
sxz: '生效中',
ygq: '已过期',
yzf: '已作废',
zky: '转科研'
}
return map[s] || s || '-'
}
export function payModeLabel(s: string) {
if (s === 'dj') return '趸交'
if (s === 'fq') return '分期'
return s || '-'
}
export function payStatusLabel(s: string) {
const map: Record<string, string> = {
dfj: '待缴费',
jfqrz: '缴费确认中',
yjf: '已缴费',
tfqrz: '退费确认中',
ytf: '已退费'
}
return map[s] || '未知'
}
export function transferTypeLabel(t: string) {
const map: Record<string, string> = {
wxzz: '微信转账',
zzbzz: '支付宝转账',
yhkzz: '银行卡转账',
xj: '现金'
}
return map[t] || t || '-'
}
export {
protocolStatusLabel,
protocolStatusTagType,
payStatusLabel,
payStatusTagType,
payModeLabel,
payModeTagType,
transferTypeLabel,
transferTypeTagType
} from './status-tag-registry'
export function formatPaymentDueDate(d: unknown) {
const s = String(d || '')
@@ -43,7 +16,6 @@ export function formatPaymentDueDate(d: unknown) {
return s
}
/** 分期应缴预警天数(与分期预警规则一致:应缴日在当天起未来 N 天内,含逾期) */
export const PAYMENT_DUE_WARN_DAYS = 15
function parsePaymentDueYmd(ymd: unknown): Date | null {
@@ -61,7 +33,6 @@ function startOfLocalDay(d: Date) {
return new Date(d.getFullYear(), d.getMonth(), d.getDate())
}
/** 应缴日是否不晚于「今天 + warnDays」(含当天与已逾期) */
export function isPaymentDueWithinWarnWindow(
installmentDueDate: unknown,
warnDays = PAYMENT_DUE_WARN_DAYS
+18 -25
View File
@@ -1,25 +1,18 @@
export function workOrderStatusLabel(v: string) {
const m: Record<string, string> = {
dpz: '待配置',
ypz: '已配置',
ywc: '已完成'
}
return m[v] || v || '—'
}
export function taskTypeLabel(v: string) {
const m: Record<string, string> = {
sysz: '实验室自检',
dsfjc: '第三方检测'
}
return m[v] || v || '—'
}
export function taskStatusLabel(v: string) {
const m: Record<string, string> = {
dzx: '待执行',
jxz: '进行中',
ywc: '已完成'
}
return m[v] || v || '—'
}
export {
qcBizTypeLabel,
qcBizTypeTagType,
receptionSourceLabel,
receptionSourceTagType,
acceptConclusionLabel,
acceptConclusionTagType,
transportTypeLabel,
transportTypeTagType,
workOrderStatusLabel,
workOrderStatusTagType,
taskTypeLabel,
taskTypeTagType,
qcTaskConclusionLabel,
qcTaskConclusionTagType,
taskStatusLabel,
taskStatusTagType
} from './status-tag-registry'
+328
View File
@@ -0,0 +1,328 @@
/**
* 状态标签注册表 — 全局集中定义所有枚举字段的 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: 'success' }
}
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' }
}
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' }
}
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: 'info' },
zdyhcb: { label: '自定义耗材包', tagType: 'primary' }
}
export const packTypeLabel = createLabelGetter(packType)
export const packTypeTagType = createTagTypeGetter(packType)