From 98ed3174832bd43358fc519ff30f52af290578a9 Mon Sep 17 00:00:00 2001 From: itcast Date: Tue, 27 Jan 2026 09:17:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E8=B4=AD=E6=A8=A1=E5=9D=97=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E9=BB=98=E8=AE=A4=E4=B8=80=E4=B8=AA=E6=9C=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../material/purchase/goodsAccept/index.vue | 20 ++++++++++++++++++- .../purchase/goodsArrived/component/home.vue | 17 ++++++++++++++++ .../purchase/goodsBind/component/home.vue | 20 +++++++++++++++++-- .../material/purchase/goodsEntry/index.vue | 15 ++++++++++++++ .../material/report/goodsEntryReport.vue | 10 ++++++++++ 5 files changed, 79 insertions(+), 3 deletions(-) diff --git a/src/views/material/purchase/goodsAccept/index.vue b/src/views/material/purchase/goodsAccept/index.vue index d681eb69..071b2884 100644 --- a/src/views/material/purchase/goodsAccept/index.vue +++ b/src/views/material/purchase/goodsAccept/index.vue @@ -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; diff --git a/src/views/material/purchase/goodsArrived/component/home.vue b/src/views/material/purchase/goodsArrived/component/home.vue index 05c31d87..9c6418c3 100644 --- a/src/views/material/purchase/goodsArrived/component/home.vue +++ b/src/views/material/purchase/goodsArrived/component/home.vue @@ -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); + }, + // 日期格式化:将Date对象转为yyyy-MM-dd格式的字符串 + formatDate(date) { + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,补0 + const day = String(date.getDate()).padStart(2, '0'); // 日期补0 + return `${year}-${month}-${day}`; + }, getList() { this.loading = true; diff --git a/src/views/material/purchase/goodsBind/component/home.vue b/src/views/material/purchase/goodsBind/component/home.vue index b2d91ac0..2dd7c98d 100644 --- a/src/views/material/purchase/goodsBind/component/home.vue +++ b/src/views/material/purchase/goodsBind/component/home.vue @@ -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() }, // 查看 diff --git a/src/views/material/purchase/goodsEntry/index.vue b/src/views/material/purchase/goodsEntry/index.vue index fcb1f444..268ebd9e 100644 --- a/src/views/material/purchase/goodsEntry/index.vue +++ b/src/views/material/purchase/goodsEntry/index.vue @@ -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 diff --git a/src/views/material/report/goodsEntryReport.vue b/src/views/material/report/goodsEntryReport.vue index a9fd773d..1e9760f5 100644 --- a/src/views/material/report/goodsEntryReport.vue +++ b/src/views/material/report/goodsEntryReport.vue @@ -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')