diff --git a/src/views/system/jdorder/orderList.vue b/src/views/system/jdorder/orderList.vue index f652e37..a82ae26 100644 --- a/src/views/system/jdorder/orderList.vue +++ b/src/views/system/jdorder/orderList.vue @@ -41,7 +41,7 @@ - + @@ -125,9 +125,26 @@ export default { } }, created() { + // 设置默认日期为今天 + this.setDefaultDateRange() this.getList() }, methods: { + /** 设置默认日期范围为今天 */ + setDefaultDateRange() { + const today = new Date() + const todayStr = this.formatDate(today) + this.dateRange = [todayStr, todayStr] + this.queryParams.beginTime = todayStr + this.queryParams.endTime = todayStr + }, + /** 格式化日期为 yyyy-MM-dd 格式 */ + 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 listJDOrders(this.queryParams).then(res => { @@ -141,7 +158,6 @@ export default { this.getList() }, resetQuery() { - this.dateRange = [] this.queryParams = { pageNum: 1, pageSize: 10, @@ -156,6 +172,8 @@ export default { beginTime: null, endTime: null } + // 重置后重新设置默认日期为今天 + this.setDefaultDateRange() this.getList() }, /** 日期范围变化处理 */