Files
klp-mono/apps/hand-factory/utils/wms.js
2025-10-27 13:21:43 +08:00

34 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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())}`;
};