上传下载

This commit is contained in:
Flow 2025-08-13 17:33:25 +08:00
parent 92f60ac8ed
commit 1e02e0e8f3
2 changed files with 353 additions and 64 deletions

View File

@ -67,6 +67,22 @@ export const EcgworkstationApi = {
})
},
// 更新心电工作站患者信息文件名称
updateFilename: async (data: EcgworkstationVO) => {
return await request.post({
url: `/system/ecgworkstation/updateFilename`,
data
})
},
//根据机构ID和检查ID查询PDF地址
getPdfUrl: async (data: any) => {
return await request.post({
url: `/system/ecgworkstation/getPdfUrl`,
data
})
},
// 下载文件
downloadFile: async (filename: string) => {
return await request.download({

View File

@ -200,7 +200,6 @@
@click="() => handleCollect(row)"
>
<Icon icon="ep:video-camera" />
采集
</el-button>
</template>
</el-table-column>
@ -213,44 +212,44 @@
@click="handleAnalysis(row)"
>
<Icon icon="ep:monitor" />
分析
</el-button>
</template>
</el-table-column>
<el-table-column
prop="reportgenerated"
label="报告"
min-width="80"
align="center"
show-overflow-tooltip
>
<el-table-column label="导入数据" min-width="110" align="center" show-overflow-tooltip>
<template #default="{ row }">
<el-tag :type="row.reportgenerated === 1 ? 'success' : 'warning'" class="status-tag">
{{ row.reportgenerated === 1 ? '已生成' : '未生成' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="导入数据" min-width="90" align="center" show-overflow-tooltip>
<template #default="{ row }">
<input
ref="fileInput"
type="file"
:id="`file-input-${row.id}`"
accept=".hlf,.zip,.pdf,.doc,.docx"
style="display: none"
@change="(event) => handleFileSelect(row)"
/>
<el-button
type="primary"
size="small"
class="upload-btn"
@click="() => openFileBrowser(row)"
>
<Icon icon="ep:upload" />
导入数据
导入
</el-button>
</template>
</el-table-column>
<el-table-column label="上传" min-width="110" align="center" show-overflow-tooltip>
<template #default="{ row }">
<el-button
v-if="!row.uploading"
type="success"
size="small"
class="upload-btn"
@click="() => handleUpload(row)"
>
<Icon icon="ep:upload" />
</el-button>
<div v-else class="upload-progress">
<el-progress
:percentage="row.uploadProgress || 0"
:stroke-width="8"
:show-text="false"
class="progress-bar"
/>
<span class="progress-text">{{ row.uploadProgress || 0 }}%</span>
</div>
</template>
</el-table-column>
<el-table-column label="下载" min-width="80" align="center" show-overflow-tooltip>
<template #default="{ row }">
<el-button
@ -261,7 +260,6 @@
@click="handleDownload(row)"
>
<Icon icon="ep:download" />
下载
</el-button>
<div v-else class="download-progress">
<el-progress
@ -290,7 +288,6 @@
class="apply-btn"
@click="handleApply(row)"
>
<Icon icon="ep:document-add" />
申请
</el-button>
<span v-else type="success" size="small" class="status-tag"> 已申请 </span>
@ -305,7 +302,6 @@
@click="handleViewReport(row)"
>
<Icon icon="ep:view" />
查看
</el-button>
</template>
</el-table-column>
@ -318,7 +314,6 @@
>
<template #default="{ row }">
<div class="org-info">
<Icon icon="ep:office-building" />
<span>{{ row.orgname }}</span>
</div>
</template>
@ -589,13 +584,56 @@
</div>
</template>
</el-dialog>
<!-- 报告查看弹窗 -->
<el-dialog
v-model="reportViewVisible"
title="心电图报告查看"
width="85%"
top="5vh"
:close-on-click-modal="false"
:close-on-press-escape="false"
@close="closeReportView"
>
<div class="report-view-container">
<div class="report-content" v-loading="reportLoading">
<div v-if="reportImageUrl" class="report-image-container">
<el-image
:src="reportImageUrl"
:preview-src-list="[reportImageUrl]"
fit="contain"
class="medical-image"
@error="() => ElMessage.error('报告加载失败')"
:preview-teleported="true"
>
<template #error>
<div class="image-error">
<el-icon><Picture /></el-icon>
<span>图片加载失败</span>
</div>
</template>
</el-image>
</div>
<div v-else class="no-report">
<el-empty description="暂无报告数据" />
</div>
</div>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="closeReportView">关闭</el-button>
<el-button type="primary" @click="handlePrintReport" :icon="Download">打印图片</el-button>
</div>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
import { ref, reactive, onMounted, computed } from 'vue'
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus'
import PatientSelect from '@/patientcom/index.vue'
import { Search, Refresh, Plus, Download } from '@element-plus/icons-vue'
import { Search, Refresh, Plus, Download, Picture } from '@element-plus/icons-vue'
import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
import { uploadFileInChunks } from '@/utils/upload'
import { OrgApi } from '@/api/org'
@ -1038,25 +1076,18 @@ const resetQuery = () => {
/** 分析 */
const handleAnalysis = async (row) => {
try {
//
if (!row.wearstarttime) {
ElMessage.warning('请先设置佩戴时间后再进行分析')
return
}
//
const params = {
examId: row.examid,
patientName: encodeURIComponent(row.name), // URL
gender: row.gender === '1' ? '男' : row.gender === '2' ? '女' : '未知',
age: row.age?.toString() || '',
examTime: row.wearstarttime ? formatMeasureTime(row.wearstarttime) : '',
hospitalName: row.orgname || '',
department: '内科' //
// hospitalName: row.orgname || '',
orgid: Profilevo.value.orgid //
}
//
const response = await fetch('http://localhost:48082/api/analyze', {
const response = await fetch('http://localhost:48082/api/analyze-json', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@ -1258,7 +1289,7 @@ const confirmFileSelect = async (file?: any) => {
try {
//
const response = await fetch('http://localhost:48082/api/movefile', {
const response = await fetch('http://localhost:48082/api/movefile-json', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@ -1280,9 +1311,11 @@ const confirmFileSelect = async (file?: any) => {
if (result.success) {
//
await ecgdataApi.upecgfilename({
id: currentRow.value.id,
duration: result.duration
console.log(currentRow.value)
await EcgworkstationApi.updateFilename({
orgid: currentRow.value.orgid,
examid: currentRow.value.examid,
filename: result.targetFile
})
ElMessage.success(`文件 ${targetFile.name} 导入成功`)
@ -1326,7 +1359,9 @@ const handleUpload = async (row: any) => {
try {
//
const response = await fetch(`http://localhost:48082/api/exam?examId=${row.examid}`)
const response = await fetch(
`http://localhost:48082/api/check-exam-file?examId=${row.examid}`
)
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
@ -1337,9 +1372,9 @@ const handleUpload = async (row: any) => {
// success
if (result.success) {
// message
if (result.message === '压缩成功') {
//
const zipFilePath = result.zipFilePath
if (result.message === '文件存在') {
//
const fullFilePath = result.fullFilePath
sipdffile = result.isPdfFile
//
row.uploading = true
@ -1357,7 +1392,7 @@ const handleUpload = async (row: any) => {
'Content-Type': 'application/json'
},
body: JSON.stringify({
filePath: zipFilePath
filePath: fullFilePath
})
})
@ -1376,8 +1411,8 @@ const handleUpload = async (row: any) => {
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i)
}
const blob = new Blob([bytes], { type: 'application/zip' })
const file = new File([blob], `${row.examid}.zip`, { type: 'application/zip' })
const blob = new Blob([bytes])
const file = new File([blob], `${row.examid}`)
//
const uploadResult = await uploadFileInChunks({
@ -1395,11 +1430,6 @@ const handleUpload = async (row: any) => {
if (uploadResult.success) {
ElMessage.success('文件上传成功')
if (sipdffile === '存在') {
//
//
await ecgdataApi.upisreportgenerated(row.id, 1)
}
//
getList()
} else {
@ -1414,7 +1444,7 @@ const handleUpload = async (row: any) => {
row.uploadProgress = 0
}
} else {
//
//
ElMessage.error(result.message || '文件状态异常')
return
}
@ -1452,16 +1482,150 @@ const handleApply = async (row) => {
}
}
//
const reportViewVisible = ref(false)
const reportImageUrl = ref('')
const currentReportRow = ref<EcgworkstationVO | null>(null)
const reportLoading = ref(false)
/** 查看报告 */
const handleViewReport = (row) => {
if (row.pdfurl) {
// PDF
window.open(row.pdfurl, '_blank')
} else {
ElMessage.warning('报告未生成')
const handleViewReport = async (row) => {
try {
reportLoading.value = true
currentReportRow.value = row
//
const result = await EcgworkstationApi.getPdfUrl({
orgid: row.orgid,
examid: row.examid
})
// APIURLdata
let pdfUrl = ''
if (typeof result === 'string') {
// APIURL
pdfUrl = result.replace(/`/g, '').trim()
} else if (result && result.data) {
// APIdataURL
pdfUrl = result.data.replace(/`/g, '').trim()
}
if (pdfUrl) {
console.log('处理后的PDF URL:', pdfUrl)
reportImageUrl.value = pdfUrl
reportViewVisible.value = true
ElMessage.success('报告加载成功')
} else {
console.warn('API返回数据异常:', {
result,
resultType: typeof result,
hasData: !!result?.data
})
ElMessage.warning('报告未生成或查询失败')
}
} catch (error) {
console.error('查询报告失败:', error)
console.error('错误详情:', {
message: error?.message,
response: error?.response,
status: error?.response?.status
})
ElMessage.error('查询报告失败,请重试')
} finally {
reportLoading.value = false
}
}
/** 打印报告 */
const handlePrintReport = () => {
if (!reportImageUrl.value) {
ElMessage.warning('没有可打印的报告')
return
}
//
const printStyle = `
<style>
@media print {
* {
visibility: hidden !important;
margin: 0 !important;
padding: 0 !important;
}
html, body {
width: 100% !important;
height: 100% !important;
margin: 0 !important;
padding: 0 !important;
overflow: hidden !important;
}
.medical-image {
visibility: visible !important;
position: fixed !important;
top: 0 !important;
left: 0 !important;
width: 100vw !important;
height: 100vh !important;
border: none !important;
margin: 0 !important;
padding: 0 !important;
z-index: 9999 !important;
object-fit: contain !important;
background: white !important;
box-shadow: none !important;
}
.medical-image img {
width: 100% !important;
height: 100% !important;
object-fit: contain !important;
}
/* 隐藏所有其他元素 */
.el-dialog,
.el-dialog *:not(.medical-image):not(.medical-image *),
.dialog-footer,
.report-view-container > *:not(.report-content),
.report-content > *:not(.report-image-container),
.report-image-container > *:not(.medical-image) {
display: none !important;
visibility: hidden !important;
}
}
</style>
`
// head
const existingStyle = document.querySelector('#print-style')
if (existingStyle) {
existingStyle.remove()
}
const styleElement = document.createElement('style')
styleElement.id = 'print-style'
styleElement.innerHTML = printStyle
document.head.appendChild(styleElement)
//
window.print()
//
setTimeout(() => {
if (styleElement) {
styleElement.remove()
}
}, 1000)
}
/** 关闭报告查看弹窗 */
const closeReportView = () => {
reportViewVisible.value = false
reportImageUrl.value = ''
currentReportRow.value = null
}
/** 下载 */
const handleDownload = async (row) => {
//
@ -2679,4 +2843,113 @@ onMounted(async () => {
display: none !important;
}
}
//
.report-view-container {
.report-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px;
background: #f8f9fa;
border-radius: 8px;
margin-bottom: 16px;
.patient-info {
display: flex;
flex-wrap: wrap;
gap: 16px;
.info-item {
font-size: 14px;
color: #606266;
font-weight: 500;
&:first-child {
color: #409eff;
font-weight: 600;
}
}
}
.report-actions {
display: flex;
gap: 8px;
}
}
.report-content {
min-height: 400px;
display: flex;
justify-content: center;
align-items: center;
.report-image-container {
width: 100%;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
.medical-image {
width: 90%;
height: 70vh;
min-height: 500px;
max-height: 800px;
border: 1px solid #e4e7ed;
border-radius: 8px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
background: #fff;
cursor: pointer;
transition: all 0.3s ease;
&:hover {
box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.15);
transform: scale(1.02);
}
}
.image-error {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 200px;
color: #909399;
font-size: 14px;
.el-icon {
font-size: 48px;
margin-bottom: 12px;
}
}
}
.no-report {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
min-height: 300px;
}
}
}
//
@media (max-width: 768px) {
.report-view-container {
.report-header {
flex-direction: column;
gap: 12px;
.patient-info {
justify-content: center;
.info-item {
font-size: 12px;
}
}
}
}
}
</style>