修改导出部分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,11 +58,62 @@ 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),
@ -93,7 +164,14 @@ 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)
//
const doctorName = doctorvalue.value ? doctorvalue.value : Profilevo.value.doctorname
const data = await EcganalysisparasApi.getDateStaAndEndData(
doctorName, // 使
startDate,
endDate
)
cachedData.value = data //
updateChartWithData(data)
}
@ -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,12 +243,12 @@ 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) // 使
if (countMap[dateStr] !== undefined) {
@ -180,18 +256,48 @@ const calculateDailyDiagnosisCounts = (data: any[], dateArray: string[]) => {
}
})
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>