38 lines
888 B
JavaScript
38 lines
888 B
JavaScript
|
|
/**
|
|||
|
|
* 生成钢卷号前五位
|
|||
|
|
* 格式:年份后两位 + 月份字母 + 日期两位
|
|||
|
|
* 例如:2026年3月3日生成 26L03
|
|||
|
|
* @returns {string} 钢卷号前五位
|
|||
|
|
*/
|
|||
|
|
export function generateCoilNoPrefix() {
|
|||
|
|
const now = new Date();
|
|||
|
|
// 取年份后两位
|
|||
|
|
const year = now.getFullYear().toString().slice(-2);
|
|||
|
|
|
|||
|
|
// 月份字母映射
|
|||
|
|
const monthLetters = {
|
|||
|
|
1: 'J', // 1月
|
|||
|
|
2: 'K', // 2月
|
|||
|
|
3: 'L', // 3月
|
|||
|
|
4: 'M', // 4月
|
|||
|
|
5: 'N', // 5月
|
|||
|
|
6: 'O', // 6月
|
|||
|
|
7: 'P', // 7月
|
|||
|
|
8: 'Q', // 8月
|
|||
|
|
9: 'R', // 9月
|
|||
|
|
10: 'S', // 10月
|
|||
|
|
11: 'T', // 11月
|
|||
|
|
12: 'U' // 12月
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// 获取月份字母
|
|||
|
|
const month = monthLetters[now.getMonth() + 1];
|
|||
|
|
|
|||
|
|
// 日期补零
|
|||
|
|
const day = String(now.getDate()).padStart(2, '0');
|
|||
|
|
|
|||
|
|
// 组合前五位:年份后两位 + 月份字母 + 日期两位
|
|||
|
|
return year + month + day;
|
|||
|
|
}
|
|||
|
|
|