数据字典集中治理

This commit is contained in:
Cheng Zhou
2025-12-17 20:58:42 +08:00
parent c2328594b0
commit b0bffbc75e
16 changed files with 170 additions and 39 deletions
+16
View File
@@ -0,0 +1,16 @@
import type { Dict } from "./types";
import { createDict } from "./utils";
const seriousnessItems = [
{ value: "NON_SERIOUS", label: "非严重", order: 1 },
{ value: "SERIOUS", label: "严重", order: 2, color: "danger" },
];
const severityItems = [
{ value: "MILD", label: "轻度", order: 1 },
{ value: "MODERATE", label: "中度", order: 2 },
{ value: "SEVERE", label: "重度", order: 3, color: "danger" },
];
export const aeSeriousnessDict: Dict = createDict(seriousnessItems);
export const aeSeverityDict: Dict = createDict(severityItems);
+13
View File
@@ -0,0 +1,13 @@
import type { Dict } from "./types";
import { createDict } from "./utils";
import { statusDict } from "./status.dict";
const categoryItems = [
{ value: "SITE_FEE", label: "中心费用", order: 1 },
{ value: "SUBJECT_FEE", label: "受试者费用", order: 2 },
{ value: "TRAVEL_FEE", label: "差旅费用", order: 3 },
{ value: "OTHER", label: "其他", order: 99 },
];
export const financeCategoryDict: Dict = createDict(categoryItems);
export const financeStatusDict = statusDict;
+12
View File
@@ -0,0 +1,12 @@
import type { Dict } from "./types";
import { createDict } from "./utils";
const transactionItems = [
{ value: "RECEIPT", label: "接收", order: 1 },
{ value: "DISPENSE", label: "发药", order: 2 },
{ value: "RETURN", label: "回收", order: 3 },
{ value: "DESTROY", label: "销毁", order: 4 },
{ value: "TRANSFER", label: "转移", order: 5 },
];
export const impTransactionTypeDict: Dict = createDict(transactionItems);
+8
View File
@@ -0,0 +1,8 @@
export * from "./types";
export * from "./utils";
export * from "./status.dict";
export * from "./priority.dict";
export * from "./role.dict";
export * from "./ae.dict";
export * from "./finance.dict";
export * from "./imp.dict";
@@ -0,0 +1,10 @@
import type { Dict } from "./types";
import { createDict } from "./utils";
const items = [
{ value: "LOW", label: "低", color: "info", order: 1 },
{ value: "MEDIUM", label: "中", color: "warning", order: 2 },
{ value: "HIGH", label: "高", color: "danger", order: 3 },
];
export const priorityDict: Dict = createDict(items);
+12
View File
@@ -0,0 +1,12 @@
import type { Dict } from "./types";
import { createDict } from "./utils";
const items = [
{ value: "ADMIN", label: "管理员", order: 1 },
{ value: "PM", label: "项目负责人", order: 2 },
{ value: "CRA", label: "CRA", order: 3 },
{ value: "PV", label: "PV", order: 4 },
{ value: "IMP", label: "药品管理员", order: 5 },
];
export const roleDict: Dict = createDict(items);
+24
View File
@@ -0,0 +1,24 @@
import type { Dict } from "./types";
import { createDict } from "./utils";
const items = [
{ value: "TODO", label: "待处理", color: "info", order: 1 },
{ value: "DOING", label: "进行中", color: "warning", order: 2 },
{ value: "DONE", label: "已完成", color: "success", order: 3 },
{ value: "BLOCKED", label: "阻塞", color: "danger", order: 4 },
{ value: "DRAFT", label: "草稿", color: "info", order: 10 },
{ value: "SUBMITTED", label: "已提交", color: "warning", order: 11 },
{ value: "APPROVED", label: "已审批", color: "success", order: 12 },
{ value: "REJECTED", label: "已驳回", color: "danger", order: 13 },
{ value: "PAID", label: "已支付", color: "success", order: 14 },
{ value: "CLOSED", label: "已关闭", color: "success", order: 20 },
{ value: "OPEN", label: "开放", color: "info", order: 19 },
{ value: "FOLLOW_UP", label: "随访中", color: "warning", order: 18 },
{ value: "OVERDUE", label: "已逾期", color: "danger", order: 30 },
{ value: "SCREENING", label: "筛选中", color: "info", order: 40 },
{ value: "ENROLLED", label: "已入组", color: "success", order: 41 },
{ value: "COMPLETED", label: "已完成", color: "success", order: 42 },
{ value: "DROPPED", label: "已脱落", color: "danger", order: 43 },
];
export const statusDict: Dict = createDict(items);
+13
View File
@@ -0,0 +1,13 @@
export interface DictItem {
value: string;
label: string;
color?: string;
order?: number;
description?: string;
}
export interface Dict {
items: DictItem[];
get: (value?: string | null) => DictItem | undefined;
list: () => DictItem[];
}
+15
View File
@@ -0,0 +1,15 @@
import type { Dict, DictItem } from "./types";
export const createDict = (items: DictItem[]): Dict => {
const normalized = items.map((item, idx) => ({ order: idx, ...item }));
const get = (value?: string | null) => normalized.find((i) => i.value === value);
const list = () =>
[...normalized].sort((a, b) => (a.order || 0) - (b.order || 0));
return { items: normalized, get, list };
};
export const getDictItem = (dict: Dict, value?: string | null) => dict.get(value);
export const getDictLabel = (dict: Dict, value?: string | null) => dict.get(value)?.label || value || "";
export const getDictColor = (dict: Dict, value?: string | null) => dict.get(value)?.color;
export const getDictOptions = (dict: Dict) =>
dict.list().map((i) => ({ label: i.label, value: i.value, disabled: false }));