DG7/MRF7 移动信息架构与展示去重治理
这个提交包含在:
@@ -0,0 +1,56 @@
|
||||
import { isUuidLike } from "./reimbursementDisplay";
|
||||
|
||||
export type BusinessEntityType = "reimbursement" | "leave" | "purchase_request" | "travel_request" | string | null | undefined;
|
||||
|
||||
const ENTITY_NOUN_LABELS: Record<string, string> = {
|
||||
reimbursement: "报销单",
|
||||
leave: "请假",
|
||||
purchase_request: "采购单",
|
||||
travel_request: "差旅单",
|
||||
};
|
||||
|
||||
const ENTITY_SHORT_LABELS: Record<string, string> = {
|
||||
reimbursement: "报销",
|
||||
leave: "请假",
|
||||
purchase_request: "采购",
|
||||
travel_request: "差旅",
|
||||
};
|
||||
|
||||
export function businessEntityLabel(entityType: BusinessEntityType, options: { noun?: boolean } = {}) {
|
||||
if (!entityType) {
|
||||
return options.noun ? "业务单据" : "业务";
|
||||
}
|
||||
const labels = options.noun ? ENTITY_NOUN_LABELS : ENTITY_SHORT_LABELS;
|
||||
return labels[entityType] ?? String(entityType);
|
||||
}
|
||||
|
||||
export function compactBusinessReference(value: string | null | undefined) {
|
||||
const trimmed = value?.trim();
|
||||
if (!trimmed || isUuidLike(trimmed)) {
|
||||
return null;
|
||||
}
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
export function businessPrimaryLabel(input: {
|
||||
entityType: BusinessEntityType;
|
||||
reference?: string | null;
|
||||
title?: string | null;
|
||||
fallback?: string;
|
||||
}) {
|
||||
const reference = compactBusinessReference(input.reference);
|
||||
if (reference) {
|
||||
return `${businessEntityLabel(input.entityType, { noun: true })} ${reference}`;
|
||||
}
|
||||
|
||||
const title = input.title?.trim();
|
||||
if (title && !isUuidLike(title)) {
|
||||
return title;
|
||||
}
|
||||
|
||||
return input.fallback ?? businessEntityLabel(input.entityType, { noun: true });
|
||||
}
|
||||
|
||||
export function joinBusinessMeta(items: Array<string | null | undefined>) {
|
||||
return items.map((item) => item?.trim()).filter((item): item is string => Boolean(item)).join(" · ");
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户