Compare commits

...

3 Commits

2 changed files with 43 additions and 30 deletions

View File

@ -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}` })
},
}

View File

@ -3,7 +3,7 @@
<div class="demo-date-picker">
<div class="block">
<el-date-picker
v-model="value"
v-model="Date_value"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
@ -32,7 +32,7 @@ import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
const Profilevo = ref<ProfileVO>({} as ProfileVO) //
const endDate = new Date()
const startDate = new Date(endDate.getTime() - 7 * 24 * 3600 * 1000)
const value = ref<[Date, Date]>([startDate, endDate])
const Date_value = ref<[Date, Date]>([startDate, endDate])
const getlogininfo = async () => {
Profilevo.value = await getUserProfile()
}
@ -44,12 +44,12 @@ const defaultTime = ref<[Date, Date]>([
//
const disabledDate = (time: Date) => {
if (value.value && value.value[0]) {
const start = value.value[0]
if (Date_value.value && Date_value.value[0]) {
const start = Date_value.value[0]
const diff = 7 * 24 * 3600 * 1000
//
if (!value.value[1]) {
if (!Date_value.value[1]) {
const today = new Date()
return time.getTime() > today.getTime()
}
@ -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
@ -83,17 +83,17 @@ const cachedData = ref<any[]>([])
// getdata
async function getdata() {
const startDate = `${formatDate(value.value[0])} 00:00:00`
const endDate = `${formatDate(value.value[1])} 23:59:59`
const startDate = `${formatDate(Date_value.value[0])} 00:00:00`
const endDate = `${formatDate(Date_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)
}
//
const updateChartWithData = (data: any[]) => {
const dateArray = generateDateArray(value.value[0], value.value[1])
const dateArray = generateDateArray(Date_value.value[0], Date_value.value[1])
const countArray = calculateDailyDiagnosisCounts(data, dateArray)
const myChart = echarts.init(document.getElementById('main'))
@ -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: '诊断数量',
@ -127,14 +141,22 @@ const handleDateChange = (val: [Date, Date]) => {
const diff = val[1].getTime() - val[0].getTime()
if (diff > 7 * 24 * 3600 * 1000) {
// 7
value.value = [val[0], new Date(val[0].getTime() + 7 * 24 * 3600 * 1000 - 1)]
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)
value.value = [startDate, endDate]
updateChart()
const startDate = new Date(endDate.getTime() - 6 * 24 * 3600 * 1000)
Date_value.value = [startDate, endDate]
})
</script>