export const PROCESSING_METHODS = ['原材料', '净菜', '切配', '熟食'] as const; /** 录单/OCR 常用标准加工方式(与 orderParseService 对齐) */ export const STANDARD_PROCESSING_METHODS = [ '砍', '去皮', '切片', '切块', '切丝', '切段', '切丁', '清洗', '洗净', '打包', '分装', '净菜', '剁碎', '去根', '去叶', ] as const; export type ProcessingMethod = (typeof PROCESSING_METHODS)[number]; export type ProcessingAlias = { alias_name: string; processing_method: string; }; function normalizeText(value: string): string { return (value || '').trim().toLowerCase(); } export function resolveProcessingMethodFromAlias( raw: string, aliases: ProcessingAlias[], ): string { const trimmed = (raw || '').trim(); if (!trimmed) return '原材料'; const direct = PROCESSING_METHODS.find((m) => m === trimmed); if (direct) return direct; const aliasMatch = aliases.find( (item) => normalizeText(item.alias_name) === normalizeText(trimmed), ); if (aliasMatch) return aliasMatch.processing_method; if (trimmed.includes('切')) return '净菜'; if (trimmed.includes('丁') || trimmed.includes('块') || trimmed.includes('片') || trimmed.includes('丝')) { return '切配'; } if (trimmed.includes('卤') || trimmed.includes('熟')) return '熟食'; if (trimmed.includes('加') || trimmed.includes('工')) return '切配'; return '原材料'; } /** 订单管理详情加工方式下拉(含库内已有自定义值时由调用方补一项) */ export const ORDER_MANAGE_PROCESSING_METHOD_OPTIONS: string[] = Array.from( new Set(['原材料', ...PROCESSING_METHODS, ...STANDARD_PROCESSING_METHODS]) ); export function orderManageProcessingMethodSelectOptions(current?: string | null): Array<{ value: string; label: string; }> { const values = [...ORDER_MANAGE_PROCESSING_METHOD_OPTIONS]; const cur = String(current || '').trim(); if (cur && !values.includes(cur)) values.push(cur); return values.map((value) => ({ value, label: value })); }