修改逻辑

This commit is contained in:
Euni4U 2025-03-12 17:51:54 +08:00
parent 4d0586fb46
commit ba1b35d37f
4 changed files with 532 additions and 327 deletions

View File

@ -25,6 +25,7 @@ export interface PatientVO {
auditorTime: Date // 审核时间
chargetime: Date // 收费时间
headimage: string // 个人信息图片
domicileaddress: string // 住址
}
// 患者信息 API
@ -58,4 +59,9 @@ export const PatientApi = {
exportPatient: async (params) => {
return await request.download({ url: `/inspect/patient/export-excel`, params })
},
// 导入患者信息
uploadExcel: async (data: FormData) => {
return await request.upload({ url: `/inspect/patient/uploadExcel`, data })
}
}

View File

@ -129,7 +129,8 @@ const getImageUrls = async () => {
'ultrasound': ['ultrasound', 'us', '超声', '彩超', 'b超', 'doppler'],
'ecg': ['ecg', 'ekg', '心电图', 'electrocardiogram'],
'blood': ['blood', 'cbc', '血常规', '血液', 'bloodtest'],
'urine': ['urine', 'ua', '尿常规', '尿液', 'urinalysis','RT','rt']
'urine': ['urine', 'ua', '尿常规', '尿液', 'urinalysis','RT','rt'],
'biochemical': ['biochemical', 'biochemistry', '生化', '化验','生化检查','生化检验','bt','BT']
}
const patterns = typePatterns[props.examType]
@ -162,9 +163,6 @@ const getImageUrls = async () => {
type: isPDF ? 'pdf' : 'image'
}
}).filter(item => item)
console.log('处理后的媒体文件:', mediaFiles.value) //
// URL
imageUrls.value = mediaFiles.value
.filter(file => file.type === 'image')
@ -361,9 +359,6 @@ const loadPatientData = async (patient) => {
if (patientItemsResponse?.list && patientItemsResponse.list.length > 0) {
//
currentItem.value = patientItemsResponse.list[0]
console.log('找到的当前检查项目:', currentItem.value)
//
if (currentItem.value) {
imageFinding.value = currentItem.value.examDescription || ''
@ -407,7 +402,6 @@ watch(
() => props.examType,
async (newType) => {
if (newType && reportData.value.medicalSn) {
console.log('检查类型变更为:', newType)
imageUrls.value = await getImageUrls()
}
},
@ -428,7 +422,8 @@ const getExamTypeTitle = () => {
ultrasound: '超声',
ecg: '心电图',
blood: '血常规',
urine: '尿常规'
urine: '尿常规',
biochemical: '生化'
}
return typeMap[props.examType] || '检查'
}

View File

@ -6,52 +6,34 @@
<div class="filter-options">
<div class="header-title">
<span>患者列表</span>
<el-button
type="success"
size="small"
@click="handleRefresh"
:icon="Refresh"
>
刷新
</el-button>
<div class="header-buttons">
<el-button
type="primary"
size="small"
@click="handleSync"
:icon="RefreshRight"
>
同步
</el-button>
<el-button
type="success"
size="small"
@click="handleRefresh"
:icon="Refresh"
>
刷新
</el-button>
</div>
</div>
</div>
<!-- 添加时间筛选 -->
<div class="view-options">
<div class="view-buttons">
<button
v-for="period in timePeriods"
:key="period.value"
class="view-btn"
:class="{ active: selectedPeriod === period.value }"
@click="handlePeriodChange(period.value)"
>
{{ period.label }}
</button>
</div>
<!-- 添加日期选择器 -->
<div v-if="showDatePicker" class="date-picker-container">
<div class="date-picker-wrapper">
<el-date-picker
v-model="customDateRange"
type="daterange"
unlink-panels
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
:shortcuts="shortcuts"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
/>
</div>
<el-button
type="primary"
@click="handleDateSearch"
class="search-button"
>搜索</el-button>
</div>
<!-- 添加检查状态筛选 -->
<div class="status-filter">
<el-radio-group v-model="statusFilter" @change="handleStatusFilterChange">
<el-radio label="0">待检查</el-radio>
<el-radio label="1">已检查</el-radio>
<el-radio label="">全部</el-radio>
</el-radio-group>
</div>
<!-- 简化体检编号搜索框 -->
@ -331,9 +313,7 @@ import { PatientApi } from '@/api/inspect/inspectpatient'
import { PatientitemsApi } from '@/api/inspect/inspectpatientitems'
import { getUserProfile } from '@/api/system/user/profile'
import ExamImages from './Exam_images.vue'
import CT from './CT.vue' // CT
import { ArrowDown, Refresh } from '@element-plus/icons-vue'
import BloodTest from './blood.vue' //
import { ArrowDown, Refresh, RefreshRight } from '@element-plus/icons-vue'
import All from './All.vue' // All
const dialogTitle = ref('体检报告')
@ -390,7 +370,8 @@ const examTabs = ref([
{ id: 'ultrasound', name: '超声', color: '#0099CC' },
{ id: 'ecg', name: '心电图', color: '#00CCFF' },
{ id: 'blood', name: '血常规', color: '#66CCFF' },
{ id: 'urine', name: '尿常规', color: '#99CCFF' }
{ id: 'urine', name: '尿常规', color: '#99CCFF' },
{ id: 'biochemical', name: '生化', color: '#0099CC' }
])
const currentTab = ref('general')
@ -420,10 +401,33 @@ return [...currentExamItems.value].sort((a, b) => {
});
});
//
//
const switchTab = (tabId) => {
currentTab.value = tabId
// activeConclusion
//
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] = [];
}
}
}
// conclusionData
@ -432,58 +436,14 @@ const conclusionData = ref({
ultrasound: { finding: '', diagnosis: '' },
ecg: { finding: '', diagnosis: '' },
blood: { summary: '' },
urine: { summary: '' }
urine: { summary: '' },
biochemical: { summary: '' } //
})
//
const examConclusion = ref('')
const examDate = ref('')
//
const timePeriods = [
{ label: '今日', value: 'today' },
{ label: '本周', value: 'week' },
{ label: '本月', value: 'month' },
{ label: '自定义', value: 'custom' },
{ label: '重置', value: 'reset' }
]
//
const selectedPeriod = ref('today')
const showDatePicker = ref(false)
const customDateRange = ref([])
//
const shortcuts = [
{
text: '最近一周',
value: () => {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
return [start, end]
},
},
{
text: '最近一个月',
value: () => {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
return [start, end]
},
},
{
text: '最近三个月',
value: () => {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
return [start, end]
},
},
]
const pageNo = ref(1)
const pageSize = ref(100)
const total = ref(0)
@ -491,7 +451,6 @@ const total = ref(0)
//
const searchQuery = ref('')
const originalPatients = ref([]) //
const filteredPatients = ref([]) //
//
const patientDataCache = ref(new Map())
@ -513,7 +472,7 @@ const handleLocalSearch = () => {
)
}
//
//
const getPatientList = async () => {
try {
const loading = ElLoading.service({
@ -526,71 +485,63 @@ const getPatientList = async () => {
pageNo: pageNo.value,
pageSize: pageSize.value
}
const res = await PatientApi.getPatientPage(params)
//
if (res.list && res.list.length > 0) {
//
//
patients.value = res.list
originalPatients.value = res.list
total.value = res.total
} else {
patients.value = []
originalPatients.value = []
total.value = 0
}
patients.value = res.list
originalPatients.value = res.list //
filteredPatients.value = res.list //
total.value = res.total
loading.close()
//
if (selectedPatient.value) {
const updatedPatient = res.list.find(p => p.id === selectedPatient.value.id)
if (updatedPatient) {
selectedPatient.value = updatedPatient
}
}
} catch (error) {
console.error('获取患者列表出错:', error)
message.error('获取患者列表出错')
ElMessage.error('获取患者列表失败')
}
}
//
const getpatientitemData = async (medicalSn) => {
try {
const params = {
medicalSn: medicalSn,
pageNo: 1,
pageSize: 100
}
const itemsRes = await PatientitemsApi.getPatientitemsPage(params)
if (itemsRes.list && itemsRes.list.length > 0) {
patientitemData.value = itemsRes.list[0]
try {
const params = {
medicalSn: medicalSn,
pageNo: 1,
pageSize: 100
}
const itemsRes = await PatientitemsApi.getPatientitemsPage(params)
//
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')) {
//
const patientIndex = patients.value.findIndex(p => p.medicalSn === medicalSn)
if (patientIndex !== -1) {
patients.value[patientIndex] = {
...patients.value[patientIndex],
examStatus: '1' //
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')) {
//
const patientIndex = patients.value.findIndex(p => p.medicalSn === medicalSn)
if (patientIndex !== -1) {
patients.value[patientIndex] = {
...patients.value[patientIndex],
examStatus: '1' //
}
}
}
}
} catch (error) {
console.error('获取患者体检项目数据出错:', error)
message.error('获取患者体检项目数据出错')
}
} catch (error) {
console.error('获取患者体检项目数据出错:', error)
message.error('获取患者体检项目数据出错')
}
}
// loadPatientData
@ -627,18 +578,11 @@ const loadPatientData = async (patient) => {
//
const hasItems = await checkPatientHasItems(patient.medicalSn)
//
//
if (!hasItems) {
console.log('患者没有检查项目,自动同步')
try {
await PatientitemsApi.createPatientapiInfo({
medicalSn: patient.medicalSn
})
console.log('自动同步成功')
} catch (syncError) {
console.error('自动同步失败:', syncError)
//
}
console.log('患者没有检查项目,需要同步')
ElMessage.info('该患者没有检查项目,请点击"同步"按钮获取最新数据')
//
}
//
@ -659,7 +603,8 @@ const loadPatientData = async (patient) => {
ultrasound: { finding: '', diagnosis: '' },
ecg: { finding: '', diagnosis: '' },
blood: { summary: '' },
urine: { summary: '' }
urine: { summary: '' },
biochemical: { summary: '' } //
}
//
@ -736,6 +681,9 @@ const getCategoryByItemName = (itemName) => {
return 'blood'
} else if (itemName.includes('尿常规') || itemName.includes('尿液分析')) {
return 'urine'
} else if (itemName.includes('生化') || itemName.includes('肝功能') || itemName.includes('肾功能') ||
itemName.includes('血脂') || itemName.includes('血糖') || itemName.includes('电解质')) {
return 'biochemical'
} else {
return 'general'
}
@ -886,7 +834,7 @@ return '一般检查'
}
//
const tabColors = ['#003366', '#006699', '#0099CC', '#00CCFF']
const tabColors = ['#003366', '#006699', '#0099CC', '#00CCFF', '#0099CC']
const getTabColor = (index) => {
return tabColors[index % tabColors.length]
}
@ -967,73 +915,14 @@ try {
onMounted(async () => {
//
patients.value = []
filteredPatients.value = [] //
selectedPatient.value = null
reportData.value = {
medicalSn: '',
cardId: '',
pName: '',
gender: '',
birthday: '',
nationality: '',
nation: '',
race: '',
phoneNum: '',
status: 0,
reportType: '',
medicalDateTime: '',
chargeType: '',
totalPrice: 0,
headPicUrl: '',
summaryResult: '',
auditor: '',
auditorTime: ''
}
patientitemData.value = {
medicalSn: '',
itemName: '',
itemCode: '',
price: 0,
discountedPrice: 0,
discounted: 0,
sectionID: '',
examDescription: '',
itemResult: '',
unit: '',
highValue: 0,
lowValue: 0,
itemStatus: '',
createTime: '',
positive: '',
inspectdoctor: '',
inspecttime: ''
}
customDateRange.value = []
//
try {
const userProfile = await getUserProfile()
user.value = userProfile
isImageDepartment.value = checkIsImageDepartment(userProfile.deptId)
//
await getPatientList()
} catch (error) {
console.error('获取用户信息失败:', error)
isImageDepartment.value = false
}
//
const today = new Date()
selectedPeriod.value = 'today'
const todayStart = new Date(today)
todayStart.setHours(0, 0, 0, 0)
const todayEnd = new Date(today)
todayEnd.setHours(23, 59, 59, 999)
customDateRange.value = [todayStart, todayEnd]
//
await fetchPatientsByDate()
//
pageSize.value = 20 //
pageNo.value = 1
//
await getPatientList()
})
//
@ -1043,6 +932,16 @@ const handlePeriodChange = (period) => {
//
selectedPatient.value = null
if (period === 'reset') {
//
selectedPeriod.value = '' //
customDateRange.value = [] //
showDatePicker.value = false
//
getPatientList()
return
}
const today = new Date()
let startDate, endDate
@ -1076,19 +975,10 @@ const handlePeriodChange = (period) => {
case 'custom':
showDatePicker.value = !showDatePicker.value
break
case 'reset':
selectedPeriod.value = 'today'
const todayStart = new Date(today.setHours(0, 0, 0, 0))
const todayEnd = new Date(today.setHours(23, 59, 59, 999))
customDateRange.value = [todayStart, todayEnd]
showDatePicker.value = false
fetchPatientsByDate()
break
}
}
//
// -
const fetchPatientsByDate = async () => {
try {
if (!customDateRange.value || customDateRange.value.length !== 2) return
@ -1106,7 +996,6 @@ const fetchPatientsByDate = async () => {
const res = await PatientApi.getPatientPage(params)
patients.value = res.list
originalPatients.value = res.list
filteredPatients.value = res.list
total.value = res.total
//
@ -1214,89 +1103,26 @@ const checkEditPermission = () => {
}
//
const handleSyncResults = async () => {
if (!selectedPatient.value?.medicalSn) {
console.warn('未选择患者,无法同步')
ElMessage.warning('请先选择患者')
return
}
const handleSync = async () => {
try {
console.log('开始同步患者数据, 体检编号:', selectedPatient.value.medicalSn)
const loading = ElLoading.service({
lock: true,
text: '同步中...',
background: 'rgba(255, 255, 255, 0.7)'
})
//
const existingItems = await PatientitemsApi.getPatientitemsPage({
medicalSn: selectedPatient.value.medicalSn,
pageNo: 1,
pageSize: 1
})
//
if (existingItems.list && existingItems.list.length > 0) {
console.log('该患者已有检查项目,无需再次同步')
loading.close()
ElMessage.info('该患者已有检查项目,无需再次同步')
//
await loadPatientData(selectedPatient.value)
return
}
//
const syncResult = await PatientitemsApi.createPatientapiInfo({
medicalSn: selectedPatient.value.medicalSn
})
console.log('同步接口调用成功:', syncResult)
//
console.log('重新加载患者数据')
await loadPatientData(selectedPatient.value)
console.log('患者数据加载完成')
loading.close()
console.log('同步操作完成')
ElMessage.success('同步成功')
} catch (error) {
console.error('同步失败:', error)
ElMessage.error('同步失败,请稍后重试')
}
}
//
const handleRefresh = async () => {
try {
const loading = ElLoading.service({
lock: true,
text: '刷新中...',
background: 'rgba(255, 255, 255, 0.7)'
})
//
selectedPeriod.value = 'today'
showDatePicker.value = false
searchQuery.value = ''
selectedPatient.value = null
pageNo.value = 1
//
const today = new Date()
const todayStart = new Date(today.setHours(0, 0, 0, 0))
const todayEnd = new Date(today.setHours(23, 59, 59, 999))
customDateRange.value = [todayStart, todayEnd]
try {
// 1.
//
await PatientitemsApi.createPatientapiInfo({})
// 2.
//
await new Promise(resolve => setTimeout(resolve, 1000))
// 3.
//
const today = new Date()
const todayStart = new Date(today.setHours(0, 0, 0, 0))
const todayEnd = new Date(today.setHours(23, 59, 59, 999))
const params = {
pageNo: pageNo.value,
pageSize: pageSize.value,
@ -1311,18 +1137,52 @@ const handleRefresh = async () => {
//
patients.value = res.list
originalPatients.value = res.list
filteredPatients.value = res.list
total.value = res.total
//
patientDataCache.value.clear()
loading.close()
ElMessage.success('同步成功')
} catch (error) {
loading.close()
console.error('同步数据失败:', error)
ElMessage.error('同步数据失败,请稍后重试')
}
} catch (error) {
console.error('同步失败:', error)
ElMessage.error('同步失败,请稍后重试')
}
}
// -
const handleRefresh = async () => {
try {
const loading = ElLoading.service({
lock: true,
text: '刷新中...',
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('同步数据失败,请稍后重试')
console.error('刷新数据失败:', error)
ElMessage.error('刷新数据失败,请稍后重试')
}
} catch (error) {
console.error('刷新失败:', error)
@ -1437,7 +1297,7 @@ const isReadOnly = computed(() => {
//
const handleCurrentChange = (val) => {
pageNo.value = val
getPatientList() // 使
getPatientList() //
}
//
@ -1586,6 +1446,13 @@ const validateAllResults = () => {
errors.push('尿常规体检小结不能为空')
}
}
//
if (conclusionData.value.biochemical) {
if (!conclusionData.value.biochemical.summary?.trim()) {
errors.push('生化检查体检小结不能为空')
}
}
if (errors.length > 0) {
ElMessage({
@ -1601,7 +1468,7 @@ const validateAllResults = () => {
return true
}
//
//
const handleSaveAllResults = async () => {
if (!checkEditPermission()) return
@ -1661,18 +1528,28 @@ const handleSaveAllResults = async () => {
} else if (itemName.includes('血常规') || itemName.includes('血细胞') || itemName.includes('血红蛋白')) {
allUpdatedItems.push({
...baseFields,
analyse: conclusionData.value.blood?.summary?.trim() || '' // analyse
analyse: conclusionData.value.blood?.summary?.trim() || '', // analyse
itemResult: conclusionData.value.blood?.summary?.trim() || '' // itemResult
})
} else if (itemName.includes('尿常规') || itemName.includes('尿液分析')) {
allUpdatedItems.push({
...baseFields,
analyse: conclusionData.value.urine?.summary?.trim() || '' // analyse
analyse: conclusionData.value.urine?.summary?.trim() || '', // analyse
itemResult: conclusionData.value.urine?.summary?.trim() || '' // itemResult
})
} else if (itemName.includes('生化') || itemName.includes('肝功能') || itemName.includes('肾功能') ||
itemName.includes('血脂') || itemName.includes('血糖') || itemName.includes('电解质')) {
allUpdatedItems.push({
...baseFields,
analyse: conclusionData.value.biochemical?.summary?.trim() || '', // analyse
itemResult: conclusionData.value.biochemical?.summary?.trim() || '' // itemResult
})
} else {
//
allUpdatedItems.push({
...baseFields,
analyse: conclusionData.value.general?.summary?.trim() || '' // analyse
analyse: conclusionData.value.general?.summary?.trim() || '', // analyse
itemResult: conclusionData.value.general?.summary?.trim() || '' // itemResult
})
}
})
@ -1692,25 +1569,29 @@ const handleSaveAllResults = async () => {
// - API
if (selectedPatient.value) {
// status1
// status1
await PatientApi.updatePatient({
id: selectedPatient.value.id,
status: 1 //
status: 1, //
medicalDateTime: currentTimestamp //
})
//
selectedPatient.value.status = 1
selectedPatient.value.medicalDateTime = currentTimestamp
//
const patientIndex = patients.value.findIndex(p => p.id === selectedPatient.value.id)
if (patientIndex !== -1) {
patients.value[patientIndex].status = 1
patients.value[patientIndex].medicalDateTime = currentTimestamp
}
//
const filteredIndex = filteredPatients.value.findIndex(p => p.id === selectedPatient.value.id)
if (filteredIndex !== -1) {
filteredPatients.value[filteredIndex].status = 1
filteredPatients.value[filteredIndex].medicalDateTime = currentTimestamp
}
}
@ -1772,9 +1653,42 @@ const inspectTime = ref('')
//
const isSpecialExam = computed(() => {
return ['ultrasound', 'ecg', 'blood', 'urine'].includes(currentTab.value)
return ['ultrasound', 'ecg', 'blood', 'urine', 'biochemical'].includes(currentTab.value)
})
//
const statusFilter = ref('0') //
//
const filteredPatients = computed(() => {
let result = patients.value
//
if (statusFilter.value !== '') {
result = result.filter(patient =>
String(patient.status) === statusFilter.value
)
}
//
if (searchQuery.value) {
const query = searchQuery.value.toLowerCase()
result = result.filter(patient =>
(patient.pname && patient.pname.toLowerCase().includes(query)) ||
(patient.medicalSn && patient.medicalSn.toLowerCase().includes(query))
)
}
return result
})
//
const handleStatusFilterChange = (value) => {
statusFilter.value = value
//
selectedPatient.value = null
}
</script>
<style scoped>
@ -1803,11 +1717,13 @@ color: #333;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
padding: 8px 0;
}
.filter-options {
padding: 10px 15px;
border-bottom: 1px solid #e6e6e6;
width: 100%;
padding: 0 10px;
}
.radio-label {
@ -2673,4 +2589,45 @@ cursor: not-allowed;
background-color: #f5f7fa;
cursor: not-allowed;
}
/* 修改按钮样式 */
.header-buttons {
display: flex;
flex-direction: row;
gap: 8px;
align-items: center;
justify-content: flex-end;
}
/* 确保按钮容器有足够的宽度 */
.filter-options {
width: 100%;
}
/* 确保按钮不会换行 */
.header-buttons .el-button {
flex-shrink: 0;
margin-left: 8px;
white-space: nowrap;
}
/* 添加状态筛选样式 */
.status-filter {
padding: 10px 15px;
border-bottom: 1px solid #e6e6e6;
}
:deep(.el-radio-group) {
display: flex;
justify-content: space-around;
width: 100%;
}
:deep(.el-radio) {
margin-right: 0;
}
:deep(.el-radio__label) {
font-size: 13px;
}
</style>

View File

@ -0,0 +1,247 @@
<template>
<div id="PrintElementOptionSetting" style="display:none;"></div>
<ContentWrap style="height: 70px; display: flex; align-items: center;">
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="体检编号" prop="medicalSn">
<el-input
v-model="queryParams.medicalSn"
placeholder="请输入体检编号"
clearable
@keyup.enter="handleQuery"
class="!w-200px"
/>
</el-form-item>
<el-form-item label="姓名" prop="pname">
<el-input
v-model="queryParams.pname"
placeholder="请输入姓名"
clearable
@input="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)
]"
clearable
class="!w-320px"
/>
</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">
<Icon icon="ep:upload" class="mr-5px" /> 导入Excel文件
</el-button>
<input
type="file"
ref="fileInputRef"
accept=".xlsx,.xls"
style="display: none"
@change="uploadFile"
/>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
:header-cell-style="{ background: 'rgb(235, 241, 250)', height: '56px',color:'#333333' }"
:row-style="{ height: '56px' }"
>
<el-table-column label="体检编号" align="center" prop="medicalSn" />
<el-table-column label="姓名" align="center" prop="pname" />
<el-table-column label="性别" align="center" prop="gender" />
<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" fixed="right" width="120px">
<template #default="scope">
<el-button
link
type="primary"
@click="handlePrint(scope.row)"
>
打印导检单
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<DepartmentForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts">
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";
defineOptions({ name: 'Department' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<PatientVO[]>([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
medicalSn: undefined,
pname: undefined,
medicalDateTime: [],
cardId: undefined,
phoneNum: undefined,
domicileaddress: undefined
})
const queryFormRef = ref() //
const fileInputRef = ref<HTMLInputElement | null>(null) //
/** 获取列表 */
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
})
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 添加/修改操作 */
const formRef = ref()
/** 初始化 **/
onMounted(() => {
getList()
})
/** 打印报告按钮操作 */
const handlePrint = async (row: PatientVO) => {
try {
console.log('开始打印,体检编号:', row.medicalSn);
// 使SummaryApi
const dataPrint = await SummaryApi.printInfoOfMedicalSn(row.medicalSn);
console.log('获取到的打印数据:', dataPrint);
// - 使
const hiprintTemplate = newHiprintPrintTemplate("InspectionChecklist", {
template: template,
settingContainer: "#PrintElementOptionSetting",
});
console.log('打印模板创建成功');
//
const options = {leftOffset: -1, topOffset: -1};
//
const ext = {
callback: () => {
console.log("浏览器打印窗口已打开");
},
styleHandler: () => {
return "<style>.hiprint-printElement-text{color:black !important;}</style>";
},
};
//
hiprintTemplate.print(dataPrint, options, ext);
} catch (error) {
console.error('打印导检单失败,详细错误:', error);
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 handleImport = () => {
fileInputRef.value?.click()
}
/** 处理文件上传 */
const uploadFile = async (event: Event) => {
const target = event.target as HTMLInputElement
if (!target.files || target.files.length === 0) {
return
}
const file = target.files[0]
if (!file.name.endsWith('.xlsx') && !file.name.endsWith('.xls')) {
message.error('请上传Excel文件(.xlsx或.xls格式)')
return
}
try {
loading.value = true
const formData = new FormData()
formData.append('file', file)
await PatientApi.uploadExcel(formData)
message.success('导入成功')
//
if (fileInputRef.value) {
fileInputRef.value.value = ''
}
//
await getList()
} catch (error) {
console.error('导入失败:', error)
message.error('导入失败,请检查文件格式是否正确')
} finally {
loading.value = false
}
}
</script>