修改BUG
This commit is contained in:
parent
761857cec5
commit
b0556140d6
@ -26,6 +26,9 @@ export interface PatientVO {
|
||||
chargetime: Date // 收费时间
|
||||
headimage: string // 个人信息图片
|
||||
domicileaddress: string // 住址
|
||||
xcgcode: string // 血常规编号
|
||||
ncgcode: string // 尿常规编号
|
||||
shqx: string // 生化编号
|
||||
}
|
||||
|
||||
// 患者信息 API
|
||||
@ -34,7 +37,10 @@ export const PatientApi = {
|
||||
getPatientPage: async (params: any) => {
|
||||
return await request.get({ url: `/inspect/patient/page`, params })
|
||||
},
|
||||
|
||||
//根据体检获得患者信息
|
||||
getPatientInfo: async (medicalSn: string) => {
|
||||
return await request.get({ url: `/inspect/patient/getpatientjson?medicalSn=` + medicalSn })
|
||||
},
|
||||
// 查询患者信息详情
|
||||
getPatient: async (id: number) => {
|
||||
return await request.get({ url: `/inspect/patient/get?id=` + id })
|
||||
@ -63,5 +69,24 @@ export const PatientApi = {
|
||||
// 导入患者信息
|
||||
uploadExcel: async (data: FormData) => {
|
||||
return await request.upload({ url: `/inspect/patient/uploadExcel`, data })
|
||||
}
|
||||
},
|
||||
|
||||
//发送检验申请单
|
||||
syncinspectApplyTj: async (medicalSn: string) => {
|
||||
return await request.get({ url: `/inspect/patient/syncinspectApplyTj?medicalSn=` + medicalSn })
|
||||
},
|
||||
|
||||
//获取检验报告
|
||||
getReportTj: async (medicalSn: string,type:string) => {
|
||||
return await request.get({ url: `/inspect/patient/getReportTj?medicalSn=` + medicalSn + `&type=` + type })
|
||||
},
|
||||
|
||||
//获取超声报告
|
||||
getUSTj: async (medicalSn: string) => {
|
||||
return await request.get({ url: `/inspect/patient/getUSTj?medicalSn=` + medicalSn})
|
||||
},
|
||||
//获取心电报告
|
||||
GetApiEcgInfo: async (medicalSn: string) => {
|
||||
return await request.get({ url: `/inspect/patient/getecgTj?medicalSn=` + medicalSn})
|
||||
},
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ const getImageUrls = async () => {
|
||||
pacsData.value = response.list
|
||||
let filteredData = response.list
|
||||
|
||||
// 确保根据当前检查类型过滤数据
|
||||
if (props.examType) {
|
||||
const typePatterns = {
|
||||
'ultrasound': ['ultrasound', 'us', '超声', '彩超', 'b超', 'doppler'],
|
||||
@ -144,6 +145,10 @@ const getImageUrls = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 清空旧数据
|
||||
mediaFiles.value = []
|
||||
imageUrls.value = []
|
||||
|
||||
if (filteredData.length === 0) {
|
||||
return []
|
||||
}
|
||||
@ -163,6 +168,7 @@ const getImageUrls = async () => {
|
||||
type: isPDF ? 'pdf' : 'image'
|
||||
}
|
||||
}).filter(item => item)
|
||||
|
||||
// 只收集图片URL用于预览
|
||||
imageUrls.value = mediaFiles.value
|
||||
.filter(file => file.type === 'image')
|
||||
@ -324,13 +330,7 @@ const loadPatientData = async (patient) => {
|
||||
}
|
||||
|
||||
try {
|
||||
const cacheKey = patient.id
|
||||
if (patientDataCache.value.has(cacheKey)) {
|
||||
const cachedData = patientDataCache.value.get(cacheKey)
|
||||
reportData.value = cachedData.reportData
|
||||
return
|
||||
}
|
||||
|
||||
// 不再使用缓存,每次都重新加载
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: '加载中...',
|
||||
@ -365,44 +365,92 @@ const loadPatientData = async (patient) => {
|
||||
imageDiagnosis.value = currentItem.value.itemResult || ''
|
||||
}
|
||||
|
||||
// 加载所有影像数据,不再按类型过滤
|
||||
// 加载所有影像数据
|
||||
imageUrls.value = await getImageUrls()
|
||||
} else {
|
||||
// 如果没有找到检查项目,清空数据
|
||||
currentItem.value = null
|
||||
imageFinding.value = ''
|
||||
imageDiagnosis.value = ''
|
||||
mediaFiles.value = []
|
||||
imageUrls.value = []
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取患者检查项目失败:', error)
|
||||
// 出错时也清空数据
|
||||
currentItem.value = null
|
||||
imageFinding.value = ''
|
||||
imageDiagnosis.value = ''
|
||||
mediaFiles.value = []
|
||||
imageUrls.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 缓存数据
|
||||
patientDataCache.value.set(cacheKey, {
|
||||
reportData: { ...reportData.value }
|
||||
})
|
||||
} finally {
|
||||
loading.close()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取患者详细信息出错:', error)
|
||||
ElMessage.error('获取患者详细信息失败')
|
||||
// 出错时清空数据
|
||||
mediaFiles.value = []
|
||||
imageUrls.value = []
|
||||
}
|
||||
}
|
||||
|
||||
// 监听患者变化
|
||||
// 修改检查类型变化的监听器
|
||||
watch(
|
||||
() => props.examType,
|
||||
async (newType, oldType) => {
|
||||
console.log(`[All.vue] examType 变化: 从 ${oldType} 到 ${newType}`)
|
||||
|
||||
if (!newType) return
|
||||
|
||||
// 如果新旧类型相同,不执行任何操作
|
||||
if (newType === oldType) return
|
||||
|
||||
// 无论如何都清空当前数据
|
||||
mediaFiles.value = []
|
||||
imageUrls.value = []
|
||||
|
||||
if (reportData.value.medicalSn) {
|
||||
// 显示加载中
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: '加载中...',
|
||||
background: 'rgba(255, 255, 255, 0.7)'
|
||||
})
|
||||
|
||||
try {
|
||||
console.log(`[All.vue] 重新获取 ${newType} 类型的影像数据`)
|
||||
// 重新获取影像数据
|
||||
await getImageUrls()
|
||||
console.log(`[All.vue] 获取到 ${mediaFiles.value.length} 个媒体文件`)
|
||||
} finally {
|
||||
loading.close()
|
||||
}
|
||||
}
|
||||
},
|
||||
{ immediate: false }
|
||||
)
|
||||
|
||||
// 修改患者变化的监听器
|
||||
watch(
|
||||
() => props.patient,
|
||||
(newPatient) => {
|
||||
console.log(`[All.vue] 患者变化: ${newPatient?.pname}, ID: ${newPatient?.id}`)
|
||||
|
||||
if (newPatient) {
|
||||
loadPatientData(newPatient)
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
// 监听检查类型变化
|
||||
watch(
|
||||
() => props.examType,
|
||||
async (newType) => {
|
||||
if (newType && reportData.value.medicalSn) {
|
||||
imageUrls.value = await getImageUrls()
|
||||
// 保存当前检查类型
|
||||
const currentExamType = props.examType
|
||||
console.log(`[All.vue] 当前检查类型: ${currentExamType}`)
|
||||
|
||||
loadPatientData(newPatient).then(() => {
|
||||
// 如果有检查类型,确保加载对应类型的影像数据
|
||||
if (currentExamType && reportData.value.medicalSn) {
|
||||
console.log(`[All.vue] 加载 ${currentExamType} 类型的影像数据`)
|
||||
getImageUrls()
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
@ -411,8 +459,20 @@ watch(
|
||||
// 修改组件挂载时的逻辑
|
||||
onMounted(async () => {
|
||||
if (props.patient) {
|
||||
// 保存当前检查类型
|
||||
const currentExamType = props.examType
|
||||
|
||||
// 清空当前数据
|
||||
mediaFiles.value = []
|
||||
imageUrls.value = []
|
||||
|
||||
// 加载患者数据和检查项目
|
||||
await loadPatientData(props.patient)
|
||||
|
||||
// 在加载完患者数据后,手动获取影像数据
|
||||
if (currentExamType && reportData.value.medicalSn) {
|
||||
await getImageUrls()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
@click="handleRefresh"
|
||||
:icon="Refresh"
|
||||
>
|
||||
刷新
|
||||
刷新列表
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@ -307,7 +307,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, computed, onBeforeUnmount } from 'vue'
|
||||
import { ref, onMounted, computed, onBeforeUnmount, watch } from 'vue'
|
||||
import { ElDialog, ElLoading, ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { PatientApi } from '@/api/inspect/inspectpatient'
|
||||
import { PatientitemsApi } from '@/api/inspect/inspectpatientitems'
|
||||
@ -401,33 +401,10 @@ return [...currentExamItems.value].sort((a, b) => {
|
||||
});
|
||||
});
|
||||
|
||||
// 修改切换标签页函数,添加数据清理逻辑
|
||||
const switchTab = (tabId) => {
|
||||
// 保存当前标签页的数据
|
||||
if (currentTab.value && examItems.value) {
|
||||
// 存储当前标签页的数据到缓存
|
||||
const currentItems = sortedExamItems.value || [];
|
||||
|
||||
// 如果切换到新标签页,检查是否有数据
|
||||
if (tabId !== currentTab.value) {
|
||||
// 设置新的当前标签
|
||||
currentTab.value = tabId;
|
||||
|
||||
// 如果新标签页没有数据,显示空状态
|
||||
if (!examItems.value[tabId] || examItems.value[tabId].length === 0) {
|
||||
// 确保该标签页有一个空数组
|
||||
examItems.value[tabId] = [];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 如果没有当前标签页数据,直接设置新标签
|
||||
currentTab.value = tabId;
|
||||
|
||||
// 确保该标签页有一个空数组
|
||||
if (!examItems.value[tabId]) {
|
||||
examItems.value[tabId] = [];
|
||||
}
|
||||
}
|
||||
// 修改 switchTab 函数,添加防止重复设置的逻辑
|
||||
const switchTab = async (tabId) => {
|
||||
// 设置新的当前标签
|
||||
currentTab.value = tabId
|
||||
}
|
||||
|
||||
// 修改 conclusionData 的数据结构
|
||||
@ -517,15 +494,6 @@ const getpatientitemData = async (medicalSn) => {
|
||||
|
||||
if (itemsRes.list && itemsRes.list.length > 0) {
|
||||
patientitemData.value = itemsRes.list[0]
|
||||
|
||||
// 获取用户信息
|
||||
const userProfile = await getUserProfile()
|
||||
user.value = userProfile
|
||||
|
||||
// 检查当前部门的项目状态
|
||||
const currentDeptItems = itemsRes.list.filter(item =>
|
||||
item.sectionID === userProfile.deptId || item.sectionID == userProfile.deptId
|
||||
)
|
||||
// 如果有项目且都是已检查状态,更新患者状态
|
||||
if (currentDeptItems.length > 0 && currentDeptItems.every(item => item.itemStatus === '1')) {
|
||||
// 更新患者列表中的状态
|
||||
@ -544,22 +512,15 @@ const getpatientitemData = async (medicalSn) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 删除原来的loadPatientData声明,只保留这一个完整的实现
|
||||
// 修改 loadPatientData 函数,确保它不会修改 currentTab
|
||||
const loadPatientData = async (patient) => {
|
||||
console.log(`[loadPatientData] 开始加载患者数据: ${patient.pname}, ID: ${patient.id}`)
|
||||
console.log(`[loadPatientData] 加载前的当前标签: ${currentTab.value}`)
|
||||
|
||||
// 保存当前标签,以便在加载完成后恢复
|
||||
//const savedTab = currentTab.value
|
||||
|
||||
try {
|
||||
// 检查缓存中是否已有数据
|
||||
const cacheKey = patient.id
|
||||
if (patientDataCache.value.has(cacheKey)) {
|
||||
const cachedData = patientDataCache.value.get(cacheKey)
|
||||
reportData.value = cachedData.reportData
|
||||
examItems.value = cachedData.examItems
|
||||
conclusionData.value = cachedData.conclusionData
|
||||
currentTab.value = cachedData.currentTab
|
||||
inspectDoctor.value = cachedData.inspectDoctor || ''
|
||||
inspectTime.value = cachedData.inspectTime || ''
|
||||
return
|
||||
}
|
||||
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: '加载中...',
|
||||
@ -575,16 +536,6 @@ const loadPatientData = async (patient) => {
|
||||
const patientData = await PatientApi.getPatient(patient.id)
|
||||
reportData.value = patientData
|
||||
|
||||
// 检查患者是否已有检查项目
|
||||
const hasItems = await checkPatientHasItems(patient.medicalSn)
|
||||
|
||||
// 如果没有检查项目,提示用户需要同步
|
||||
if (!hasItems) {
|
||||
console.log('患者没有检查项目,需要同步')
|
||||
ElMessage.info('该患者没有检查项目,请点击"同步"按钮获取最新数据')
|
||||
// 不再自动同步
|
||||
}
|
||||
|
||||
// 获取检查项目
|
||||
const itemsRes = await PatientitemsApi.getPatientitemsPage({
|
||||
medicalSn: patient.medicalSn,
|
||||
@ -604,7 +555,7 @@ const loadPatientData = async (patient) => {
|
||||
ecg: { finding: '', diagnosis: '' },
|
||||
blood: { summary: '' },
|
||||
urine: { summary: '' },
|
||||
biochemical: { summary: '' } // 添加生化检查的小结
|
||||
biochemical: { summary: '' }
|
||||
}
|
||||
|
||||
// 初始化检查医生和检查时间为空
|
||||
@ -647,27 +598,46 @@ const loadPatientData = async (patient) => {
|
||||
|
||||
examItems.value = groupedItems
|
||||
conclusionData.value = conclusions
|
||||
|
||||
// 缓存数据
|
||||
patientDataCache.value.set(cacheKey, {
|
||||
reportData: { ...reportData.value },
|
||||
examItems: { ...examItems.value },
|
||||
conclusionData: { ...conclusionData.value },
|
||||
currentTab: currentTab.value,
|
||||
inspectDoctor: inspectDoctor.value,
|
||||
inspectTime: inspectTime.value
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载患者数据失败:', error)
|
||||
ElMessage.error('加载患者数据失败')
|
||||
} finally {
|
||||
loading.close()
|
||||
|
||||
// 确保当前标签保持不变
|
||||
// if (currentTab.value !== savedTab) {
|
||||
// console.log(`[loadPatientData] 恢复标签: 从 ${currentTab.value} 到 ${savedTab}`)
|
||||
// currentTab.value = savedTab
|
||||
// }
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载患者数据失败:', error)
|
||||
ElMessage.error('加载患者数据失败')
|
||||
}
|
||||
|
||||
// 在加载完成后记录当前标签
|
||||
console.log(`[loadPatientData] 加载完成后的当前标签: ${currentTab.value}`)
|
||||
}
|
||||
|
||||
// 修改 handlePatientSelect 函数,避免重置标签
|
||||
const handlePatientSelect = async (patient) => {
|
||||
try {
|
||||
// 清理当前数据
|
||||
examConclusion.value = ''
|
||||
examItems.value = {}
|
||||
// 设置选中患者
|
||||
selectedPatient.value = patient
|
||||
// 重新加载患者数据,但不改变当前标签
|
||||
console.log(`[handlePatientSelect] 开始加载患者数据`)
|
||||
await loadPatientData(patient)
|
||||
console.log(`[handlePatientSelect] 患者数据加载完成`)
|
||||
currentTab.value='general'
|
||||
} catch (error) {
|
||||
console.error('[handlePatientSelect] 切换患者失败:', error)
|
||||
message.error('切换患者失败')
|
||||
isImageDepartment.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 辅助函数:根据项目名称获取分类
|
||||
@ -837,80 +807,7 @@ return '一般检查'
|
||||
const tabColors = ['#003366', '#006699', '#0099CC', '#00CCFF', '#0099CC']
|
||||
const getTabColor = (index) => {
|
||||
return tabColors[index % tabColors.length]
|
||||
}
|
||||
|
||||
// 修改患者选择处理函数
|
||||
const handlePatientSelect = async (patient) => {
|
||||
try {
|
||||
// 清理当前数据
|
||||
examConclusion.value = ''
|
||||
examItems.value = {}
|
||||
currentTab.value = 'general' // 设置默认选中一般检查
|
||||
|
||||
// 清理该患者的缓存
|
||||
if (patientDataCache.value.has(patient.id)) {
|
||||
patientDataCache.value.delete(patient.id)
|
||||
}
|
||||
|
||||
// 设置选中患者
|
||||
selectedPatient.value = patient
|
||||
|
||||
// 重新加载患者数据
|
||||
await loadPatientData(patient)
|
||||
|
||||
// 如果有体检编号,获取体检项目数据
|
||||
if (patient.medicalSn) {
|
||||
await getpatientitemData(patient.medicalSn)
|
||||
|
||||
// 查询并设置检查医生和检查日期
|
||||
try {
|
||||
const params = {
|
||||
medicalSn: patient.medicalSn,
|
||||
pageNo: 1,
|
||||
pageSize: 100
|
||||
}
|
||||
const itemsRes = await PatientitemsApi.getPatientitemsPage(params)
|
||||
|
||||
if (itemsRes.list && itemsRes.list.length > 0) {
|
||||
// 查找当前部门的已检查项目
|
||||
const checkedItems = itemsRes.list.filter(item =>
|
||||
item.itemStatus === '1' &&
|
||||
(item.sectionID === user.value.deptId || item.sectionID == user.value.deptId)
|
||||
)
|
||||
|
||||
if (checkedItems.length > 0) {
|
||||
// 使用第一个已检查项目的检查医生和检查时间
|
||||
const firstCheckedItem = checkedItems[0]
|
||||
inspectDoctor.value = firstCheckedItem.inspectdoctor || ''
|
||||
|
||||
// 格式化检查时间
|
||||
if (firstCheckedItem.inspecttime) {
|
||||
const inspectDate = new Date(Number(firstCheckedItem.inspecttime))
|
||||
inspectTime.value = formatDate(inspectDate)
|
||||
}
|
||||
} else {
|
||||
// 如果没有已检查项目,则清空检查医生和检查时间
|
||||
inspectDoctor.value = ''
|
||||
inspectTime.value = ''
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取检查医生和检查日期失败:', error)
|
||||
inspectDoctor.value = ''
|
||||
inspectTime.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
// 确保切换完数据后,标签页仍然是一般检查
|
||||
currentTab.value = 'general'
|
||||
|
||||
} catch (error) {
|
||||
console.error('切换患者失败:', error)
|
||||
message.error('切换患者失败')
|
||||
// 出错时重置状态
|
||||
isImageDepartment.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 清理页面状态
|
||||
@ -1058,15 +955,8 @@ const age = computed(() => {
|
||||
|
||||
// 添加性别计算属性
|
||||
const gender = computed(() => {
|
||||
if (!reportData.value.cardId) return reportData.value.gender || ''
|
||||
|
||||
// 从身份证号提取性别信息
|
||||
const idCard = reportData.value.cardId
|
||||
if (idCard.length !== 18) return reportData.value.gender || '' // 确保是18位身份证
|
||||
|
||||
// 身份证第17位,奇数为男,偶数为女
|
||||
const genderCode = parseInt(idCard.charAt(16))
|
||||
return genderCode % 2 === 1 ? '男' : '女'
|
||||
// 直接使用reportData中的gender字段
|
||||
return reportData.value.gender || ''
|
||||
})
|
||||
|
||||
// 添加选中患者的状态
|
||||
@ -1112,9 +1002,74 @@ const handleSync = async () => {
|
||||
})
|
||||
|
||||
try {
|
||||
// 调用同步接口
|
||||
await PatientitemsApi.createPatientapiInfo({})
|
||||
if (!selectedPatient.value?.medicalSn) {
|
||||
throw new Error('未选择患者或体检编号为空')
|
||||
}
|
||||
|
||||
const medicalSn = selectedPatient.value.medicalSn
|
||||
|
||||
// 定义需要同步的类型
|
||||
const types = ['XCG', 'NCG', 'SHQX','ECG']
|
||||
|
||||
// 并行请求所有报告(包括检验报告和超声报告)
|
||||
const syncPromises = [
|
||||
// 检验报告请求
|
||||
...types.map(type =>
|
||||
PatientApi.getReportTj(medicalSn, type)
|
||||
.catch(error => {
|
||||
console.warn(`获取${type}报告失败:`, error)
|
||||
return null
|
||||
})
|
||||
),
|
||||
// 超声报告请求
|
||||
PatientApi.getUSTj(medicalSn)
|
||||
.catch(error => {
|
||||
console.warn('获取超声报告失败:', error)
|
||||
return null
|
||||
}),
|
||||
// 心电报告请求
|
||||
PatientApi.GetApiEcgInfo(medicalSn)
|
||||
.catch(error => {
|
||||
console.warn('获取心电报告失败:', error)
|
||||
return null
|
||||
})
|
||||
]
|
||||
|
||||
const results = await Promise.all(syncPromises)
|
||||
|
||||
// 检查是否所有请求都失败了
|
||||
const allFailed = results.every(result => result === null)
|
||||
if (allFailed) {
|
||||
throw new Error('所有报告同步失败')
|
||||
}
|
||||
|
||||
// 处理同步结果
|
||||
results.forEach((result, index) => {
|
||||
if (result) {
|
||||
if (index < types.length) {
|
||||
// 处理检验报告结果
|
||||
const type = types[index]
|
||||
switch (type) {
|
||||
case 'XCG':
|
||||
console.log('血常规报告同步成功')
|
||||
break
|
||||
case 'NCG':
|
||||
console.log('尿常规报告同步成功')
|
||||
break
|
||||
case 'SHQX':
|
||||
console.log('生化报告同步成功')
|
||||
break
|
||||
case 'ECG':
|
||||
console.log('心电报告同步成功')
|
||||
break
|
||||
}
|
||||
} else {
|
||||
// 处理超声报告结果
|
||||
console.log('超声报告同步成功')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 等待一小段时间确保后端数据同步完成
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
|
||||
@ -1142,21 +1097,28 @@ const handleSync = async () => {
|
||||
// 清除缓存
|
||||
patientDataCache.value.clear()
|
||||
|
||||
// 如果当前有选中的患者,重新加载其数据
|
||||
if (selectedPatient.value) {
|
||||
await loadPatientData(selectedPatient.value)
|
||||
}
|
||||
|
||||
loading.close()
|
||||
ElMessage.success('同步成功')
|
||||
} catch (error) {
|
||||
loading.close()
|
||||
console.error('同步数据失败:', error)
|
||||
ElMessage.error('同步数据失败,请稍后重试')
|
||||
ElMessage.error(error.message || '同步数据失败,请稍后重试')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('同步失败:', error)
|
||||
ElMessage.error('同步失败,请稍后重试')
|
||||
ElMessage.error(error.message || '同步失败,请稍后重试')
|
||||
}
|
||||
}
|
||||
|
||||
// 修改刷新处理函数 - 移除同步功能
|
||||
const handleRefresh = async () => {
|
||||
const handleRefresh = async (e) => {
|
||||
// 阻止默认行为,防止触发浏览器刷新
|
||||
if (e) e.preventDefault()
|
||||
|
||||
try {
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
@ -1164,26 +1126,25 @@ const handleRefresh = async () => {
|
||||
background: 'rgba(255, 255, 255, 0.7)'
|
||||
})
|
||||
|
||||
// 重置所有状态
|
||||
searchQuery.value = ''
|
||||
selectedPatient.value = null
|
||||
pageNo.value = 1
|
||||
statusFilter.value = '0' // 重置为默认的待检查状态
|
||||
|
||||
try {
|
||||
// 获取最新的患者列表
|
||||
await getPatientList()
|
||||
|
||||
// 清除缓存
|
||||
patientDataCache.value.clear()
|
||||
|
||||
loading.close()
|
||||
ElMessage.success('刷新成功')
|
||||
} catch (error) {
|
||||
loading.close()
|
||||
console.error('刷新数据失败:', error)
|
||||
ElMessage.error('刷新数据失败,请稍后重试')
|
||||
// 清除选中状态和右侧内容
|
||||
selectedPatient.value = null // 清除选中患者
|
||||
reportData.value = {} // 清空报告数据
|
||||
examItems.value = {} // 清空检查项目
|
||||
conclusionData.value = { // 重置小结数据
|
||||
general: { summary: '' },
|
||||
ultrasound: { finding: '', diagnosis: '' },
|
||||
ecg: { finding: '', diagnosis: '' },
|
||||
blood: { summary: '' },
|
||||
urine: { summary: '' },
|
||||
biochemical: { summary: '' }
|
||||
}
|
||||
|
||||
// 刷新患者列表
|
||||
await getPatientList()
|
||||
//重置标签
|
||||
currentTab.value = 'general'
|
||||
loading.close()
|
||||
ElMessage.success('刷新成功')
|
||||
} catch (error) {
|
||||
console.error('刷新失败:', error)
|
||||
ElMessage.error('刷新失败,请稍后重试')
|
||||
@ -1689,6 +1650,11 @@ const handleStatusFilterChange = (value) => {
|
||||
selectedPatient.value = null
|
||||
}
|
||||
|
||||
// 添加一个监听器来跟踪 currentTab 的变化
|
||||
watch(currentTab, (newTab, oldTab) => {
|
||||
console.log(`[watch] currentTab 变化: 从 ${oldTab} 到 ${newTab}`)
|
||||
}, { immediate: true })
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
@ -1,6 +1,13 @@
|
||||
<template>
|
||||
<div id="PrintElementOptionSetting" style="display:none;"></div>
|
||||
|
||||
<!-- 添加全屏加载遮罩 -->
|
||||
<div
|
||||
v-loading.fullscreen.lock="fullscreenLoading"
|
||||
element-loading-text="正在导入数据,请勿关闭页面..."
|
||||
element-loading-background="rgba(0, 0, 0, 0.8)">
|
||||
</div>
|
||||
|
||||
<ContentWrap style="height: 70px; display: flex; align-items: center;">
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
@ -15,6 +22,7 @@
|
||||
v-model="queryParams.medicalSn"
|
||||
placeholder="请输入体检编号"
|
||||
clearable
|
||||
@input="handleQuery"
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-200px"
|
||||
/>
|
||||
@ -25,29 +33,25 @@
|
||||
placeholder="请输入姓名"
|
||||
clearable
|
||||
@input="handleQuery"
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-200px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="体检日期" prop="medicalDateTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.medicalDateTime"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
:default-time="[
|
||||
new Date(2000, 1, 1, 0, 0, 0),
|
||||
new Date(2000, 1, 1, 23, 59, 59)
|
||||
]"
|
||||
<el-form-item label="身份证号" prop="cardId">
|
||||
<el-input
|
||||
v-model="queryParams.cardId"
|
||||
placeholder="请输入身份证号"
|
||||
clearable
|
||||
class="!w-320px"
|
||||
@input="handleQuery"
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-200px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery">
|
||||
<Icon icon="ep:search" class="mr-5px" /> 查询
|
||||
</el-button>
|
||||
<el-button type="success" @click="handleImport">
|
||||
<el-button type="success" :loading="importLoading" @click="handleImport">
|
||||
<Icon icon="ep:upload" class="mr-5px" /> 导入Excel文件
|
||||
</el-button>
|
||||
<input
|
||||
@ -77,7 +81,7 @@
|
||||
<el-table-column label="身份证号" align="center" prop="cardId" />
|
||||
<el-table-column label="联系电话" align="center" prop="phoneNum" />
|
||||
<el-table-column label="住址" align="center" prop="domicileaddress" />
|
||||
<el-table-column label="体检日期" align="center" prop="medicalDateTime" :formatter="dateFormatter" />
|
||||
<el-table-column label="状态" align="center" prop="status" :formatter="statusFormatter" />
|
||||
<el-table-column label="操作" align="center" fixed="right" width="120px">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
@ -108,23 +112,26 @@ import { PatientApi, type PatientVO } from '@/api/inspect/inspectpatient'
|
||||
import * as SummaryApi from "@/api/summary";
|
||||
import { newHiprintPrintTemplate } from "@/views/summary/utils/template-helper";
|
||||
import template from "@/views/summary/print/template";
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
|
||||
defineOptions({ name: 'Department' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const importLoading = ref(false) // 导入Excel的加载状态
|
||||
const fullscreenLoading = ref(false) // 全屏加载状态
|
||||
const list = ref<PatientVO[]>([]) // 用于展示的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
medicalSn: undefined,
|
||||
pname: undefined,
|
||||
medicalSn: undefined as string | undefined,
|
||||
pname: undefined as string | undefined,
|
||||
medicalDateTime: [],
|
||||
cardId: undefined,
|
||||
phoneNum: undefined,
|
||||
domicileaddress: undefined
|
||||
cardId: undefined as string | undefined,
|
||||
phoneNum: undefined as string | undefined,
|
||||
domicileaddress: undefined as string | undefined
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null) // 文件输入引用
|
||||
@ -134,17 +141,20 @@ const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await PatientApi.getPatientPage({
|
||||
pageNo: queryParams.pageNo,
|
||||
pageSize: queryParams.pageSize,
|
||||
medicalSn: queryParams.medicalSn,
|
||||
pname: queryParams.pname,
|
||||
medicalDateTime: queryParams.medicalDateTime,
|
||||
cardId: queryParams.cardId,
|
||||
phoneNum: queryParams.phoneNum,
|
||||
domicileaddress: queryParams.domicileaddress
|
||||
...queryParams,
|
||||
pname: queryParams.pname?.trim() || undefined
|
||||
})
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
|
||||
// 在前端进行精确匹配筛选
|
||||
if (queryParams.pname) {
|
||||
list.value = data.list.filter(item => item.pname === queryParams.pname?.trim())
|
||||
total.value = list.value.length
|
||||
} else {
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('查询出错:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@ -155,6 +165,7 @@ const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
/** 初始化 **/
|
||||
@ -164,11 +175,38 @@ onMounted(() => {
|
||||
|
||||
/** 打印报告按钮操作 */
|
||||
const handlePrint = async (row: PatientVO) => {
|
||||
try {
|
||||
console.log('开始打印,体检编号:', row.medicalSn);
|
||||
const data = await PatientApi.getPatientInfo(row.medicalSn)
|
||||
//判断是否存在血常规、尿常规、生化检查编号
|
||||
if(!data.xcgcode && !data.ncgcode && !data.shqx){
|
||||
await PatientApi.syncinspectApplyTj(row.medicalSn)
|
||||
createPrint(row.medicalSn)
|
||||
} else {
|
||||
// 如果检验单已存在,弹出确认对话框
|
||||
const confirmResult = await ElMessageBox.confirm(
|
||||
'检验单已存在,是否重新创建?',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '是',
|
||||
cancelButtonText: '否',
|
||||
type: 'warning'
|
||||
}
|
||||
).catch(() => 'cancel')
|
||||
|
||||
// 用户点击"是",重新创建检验单
|
||||
if (confirmResult === 'confirm') {
|
||||
await PatientApi.syncinspectApplyTj(row.medicalSn)
|
||||
}
|
||||
// 用户点击"否",直接继续打印流程
|
||||
createPrint(row.medicalSn)
|
||||
}
|
||||
|
||||
}
|
||||
/** 打印导检单 */
|
||||
const createPrint = async (medicalSn) => {
|
||||
try {
|
||||
|
||||
// 使用SummaryApi打印导检单
|
||||
const dataPrint = await SummaryApi.printInfoOfMedicalSn(row.medicalSn);
|
||||
const dataPrint = await SummaryApi.printInfoOfMedicalSn(medicalSn);
|
||||
console.log('获取到的打印数据:', dataPrint);
|
||||
|
||||
// 创建打印模板 - 修改这里,使用固定的模板名称而不是动态获取
|
||||
@ -198,12 +236,18 @@ const handlePrint = async (row: PatientVO) => {
|
||||
message.error(`打印导检单失败: ${error.message || '未知错误'}`);
|
||||
}
|
||||
}
|
||||
|
||||
/** 日期格式化 */
|
||||
const dateFormatter = (row: any, column: any) => {
|
||||
if (!row.medicalDateTime) return ''
|
||||
const date = new Date(row.medicalDateTime)
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
|
||||
/** 状态格式化 */
|
||||
const statusFormatter = (row: any) => {
|
||||
const statusMap: Record<string, string> = {
|
||||
'0': '待检查',
|
||||
'1': '已检查',
|
||||
'2': '放弃',
|
||||
'3': '挂起,择日检',
|
||||
'4': '已汇总',
|
||||
'5': '终检审核',
|
||||
'6': '报告已取'
|
||||
}
|
||||
return statusMap[row.status] || '未知'
|
||||
}
|
||||
|
||||
/** 处理导入按钮点击 */
|
||||
@ -225,7 +269,10 @@ const uploadFile = async (event: Event) => {
|
||||
}
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
importLoading.value = true // 设置导入按钮加载状态为true
|
||||
fullscreenLoading.value = true // 设置全屏加载状态为true
|
||||
console.log('全屏加载状态已设置为:', fullscreenLoading.value) // 调试日志
|
||||
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
|
||||
@ -241,7 +288,9 @@ const uploadFile = async (event: Event) => {
|
||||
console.error('导入失败:', error)
|
||||
message.error('导入失败,请检查文件格式是否正确')
|
||||
} finally {
|
||||
loading.value = false
|
||||
importLoading.value = false // 设置导入按钮加载状态为false
|
||||
fullscreenLoading.value = false // 设置全屏加载状态为false
|
||||
console.log('全屏加载状态已重置为:', fullscreenLoading.value) // 调试日志
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user