新购模块日期默认一个月

This commit is contained in:
itcast 2026-01-27 09:17:44 +08:00
parent b552e96878
commit 98ed317483
5 changed files with 79 additions and 3 deletions

View File

@ -352,7 +352,9 @@
if (this.taskStatusList.length > 0) {
this.queryParams.taskStatusText = this.taskStatusList[0].id
}
this.getList()
this.initDefaultDate();
this.getList();
},
methods: {
//
@ -364,6 +366,22 @@
return false
}
},
initDefaultDate() {
const now=new Date();
//
this.queryParams.endTime=this.formatDate(now);
//
const oneMonthAgo =new Date(now);
oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1);
this.queryParams.startTime=this.formatDate(oneMonthAgo);
},
//
formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
},
/** 查询列表 */
getList() {
this.loading = true;

View File

@ -517,6 +517,7 @@ export default {
if (this.taskStatusList.length > 0) {
this.queryParams.isFinish = this.taskStatusList[0].id
}
this.initDefaultDate();
this.getList();
// this.getTypeList()
},
@ -529,6 +530,22 @@ export default {
// this.modelList = response.data
// })
// },
initDefaultDate() {
const now = new Date();
// 1. yyyy-MM-dd
this.queryParams.endTime = this.formatDate(now);
// 2.
const oneMonthAgo = new Date(now);
oneMonthAgo.setMonth(oneMonthAgo.getMonth() - 1); // 1/
this.queryParams.startTime = this.formatDate(oneMonthAgo);
},
// Dateyyyy-MM-dd
formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 00
const day = String(date.getDate()).padStart(2, '0'); // 0
return `${year}-${month}-${day}`;
},
getList() {
this.loading = true;

View File

@ -242,6 +242,7 @@ export default {
if (this.taskStatusList.length > 0) {
this.queryParams.isFinish = this.taskStatusList[0].id
}
this.initDefaultDate()
this.getList()
},
methods: {
@ -256,6 +257,21 @@ export default {
this.queryParams.endTime = ''
}
},
initDefaultDate() {
const now = new Date();
this.queryParams.endTime = this.formatDate(now);
const oneMonthAgo= new Date(now);
oneMonthAgo.setMonth(oneMonthAgo.getMonth()-1);
this.queryParams.startTime=this.formatDate(oneMonthAgo);
},
formatDate(date) {
const year = date.getFullYear();
const month=String(date.getMonth()+1).padStart(2, '0');
const day=String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`
},
//
async getList() {
// this.queryParams.startTime = this.queryTime ? this.queryTime[0] : ''
@ -277,9 +293,9 @@ export default {
this.queryTime = []
this.resetForm('queryForm')
this.queryParams.pageNum = 1
this.queryParams.endTime = ''
this.queryParams.pageSize = 10
this.queryParams.startTime = ''
this.getList()
},
//

View File

@ -318,9 +318,24 @@ export default {
if (this.taskStatusList.length > 0) {
this.queryParams.isFinish = this.taskStatusList[0].id
}
this.initDefaultDate()
this.getList()
},
methods: {
initDefaultDate() {
const now = new Date();
this.queryParams.endTime=this.formatDate(now);
const oneMonthAgo =new Date(now);
oneMonthAgo.setMonth(oneMonthAgo.getMonth()-1);
this.queryParams.startTime=this.formatDate(oneMonthAgo);
},
formatDate(date) {
const year =date.getFullYear();
const month = String(date.getMonth()+1).padStart(2,'0');
const day =String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
},
/** 查询列表 */
getList() {
this.loading = true

View File

@ -515,6 +515,7 @@
let start = new Date()
start.setMonth(start.getMonth() - 1)
this.dateRange = [this.format(start), this.format(end)]
this.initDefaultDate()
this.getList()
},
methods: {
@ -751,6 +752,15 @@
})
},
initDefaultDate() {
const now = new Date();
this.queryParams.endTime= this.format(now);
const oneMonthAgo =new Date(now);
oneMonthAgo.setMonth(oneMonthAgo.getMonth()-1);
this.queryParams.startTime=this.format(oneMonthAgo);
},
format(date) {
const y = date.getFullYear()
const m = String(date.getMonth() + 1).padStart(2, '0')