This commit is contained in:
@@ -89,3 +89,25 @@ export function generateCarrierCode(): string {
|
||||
|
||||
return `CARRIER${year}${month}${day}${hours}${minutes}${seconds}${randomChars}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成企业编码
|
||||
* 规则: ENT + 年月日时分秒 + 4位随机数
|
||||
* 示例: ENT20260331143025ABCD
|
||||
*/
|
||||
export function generateEnterpriseCode(): string {
|
||||
const now = new Date()
|
||||
const year = now.getFullYear()
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(now.getDate()).padStart(2, '0')
|
||||
const hours = String(now.getHours()).padStart(2, '0')
|
||||
const minutes = String(now.getMinutes()).padStart(2, '0')
|
||||
const seconds = String(now.getSeconds()).padStart(2, '0')
|
||||
|
||||
// 生成4位随机大写字母
|
||||
const randomChars = Array.from({ length: 4 }, () =>
|
||||
String.fromCharCode(65 + Math.floor(Math.random() * 26))
|
||||
).join('')
|
||||
|
||||
return `ENT${year}${month}${day}${hours}${minutes}${seconds}${randomChars}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user