From aab6a2e32ed7d1736c85a261d81dc7c24385b4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=89?= <814457906@qq.com> Date: Fri, 31 May 2024 14:33:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/manage/components/visitRecords.vue | 31 ++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/views/manage/components/visitRecords.vue b/src/views/manage/components/visitRecords.vue index d98ebf0..6432b6a 100644 --- a/src/views/manage/components/visitRecords.vue +++ b/src/views/manage/components/visitRecords.vue @@ -150,13 +150,23 @@ export default { if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } - var pastDate = new Date() + this.query.visitDateStart = this.haflYear(); + this.visitDate = [this.haflYear(), year + seperator1 + month + seperator1 + strDate] + this.query.visitDateEnd = year + seperator1 + month + seperator1 + strDate + this.query.patientId = this.$route.query.patientId + this.getListinfo(); + }, + haflYear() { + // 先获取当前时间 + var curDate = (new Date()).getTime() + // 将半年的时间单位换算成毫秒 + var halfYear = 365 / 2 * 24 * 3600 * 1000 + // 半年前的时间(毫秒单位) + var pastResult = curDate - halfYear + // 日期函数,定义起点为半年前 + var pastDate = new Date(pastResult) var pastYear = pastDate.getFullYear() - var pastMonth = pastDate.getMonth() + 1 - 6 - if (pastMonth < 0) { - pastYear = pastYear - 1 - pastMonth = 12 + pastMonth - } + var pastMonth = pastDate.getMonth() + 1 var pastDay = pastDate.getDate() if (pastMonth >= 1 && pastMonth <= 9) { pastMonth = '0' + pastMonth @@ -164,12 +174,9 @@ export default { if (pastDay >= 0 && pastDay <= 9) { pastDay = '0' + pastDay } - this.visitDate = [pastYear + '-' + pastMonth + '-' + pastDay, year + seperator1 + month + seperator1 + strDate] - this.query.visitDateStart = pastYear + '-' + pastMonth + '-' + pastDay - this.query.visitDateEnd = year + seperator1 + month + seperator1 + strDate - this.query.patientId = this.$route.query.patientId - this.getListinfo(); - }, + var endDate = pastYear + '-' + pastMonth + '-' + pastDay + return endDate + } } };