修改导出部分bug

This commit is contained in:
Euni4U 2024-12-10 17:07:25 +08:00
parent b5112d6224
commit fb27bc2fcb
2 changed files with 132 additions and 26 deletions

View File

@ -86,7 +86,7 @@ export const EcganalysisparasApi = {
return await request.get({ url: `/tblist/ecganalysisparas/getDateStaAndEndData?doctorName=${doctorName}&TimeSta=${startDate}&TimeEnd=${endDate}` })
},
// 添加导出Excel的方法
exportWorkloadExcel: async (startTime:String,endTime:String) => {
return await request.download({ url: `/tblist/ecganalysisparas/export-workload-excel?startTime=${startTime}&endTime=${endTime} ` })
exportWorkloadExcel: async (doctorName:string,startTime:string,endTime:string) => {
return await request.download({ url: `/tblist/ecganalysisparas/export-workload-excel?doctorName=${doctorName}&startTime=${startTime}&endTime=${endTime} ` })
},
}

View File

@ -16,6 +16,23 @@
</el-button>
<el-button style="margin-left: 20px" @click="getdata()">查询</el-button>
<el-button style="margin-left: 20px" @click="exportData()">导出</el-button>
<el-button style="margin-left: 20px" @click="exportnowData()"
>导出{{ Profilevo.doctorname }}工作量</el-button
>
<el-button style="margin-left: 20px" @click="exportAllData()">导出全部</el-button>
<el-select
v-model="doctorvalue"
clearable
placeholder="请选择医生"
style="margin-left: 20px; width: 180px"
>
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</div>
</ContentWrap>
@ -28,9 +45,12 @@
<script setup lang="ts">
import * as echarts from 'echarts'
import { ref } from 'vue'
const doctorvalue = ref('')
import download from '@/utils/download'
import { EcganalysisparasApi } from '@/api/tblist/ecganalysisparas'
import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
import { DiagnosisTemplateApi } from '@/api/applyregistration/diagnosisTemplate'
import { ElMessage } from 'element-plus'
const Profilevo = ref<ProfileVO>({} as ProfileVO) //
const endDate = new Date()
const startDate = new Date(endDate.getTime() - 7 * 24 * 3600 * 1000)
@ -38,12 +58,63 @@ const Date_value = ref<[Date, Date]>([startDate, endDate])
const getlogininfo = async () => {
Profilevo.value = await getUserProfile()
}
async function exportData(){
const options = ref<Array<{ value: string; label: string }>>([])
const getDoctorList = async () => {
try {
const response = await DiagnosisTemplateApi.getDoctorList()
options.value = response.map((doctor) => ({
value: doctor.doctorName,
label: doctor.doctorName
}))
} catch (error) {
console.error('获取医生列表失败:', error)
}
}
async function exportnowData() {
try {
// 使2000
const startDate = '2000-01-01 00:00:00'
// 使
const endDate = `${formatDate(new Date())} 23:59:59`
//
ElMessage.info('正在导出数据,请稍候...')
const data = await EcganalysisparasApi.exportWorkloadExcel(
Profilevo.value.doctorname,
startDate,
endDate
)
//
const fileName = `${Profilevo.value.doctorname}医生 ${formatDate(Date_value.value[0])}-${formatDate(Date_value.value[1])}工作量统计报表.xls`
download.excel(data, fileName)
ElMessage.success('导出成功')
} catch (error) {
console.error('导出失败:', error)
ElMessage.error('导出失败,请重试')
}
}
async function exportData() {
const startDate = `${formatDate(Date_value.value[0])} 00:00:00`
const endDate = `${formatDate(Date_value.value[1])} 23:59:59`
const data=await EcganalysisparasApi.exportWorkloadExcel( startDate, endDate)
download.excel(data, '工作量统计.xls')
}
const data = await EcganalysisparasApi.exportWorkloadExcel(
Profilevo.value.doctorname,
startDate,
endDate
)
//
const doctorName = Profilevo.value.doctorname
//
const fileName = `${doctorName}医生 ${formatDate(Date_value.value[0])}-${formatDate(Date_value.value[1])}工作量统计报表.xls`
download.excel(data, fileName)
}
const defaultTime = ref<[Date, Date]>([
new Date(2000, 1, 1, 0, 0, 0),
new Date(2000, 2, 1, 23, 59, 59)
@ -54,17 +125,17 @@ const disabledDate = (time: Date) => {
if (Date_value.value && Date_value.value[0]) {
const start = Date_value.value[0]
const diff = 7 * 24 * 3600 * 1000
//
if (!Date_value.value[1]) {
const today = new Date()
return time.getTime() > today.getTime()
}
//
return time.getTime() > start.getTime() + diff || time.getTime() < start.getTime()
}
//
const today = new Date()
return time.getTime() > today.getTime()
@ -76,7 +147,7 @@ const generateDateArray = (startDate: Date, endDate: Date) => {
let currentDate = new Date(startDate)
while (currentDate <= endDate) {
dates.push(formatDate(currentDate)) // 使 formatDate
dates.push(formatDate(currentDate)) // 使 formatDate
currentDate = new Date(currentDate.setDate(currentDate.getDate() + 1))
}
return dates
@ -92,9 +163,16 @@ const cachedData = ref<any[]>([])
async function getdata() {
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.doctorname, startDate, endDate)
cachedData.value = data //
//
const doctorName = doctorvalue.value ? doctorvalue.value : Profilevo.value.doctorname
const data = await EcganalysisparasApi.getDateStaAndEndData(
doctorName, // 使
startDate,
endDate
)
cachedData.value = data //
updateChartWithData(data)
}
@ -102,7 +180,7 @@ async function getdata() {
const updateChartWithData = (data: any[]) => {
const dateArray = generateDateArray(Date_value.value[0], Date_value.value[1])
const countArray = calculateDailyDiagnosisCounts(data, dateArray)
const myChart = echarts.init(document.getElementById('main'))
const option = {
tooltip: {},
@ -112,8 +190,8 @@ const updateChartWithData = (data: any[]) => {
yAxis: {
type: 'value',
name: '诊断数量',
minInterval: 1, // 1
min: 0, // 0
minInterval: 1, // 1
min: 0, // 0
axisLabel: {
formatter: '{value}'
},
@ -139,7 +217,7 @@ const updateChartWithData = (data: any[]) => {
//
const toggleChartType = () => {
chartType.value = chartType.value === 'line' ? 'bar' : 'line'
updateChartWithData(cachedData.value) // 使
updateChartWithData(cachedData.value) // 使
}
// handleDateChange
@ -150,8 +228,6 @@ const handleDateChange = (val: [Date, Date]) => {
// 7
Date_value.value = [val[0], new Date(val[0].getTime() + 7 * 24 * 3600 * 1000 - 1)]
}
}
}
@ -167,31 +243,61 @@ const formatDate = (date: Date) => {
const calculateDailyDiagnosisCounts = (data: any[], dateArray: string[]) => {
//
const countMap = {}
dateArray.forEach(date => {
dateArray.forEach((date) => {
countMap[date] = 0
})
//
data.forEach(item => {
data.forEach((item) => {
const date = new Date(item.doctorDiagTime)
const dateStr = formatDate(date) // 使
const dateStr = formatDate(date) // 使
if (countMap[dateStr] !== undefined) {
countMap[dateStr]++
}
})
return dateArray.map(date => countMap[date])
return dateArray.map((date) => countMap[date])
}
// onMounted
onMounted(() => {
getlogininfo()
getDoctorList()
// 7
const endDate = new Date()
const startDate = new Date(endDate.getTime() - 6 * 24 * 3600 * 1000)
Date_value.value = [startDate, endDate]
})
//
async function exportAllData() {
try {
// 使2000
const startDate = '2000-01-01 00:00:00'
// 使
const endDate = `${formatDate(new Date())} 23:59:59`
//
const doctorName = doctorvalue.value ? doctorvalue.value : ''
//
ElMessage.info('正在导出数据,请稍候...')
const data = await EcganalysisparasApi.exportWorkloadExcel(doctorName, startDate, endDate)
//
const fileName = doctorName
? `${doctorName}医生全部工作量统计报表.xls`
: `全部医生工作量统计报表.xls`
download.excel(data, fileName)
ElMessage.success('导出成功')
} catch (error) {
console.error('导出失败:', error)
ElMessage.error('导出失败,请重试')
}
}
</script>
<style scoped>