优化展示

This commit is contained in:
2025-11-27 18:29:05 +08:00
parent aa50fdc9de
commit 1ddd3f8c90
2 changed files with 28 additions and 3 deletions

View File

@@ -79,6 +79,31 @@ export const StockLogSourceType = {
FERMENT_END: '发酵入库', // 发酵料产出,作为新原料计入库存
};
/**
* 根据库存变动来源的键或值获取其对应的中文标签。
* @param {string} sourceTypeKeyOrValue - 库存变动来源的键 (如 "PURCHASE") 或值 (如 "采购入库")。
* @returns {string} 对应的中文标签,如果未找到则返回 '--'。
*/
export function getStockLogSourceTypeLabel(sourceTypeKeyOrValue) {
if (!sourceTypeKeyOrValue) {
return '--';
}
// 尝试直接通过键查找
if (StockLogSourceType[sourceTypeKeyOrValue]) {
return StockLogSourceType[sourceTypeKeyOrValue];
}
// 尝试通过值反向查找
for (const key in StockLogSourceType) {
if (StockLogSourceType[key] === sourceTypeKeyOrValue) {
return StockLogSourceType[key];
}
}
return '--';
}
/**
* 用药原因
* @enum {string}