给单据列表中的时间段增加默认值,默认3个月

This commit is contained in:
jishenghua
2024-04-25 21:30:55 +08:00
parent 7cbf15174a
commit 1a53fe1117
3 changed files with 44 additions and 5 deletions

View File

@@ -548,6 +548,24 @@ export function getBeforeFormatDate(day) {
return thirtyDaysAgo.getFullYear() + seperator1 + month + seperator1 + strDate
}
/**
* js获取N月前的日期 格式“yyyy-MM-dd”
*/
export function getPrevMonthFormatDate(monthNum) {
let prevMonth = new Date(); // 当前日期
prevMonth.setMonth(prevMonth.getMonth() - monthNum); // 设置为前一个月
let seperator1 = "-";
let month = prevMonth.getMonth() + 1;
let strDate = prevMonth.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
return prevMonth.getFullYear() + seperator1 + month + seperator1 + strDate
}
/**
* JS中根据指定值删除数组中的元素
* @param arrylist