From 44ddff9b265ac058f5b82f7099fa8df56f1c41af Mon Sep 17 00:00:00 2001
From: Guoxianpeng <744964089@qq.com>
Date: Sat, 11 Apr 2026 15:25:31 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8C=BB=E7=94=9F=E7=BB=9F=E8=AE=A1=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=E5=A2=9E=E5=8A=A0=E5=8A=A8=E6=80=81=E5=88=87=E6=8D=A2?=
=?UTF-8?q?=E5=A4=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
admin/src/views/doctor/tongji.vue | 95 +++++++++++++++++++++++++++++--
1 file changed, 91 insertions(+), 4 deletions(-)
diff --git a/admin/src/views/doctor/tongji.vue b/admin/src/views/doctor/tongji.vue
index 10955978..030194ec 100644
--- a/admin/src/views/doctor/tongji.vue
+++ b/admin/src/views/doctor/tongji.vue
@@ -25,9 +25,33 @@
+
+
+
+ 前一天
+
+
+ 今天
+
+
+ 后一天
+
+
+
+
- 今天
最近7天
最近30天
自定义
@@ -157,10 +181,13 @@ const loading = ref(false)
const doctorList = ref([])
const statisticsList = ref([])
const dateRange = ref([])
+const currentDate = ref(new Date().toISOString().split('T')[0])
+const isPrevDayDisabled = ref(false)
+const isNextDayDisabled = ref(false)
const queryParams = reactive({
doctor_id: '',
- time_type: 'today',
+ time_type: 'week',
start_date: '',
end_date: ''
})
@@ -178,16 +205,20 @@ const getStatistics = async () => {
loading.value = true
try {
const params: any = {
- time_type: queryParams.time_type
+ time_type: 'custom' // 始终使用custom类型,只传时间区间
}
if (queryParams.doctor_id) {
params.doctor_id = queryParams.doctor_id
}
- if (queryParams.time_type === 'custom' && dateRange.value && dateRange.value.length === 2) {
+ if (dateRange.value && dateRange.value.length === 2) {
params.start_date = dateRange.value[0]
params.end_date = dateRange.value[1]
+ } else {
+ // 否则使用currentDate作为查询参数
+ params.start_date = currentDate.value
+ params.end_date = currentDate.value
}
const res = await getDoctorStatistics(params)
@@ -215,12 +246,67 @@ const handleTimeTypeChange = () => {
if (queryParams.time_type !== 'custom') {
dateRange.value = []
}
+
+ // 根据时间类型更新currentDate
+ switch (queryParams.time_type) {
+ case 'week':
+ currentDate.value = new Date().toISOString().split('T')[0]
+ break
+ case 'month':
+ currentDate.value = new Date().toISOString().split('T')[0]
+ break
+ case 'custom':
+ // 自定义类型不更新currentDate
+ break
+ }
+
+ updateDateButtons()
+}
+
+// 更新日期按钮状态
+const updateDateButtons = () => {
+ const today = new Date().toISOString().split('T')[0]
+ const thirtyDaysAgo = new Date()
+ thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30)
+ const thirtyDaysAgoStr = thirtyDaysAgo.toISOString().split('T')[0]
+
+ // 后一天超过今天则禁用
+ isNextDayDisabled.value = currentDate.value >= today
+ // 前一天超过30天则禁用
+ isPrevDayDisabled.value = currentDate.value <= thirtyDaysAgoStr
+}
+
+// 处理前一天
+const handlePrevDay = () => {
+ const date = new Date(currentDate.value)
+ date.setDate(date.getDate() - 1)
+ currentDate.value = date.toISOString().split('T')[0]
+ updateDateButtons()
+ getStatistics()
+}
+
+// 处理后一天
+const handleNextDay = () => {
+ const date = new Date(currentDate.value)
+ date.setDate(date.getDate() + 1)
+ currentDate.value = date.toISOString().split('T')[0]
+ updateDateButtons()
+ getStatistics()
+}
+
+// 处理今天
+const handleToday = () => {
+ currentDate.value = new Date().toISOString().split('T')[0]
+ updateDateButtons()
+ getStatistics()
}
const handleReset = () => {
queryParams.doctor_id = ''
queryParams.time_type = 'today'
dateRange.value = []
+ currentDate.value = new Date().toISOString().split('T')[0]
+ updateDateButtons()
getStatistics()
}
@@ -260,6 +346,7 @@ const getStatusType = (status: string | number) => {
onMounted(() => {
getDoctorList()
+ updateDateButtons()
getStatistics()
})