/** * 数据域的人读短名 —— 左轨一枚钮只放得下 2-3 个字。 * * 域键是活动的复合键(`quote_intake`),给人看要翻译; * 字典之外的域回落到键的最后一段(截 4 字符)—— 新装的活动没配短名时,轨上先有个能认的名字。 */ export const DOMAIN_SHORT: Readonly> = { quote_intake: '受理', quote_sourcing: '寻源', quote_pricing: '定价', quote_negotiate: '议价', quote_alternative: '替代', shared: '共享', }; /** 业务序:受理 → 寻源 → 定价 → 议价 → 替代 → 共享 —— 左轨按流程走向排,不按字母 */ const DOMAIN_ORDER = ['quote_intake', 'quote_sourcing', 'quote_pricing', 'quote_negotiate', 'quote_alternative', 'shared']; export function sortDomains(domains: readonly string[]): string[] { return [...domains].sort((a, b) => { const ia = DOMAIN_ORDER.indexOf(a); const ib = DOMAIN_ORDER.indexOf(b); // 字典外的域排在已知域之后,彼此按键序稳定 if (ia === -1 && ib === -1) return a.localeCompare(b); if (ia === -1) return 1; if (ib === -1) return -1; return ia - ib; }); } export function domainShort(domain: string): string { const hit = DOMAIN_SHORT[domain]; if (hit !== undefined) return hit; const tail = domain.split('_').at(-1) ?? domain; return tail.length <= 4 ? tail : tail.slice(0, 4); }