修改HRV

This commit is contained in:
Flow 2025-08-29 14:07:13 +08:00
parent 687f652bbc
commit 66971a4e34
3 changed files with 142 additions and 287 deletions

View File

@ -520,6 +520,9 @@
// 页面加载完成后初始化
window.addEventListener('load', function() {
// 清理缓存
sessionStorage.removeItem('hrvReportData');
// 从sessionStorage中获取数据
const storedData = sessionStorage.getItem('hrvReportData');
let data = null;

View File

@ -62,5 +62,12 @@ export const HrvApi = {
return await request.post({
url: `/system/hrv/apply-superior-review?id=` + id + '&orgid=' + orgid
})
},
// 处理HRV分析
processHrv: async (examid: string) => {
return await request.get({
url: `https://58.57.172.62:6042/api/file/process-hrv?examid=${examid}`
})
}
}

View File

@ -150,28 +150,17 @@
</el-button>
</template>
</el-table-column>
<el-table-column label="导入数据" min-width="80" align="center" show-overflow-tooltip>
<el-table-column label="导入/上传" min-width="100" align="center" show-overflow-tooltip>
<template #default="{ row }">
<el-button
v-if="!row.uploading"
type="primary"
size="small"
class="upload-btn"
@click="() => openFileBrowser(row)"
>
导入
</el-button>
</template>
</el-table-column>
<el-table-column label="上传" min-width="80" 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
@ -184,29 +173,7 @@
</div>
</template>
</el-table-column>
<el-table-column label="下载" min-width="80" align="center" show-overflow-tooltip>
<template #default="{ row }">
<el-button
v-if="!row.downloading"
type="success"
size="small"
class="download-btn"
@click="handleDownload(row)"
>
<Icon icon="ep:download" />
</el-button>
<div v-else class="download-progress">
<el-progress
:percentage="Math.round(row.downloadProgress || 0)"
:stroke-width="8"
:show-text="false"
class="progress-bar"
/>
<span class="progress-text">{{ Math.round(row.downloadProgress || 0) }}%</span>
</div>
</template>
</el-table-column>
<!-- 上传列已整合到导入功能中不再单独显示 -->
<el-table-column
prop="managerorg"
@ -1027,27 +994,13 @@ const handleAnalysis = async (row) => {
return
}
const loading = ElLoading.service({
lock: true,
text: '正在获取检查数据...',
background: 'rgba(0, 0, 0, 0.7)'
})
// HRV
const response = await HrvApi.processHrv(examid)
try {
// examid
const res = await HrvdataApi.getHrvdataPage({ examid: examid, pageNo: 1, pageSize: 1 })
if (res && res.list && res.list.length > 0) {
const hrvData = res.list[0]
console.log('获取到的HRV数据:', hrvData)
//
openHrvReport(hrvData, row)
ElMessage.success('数据获取成功,正在生成报告')
} else {
ElMessage.warning('未找到相关检查数据')
}
} finally {
loading.close()
if (response) {
ElMessage.success('分析请求已发送,请稍后查看报告!')
} else {
ElMessage.error('分析请求失败,请稍后重试')
}
} catch (error) {
console.error('分析过程中出错:', error)
@ -1277,58 +1230,87 @@ const confirmFileSelect = async (file?: any) => {
}
}
console.log('最终文件路径:', finalFilePath)
//
const loading = ElLoading.service({
lock: true,
text: `正在处理文件 ${targetFile.name}...`,
text: `正在处理... 0%`,
background: 'rgba(0, 0, 0, 0.8)',
customClass: 'upload-loading'
})
//
let fakeProgress = 0
const progressInterval = setInterval(() => {
fakeProgress += Math.random() * 15 + 5 // 5-20
if (fakeProgress > 90) fakeProgress = 90 // 90%
loading.setText(`正在处理... ${Math.floor(fakeProgress)}%`)
}, 300)
try {
//
const response = await fetch('http://localhost:48082/api/movefile-json', {
// API
const fileResponse = await fetch('http://localhost:48082/api/readfile', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
filePath: finalFilePath,
examId: currentRow.value.examid
filePath: finalFilePath
})
})
if (!response.ok) {
const errorText = await response.text()
console.error('服务器响应:', errorText)
throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`)
const fileData = await fileResponse.json()
if (!fileData.success) {
throw new Error(fileData.message || '读取文件失败')
}
const result = await response.json()
console.log('服务器返回结果:', result)
// base64blob
const binaryString = atob(fileData.data)
const bytes = new Uint8Array(binaryString.length)
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i)
}
const blob = new Blob([bytes])
const file = new File([blob], `${currentRow.value.examid}`)
if (result.success) {
//
console.log(currentRow.value)
await HrvApi.updateFilename({
...currentRow.value,
filename: result.targetFile
})
//
const uploadResult = await uploadFileInChunks({
file: file,
url: import.meta.env.VITE_FILE_UPLOAD_URL,
name: `${currentRow.value.examid}.png`,
onProgress: (progress, currentChunk, totalChunks) => {
//
if (currentRow.value) currentRow.value.uploadProgress = progress
},
onError: (error, chunkIndex) => {
console.error(`分片 ${chunkIndex} 上传失败:`, error)
}
})
ElMessage.success(`文件 ${targetFile.name} 导入成功`)
getList() //
fileBrowserVisible.value = false
//
clearInterval(progressInterval)
if (uploadResult.success) {
// 100%
loading.setText('正在处理... 100%')
// 100%
setTimeout(() => {
loading.close()
ElMessage.success('文件上传成功')
//
fileBrowserVisible.value = false
//
getList()
}, 500)
} else {
throw new Error(result.message || '文件导入失败')
loading.close()
ElMessage.error(`文件上传失败: ${uploadResult.message}`)
}
} catch (error) {
//
clearInterval(progressInterval)
loading.close()
console.error('文件导入失败:', error)
const errorMessage = error instanceof Error ? error.message : '文件导入失败,请重试'
ElMessage.error(`文件导入失败: ${errorMessage}`)
} finally {
loading.close()
}
} catch (error) {
console.error('文件选择处理失败:', error)
@ -1346,109 +1328,78 @@ const cancelFileSelect = () => {
searchKeyword.value = ''
}
/** 处理上传 */
const handleUpload = async (row: any) => {
/** 处理文件上传(整合到导入功能中) */
const handleFileUpload = async (row: any, filePath: string) => {
try {
//
const loading = ElLoading.service({
lock: true,
text: '正在进行压缩文件中...',
background: 'rgba(0, 0, 0, 0.8)'
})
//
row.uploading = true
row.uploadProgress = 0
//
//
try {
//
const response = await fetch(
`http://localhost:48082/api/check-exam-file?examId=${row.examid}`
)
console.log('检查文件状态:', response)
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
// API
const fileResponse = await fetch('http://localhost:48082/api/readfile', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
filePath: filePath
})
})
const fileData = await fileResponse.json()
if (!fileData.success) {
throw new Error(fileData.message || '读取文件失败')
}
const result = await response.json()
let sipdffile
// success
if (result.success) {
// message
if (result.message === '文件存在') {
//
const fullFilePath = result.fullFilePath
sipdffile = result.isPdfFile
//
row.uploading = true
row.uploadProgress = 0
// base64blob
const binaryString = atob(fileData.data)
const bytes = new Uint8Array(binaryString.length)
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i)
}
const blob = new Blob([bytes])
const file = new File([blob], `${row.examid}`)
//
loading.close()
//
try {
// API
const fileResponse = await fetch('http://localhost:48082/api/readfile', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
filePath: fullFilePath
})
})
const fileData = await fileResponse.json()
if (!fileData.success) {
throw new Error(fileData.message || '读取文件失败')
}
// base64blob
const binaryString = atob(fileData.data)
const bytes = new Uint8Array(binaryString.length)
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i)
}
const blob = new Blob([bytes])
const file = new File([blob], `${row.examid}`)
//
const uploadResult = await uploadFileInChunks({
file: file,
url: import.meta.env.VITE_FILE_UPLOAD_URL,
name: `${row.examid}`,
onProgress: (progress, currentChunk, totalChunks) => {
//
row.uploadProgress = progress
},
onError: (error, chunkIndex) => {
console.error(`分片 ${chunkIndex} 上传失败:`, error)
}
})
if (uploadResult.success) {
ElMessage.success('文件上传成功')
//
getList()
} else {
ElMessage.error(`文件上传失败: ${uploadResult.message}`)
}
} catch (uploadError) {
console.error('文件上传失败:', uploadError)
ElMessage.error('文件上传失败,请重试')
} finally {
//
row.uploading = false
row.uploadProgress = 0
}
//
const uploadResult = await uploadFileInChunks({
file: file,
url: import.meta.env.VITE_FILE_UPLOAD_URL,
name: `${row.examid}`,
onProgress: (progress, currentChunk, totalChunks) => {
//
row.uploadProgress = progress
},
onError: (error, chunkIndex) => {
console.error(`分片 ${chunkIndex} 上传失败:`, error)
}
})
if (uploadResult.success) {
ElMessage.success('文件上传成功')
//
fileBrowserVisible.value = false
//
getList()
} else {
// successok
ElMessage.error(result.message || '请求失败')
return
ElMessage.error(`文件上传失败: ${uploadResult.message}`)
}
} catch (uploadError) {
console.error('文件上传失败:', uploadError)
ElMessage.error('文件上传失败,请重试')
} finally {
loading.close()
//
row.uploading = false
row.uploadProgress = 0
}
} catch (error) {
console.error('网络请求失败:', error)
ElMessage.error('网络请求失败,请检查服务是否正常')
console.error('文件上传处理失败:', error)
ElMessage.error('文件上传处理失败,请重试')
//
row.uploading = false
row.uploadProgress = 0
}
}
@ -1456,7 +1407,7 @@ const handleUpload = async (row: any) => {
const handleApply = async (row) => {
try {
const userinfo = await getUserProfile()
const orginfo = await OrgApi.getOrg(userinfo.orgid)
const orginfo = await OrgApi.getOrgByOrgId(userinfo.orgid)
if (orginfo.parentOrgId != null) {
await HrvApi.applySuperiorReview(row.id, orginfo.parentOrgId)
ElMessage.success(`${row.name} 申请成功`)
@ -1732,7 +1683,7 @@ const handlePrintNewReport = () => {
width: 100%;
height: 100%;
}
.print-image {
width: 100%;
height: 100%;
@ -1742,20 +1693,20 @@ const handlePrintNewReport = () => {
page-break-after: avoid;
page-break-before: avoid;
}
@media print {
@page {
size: landscape;
margin: 0;
}
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
.print-image {
width: 100%;
height: 100%;
@ -1770,7 +1721,7 @@ const handlePrintNewReport = () => {
</style>
</head>
<body>
<img src="${newReportImageUrl.value}" alt="报告" class="print-image">
<img src="${newReportImageUrl.value}" alt="报告" class="print-image">
</body>
</html>
`
@ -1802,70 +1753,6 @@ const handlePrintNewReport = () => {
}
}
/** 下载 */
const handleDownload = async (row) => {
//
row.downloading = true
row.downloadProgress = 0
//
const progressInterval = setInterval(() => {
if (row.downloadProgress < 90) {
row.downloadProgress += 5 // 25%
}
}, 2000) // 2
try {
//
row.downloadProgress = 10
await new Promise((resolve) => setTimeout(resolve, 200))
//
const response = await fetch('http://localhost:48082/api/download-file', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
fileName: `${row.examid}`
})
})
const result = await response.json()
//
clearInterval(progressInterval)
//
if (result.success) {
if (result.message === '文件不存在于服务器') {
ElMessage.error('文件不存在于服务器')
} else {
//
row.downloadProgress = 100
// 100%
await new Promise((resolve) => {
setTimeout(() => {
resolve(true)
}, 500)
})
ElMessage.success('下载成功')
}
} else {
ElMessage.error(result.message || '下载失败')
}
} catch (error) {
clearInterval(progressInterval)
console.error('下载失败:', error)
ElMessage.error('下载失败,请重试')
} finally {
//
row.downloading = false
row.downloadProgress = 0
}
}
/** 导出 */
const handleExport = async () => {
exportLoading.value = true
@ -2207,7 +2094,6 @@ onMounted(async () => {
.analysis-btn,
.upload-btn,
.download-btn,
.apply-btn,
.new-report-btn {
border-radius: 12px;
@ -2231,10 +2117,6 @@ onMounted(async () => {
background: linear-gradient(135deg, #4facfe, #00f2fe);
}
.download-btn {
background: linear-gradient(135deg, #43e97b, #38f9d7);
}
.apply-btn {
background: linear-gradient(135deg, #ff9a56, #ff6b6b);
}
@ -2884,43 +2766,6 @@ onMounted(async () => {
}
}
//
.download-progress {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
height: 32px;
padding: 0 8px;
border-radius: 6px;
background: #f0f8ff;
border: 1px solid #91d5ff;
.progress-bar {
flex: 1;
height: 8px;
:deep(.el-progress-bar__outer) {
background-color: #e6f7ff;
border-radius: 4px;
}
:deep(.el-progress-bar__inner) {
background: linear-gradient(135deg, #52c41a, #73d13d);
border-radius: 4px;
transition: width 0.3s ease;
}
}
.progress-text {
font-size: 11px;
font-weight: 600;
color: #52c41a;
min-width: 30px;
text-align: center;
}
}
//
.wear-time-display {
display: flex;