修改导出部分bug
This commit is contained in:
parent
b5112d6224
commit
fb27bc2fcb
@ -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} ` })
|
||||
},
|
||||
}
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user