From 89bf1116bc18f669239e592a07dbbc9539c278a0 Mon Sep 17 00:00:00 2001 From: Euni4U <958079825@qq.com> Date: Mon, 9 Dec 2024 17:52:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=8A=E6=96=AD=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=9F=A5=E8=AF=A2=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/tblist/ecganalysisparas/index.ts | 4 +- src/views/ECG/ECGStat/statdiagnosis.vue | 49 +++++++++++++++--------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/api/tblist/ecganalysisparas/index.ts b/src/api/tblist/ecganalysisparas/index.ts index 6de2863e..c06f3a0f 100644 --- a/src/api/tblist/ecganalysisparas/index.ts +++ b/src/api/tblist/ecganalysisparas/index.ts @@ -82,7 +82,7 @@ export const EcganalysisparasApi = { return await request.get({ url: `/tblist/ecganalysisparas/list?regId=${regId}&orgId=${orgId}` }) }, // 获取开始和结束时间的心电分析数据记录 - getDateStaAndEndData: async (orgId:String,startDate:String,endDate:String) => { - return await request.get({ url: `/tblist/ecganalysisparas/getDateStaAndEndData?orgId=${orgId}&TimeSta=${startDate}&TimeEnd=${endDate}` }) + getDateStaAndEndData: async (doctorName:String,startDate:String,endDate:String) => { + return await request.get({ url: `/tblist/ecganalysisparas/getDateStaAndEndData?doctorName=${doctorName}&TimeSta=${startDate}&TimeEnd=${endDate}` }) }, } diff --git a/src/views/ECG/ECGStat/statdiagnosis.vue b/src/views/ECG/ECGStat/statdiagnosis.vue index 9db77f8a..1814086f 100644 --- a/src/views/ECG/ECGStat/statdiagnosis.vue +++ b/src/views/ECG/ECGStat/statdiagnosis.vue @@ -63,13 +63,13 @@ const disabledDate = (time: Date) => { return time.getTime() > today.getTime() } -// 添加一个生成日期数组的函数 +// 修改生成日期数组的函数 const generateDateArray = (startDate: Date, endDate: Date) => { const dates = [] let currentDate = new Date(startDate) while (currentDate <= endDate) { - dates.push(currentDate.toLocaleDateString('zh-CN', { month: '2-digit', day: '2-digit' })) + dates.push(formatDate(currentDate)) // 使用 formatDate 函数格式化日期 currentDate = new Date(currentDate.setDate(currentDate.getDate() + 1)) } return dates @@ -86,7 +86,7 @@ async function getdata() { const startDate = `${formatDate(value.value[0])} 00:00:00` const endDate = `${formatDate(value.value[1])} 23:59:59` - const data = await EcganalysisparasApi.getDateStaAndEndData(Profilevo.value.orgId, startDate, endDate) + const data = await EcganalysisparasApi.getDateStaAndEndData(Profilevo.value.doctorname, startDate, endDate) cachedData.value = data // 保存数据 updateChartWithData(data) } @@ -102,7 +102,21 @@ const updateChartWithData = (data: any[]) => { xAxis: { data: dateArray }, - yAxis: {}, + yAxis: { + type: 'value', + name: '诊断数量', + minInterval: 1, // 因为是计数,所以最小间隔设为1 + min: 0, // 从0开始比较合理 + axisLabel: { + formatter: '{value}' + }, + splitLine: { + show: true, + lineStyle: { + type: 'dashed' + } + } + }, series: [ { name: '诊断数量', @@ -130,11 +144,19 @@ const handleDateChange = (val: [Date, Date]) => { value.value = [val[0], new Date(val[0].getTime() + 7 * 24 * 3600 * 1000 - 1)] } - updateChart() // 使用新的更新图表方法 + } } -// 添加新的统计方法 +// 修改日期格式化函数 +const formatDate = (date: 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}` +} + +// 修改统计方法中的日期格式化 const calculateDailyDiagnosisCounts = (data: any[], dateArray: string[]) => { // 初始化计数对象 const countMap = {} @@ -145,32 +167,23 @@ const calculateDailyDiagnosisCounts = (data: any[], dateArray: string[]) => { // 统计每天的诊断数量 data.forEach(item => { const date = new Date(item.doctorDiagTime) - const dateStr = date.toLocaleDateString('zh-CN', { month: '2-digit', day: '2-digit' }) + const dateStr = formatDate(date) // 使用相同的格式化函数 if (countMap[dateStr] !== undefined) { countMap[dateStr]++ } }) - // 将统计结果转换为数组 return dateArray.map(date => countMap[date]) } -// 修改日期格式化 -const formatDate = (date: 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}` -} - // 修改 onMounted onMounted(() => { getlogininfo() // 设置默认时间范围为当前日期往前7天 const endDate = new Date() - const startDate = new Date(endDate.getTime() - 7 * 24 * 3600 * 1000) + const startDate = new Date(endDate.getTime() - 6 * 24 * 3600 * 1000) value.value = [startDate, endDate] - updateChart() + })