34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
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())}`;
|
||
}; |