Files
klp-mono/apps/hand-factory/utils/wms.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

2025-10-27 13:21:43 +08:00
import { IO_TYPE_LABEL, ITEM_TYPE_LABEL, CODE_STATUS } from '@/constants/wms';
/**
* 格式化IO类型支持根据二维码状态修正显示如状态1的入库显示出库
* @param {string} ioType - 原始IO类型'in'
* @param {number} codeStatus - 二维码状态
* @returns {string} 格式化后的文案
*/
export const formatIoType = (ioType, codeStatus) => {
// 业务规则状态1已入库的原始入库→显示为出库
if (codeStatus === CODE_STATUS.IN_STOCK && ioType === IO_TYPE.IN) {
return IO_TYPE_LABEL[IO_TYPE.OUT];
}
return IO_TYPE_LABEL[ioType] || '未知操作';
};
/**
* 格式化物品类型
* @param {string} itemType - 原始物品类型'raw_material'
* @returns {string} 格式化后的文案
*/
export const formatItemType = (itemType) => {
return ITEM_TYPE_LABEL[itemType] || '未知类型';
};
/**
* 格式化当前时间统一时间格式来源
* @returns {string} 格式化时间"2024-05-20 14:30"
*/
export const formatCurrentTime = () => {
const date = new Date();
const pad = (num) => num.toString().padStart(2, '0');
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
};