修改BUG

This commit is contained in:
Euni4U 2025-03-13 15:35:35 +08:00
parent 761857cec5
commit b0556140d6
4 changed files with 349 additions and 249 deletions

View File

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

View File

@ -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()
}
}
})

View File

@ -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 ? '男' : '女'
// 使reportDatagender
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>

View File

@ -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>