// 生成单号 export function generateNo(typename='') { // 获取当前日期 const now = new Date(); // 获取月和日 const month = String(now.getMonth() + 1).padStart(2, '0'); // getMonth() 返回的是0-11,所以需要加1 const day = String(now.getDate()).padStart(2, '0'); // getDate() 返回的是1-31 // 生成 0 到 9999 之间的随机整数 const randomNum = Math.floor(Math.random() * 10000); // 返回 return typename + month + '' + day + '' + String(randomNum).padStart(4, '0'); }