|
|
|
|
@ -19,6 +19,7 @@ |
|
|
|
|
:data="form.attachment" |
|
|
|
|
:show-header="false" |
|
|
|
|
height="calc(100vh - 239px)" |
|
|
|
|
@row-dblclick="handleAttachmentClick" |
|
|
|
|
> |
|
|
|
|
<el-table-column align="center"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
@ -42,7 +43,7 @@ |
|
|
|
|
<el-button |
|
|
|
|
type="text" |
|
|
|
|
icon="el-icon-delete" |
|
|
|
|
@click="handleDeleteImg(scope.row)" |
|
|
|
|
@click="handleDeleteImg(scope.row, scope.$index)" |
|
|
|
|
v-if="form.status == 1 || form.status == 5" |
|
|
|
|
> |
|
|
|
|
删除 |
|
|
|
|
@ -640,6 +641,7 @@ import { mapGetters } from "vuex"; |
|
|
|
|
// 导入打印组件 |
|
|
|
|
import UltrasoundReportPrint from "./components/UltrasoundReportPrint.vue"; |
|
|
|
|
import CreateGroupDialog from "@/views/message/components/CreateGroupDialog"; |
|
|
|
|
import { uploadFile } from "@/utils/requestMinio"; |
|
|
|
|
export default { |
|
|
|
|
name: "CaseDetail", |
|
|
|
|
components: { |
|
|
|
|
@ -729,44 +731,21 @@ export default { |
|
|
|
|
handleOpenFile() { |
|
|
|
|
this.$refs.fileInput.click(); |
|
|
|
|
}, |
|
|
|
|
async handleFileChange(e) { |
|
|
|
|
const files = e.target.files || []; |
|
|
|
|
for (let file of files) { |
|
|
|
|
// 验证文件类型(只能上传图片) |
|
|
|
|
if (!file.type.startsWith("image/")) { |
|
|
|
|
this.$modal.msgError("只能上传图片文件"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 创建预览 URL |
|
|
|
|
const previewUrl = URL.createObjectURL(file); |
|
|
|
|
|
|
|
|
|
// 添加到列表,标记为上传中 |
|
|
|
|
const tempId = Date.now(); |
|
|
|
|
this.form.attachment.push({ |
|
|
|
|
id: tempId, |
|
|
|
|
previewUrl, |
|
|
|
|
uploading: true, |
|
|
|
|
uploadPercent: 0, |
|
|
|
|
file, // 保存文件对象用于上传 |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 开始上传 |
|
|
|
|
async handleFileChange(event) { |
|
|
|
|
const file = event.target.files[0]; |
|
|
|
|
if (!file) return; |
|
|
|
|
try { |
|
|
|
|
await this.uploadImageToMinIO(tempId, file); |
|
|
|
|
await this.uploadImageToMinIO(file); |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error("影像上传失败:", error); |
|
|
|
|
this.$modal.msgError(`上传失败:${error.message}`); |
|
|
|
|
// 移除上传失败的项目 |
|
|
|
|
this.form.attachment = this.form.attachment.filter( |
|
|
|
|
(i) => i.id !== tempId |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
console.error("超声影像上传失败:", error); |
|
|
|
|
this.$modal.msgError("超声影像上传失败: " + error.message); |
|
|
|
|
} finally { |
|
|
|
|
// 清空文件输入 |
|
|
|
|
event.target.value = ""; |
|
|
|
|
} |
|
|
|
|
e.target.value = ""; |
|
|
|
|
}, |
|
|
|
|
// 上传图片到 MinIO |
|
|
|
|
async uploadImageToMinIO(tempId, file) { |
|
|
|
|
// 上传头像到 MinIO |
|
|
|
|
async uploadImageToMinIO(file) { |
|
|
|
|
try { |
|
|
|
|
// 确保 MinIO 配置已加载 |
|
|
|
|
await this.ensureMinioInitialized(); |
|
|
|
|
@ -775,55 +754,31 @@ export default { |
|
|
|
|
const bucket = config.MINIO_BUCKET_REPORT || "remote-avatar-test"; |
|
|
|
|
const timestamp = Date.now(); |
|
|
|
|
const ext = file.name.split(".").pop() || "png"; |
|
|
|
|
const fileNameWithoutExt = file.name.replace(/\.[^/.]+$/, ""); |
|
|
|
|
const randomStr = Math.random().toString(36).substr(2, 6); |
|
|
|
|
|
|
|
|
|
// 原始文件路径(大文件) |
|
|
|
|
const objectKey = `attachments/${ |
|
|
|
|
this.form.id || 0 |
|
|
|
|
}/${fileNameWithoutExt}.${timestamp}_${randomStr}_big.${ext}`; |
|
|
|
|
// 压缩文件路径(小文件) |
|
|
|
|
const objectCompress = `attachments/${ |
|
|
|
|
this.form.id || 0 |
|
|
|
|
}/${fileNameWithoutExt}.${timestamp}_${randomStr}_small.${ext}`; |
|
|
|
|
const fileName = `${timestamp}.${ext}`; |
|
|
|
|
const objectName = `attachments/${this.form.id}/${fileName}`; |
|
|
|
|
|
|
|
|
|
console.log( |
|
|
|
|
`Uploading ultrasound image to bucket: ${bucket}, object: ${objectKey}` |
|
|
|
|
`Uploading avatar to bucket: ${bucket}, object: ${objectName}` |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// 使用 MinIO 上传 |
|
|
|
|
const result = await uploadFile( |
|
|
|
|
bucket, |
|
|
|
|
objectKey, |
|
|
|
|
objectName, |
|
|
|
|
file, |
|
|
|
|
{}, |
|
|
|
|
(percent) => { |
|
|
|
|
// 更新上传进度 |
|
|
|
|
const item = this.form.attachment.find((i) => i.id === tempId); |
|
|
|
|
if (item) { |
|
|
|
|
item.uploadPercent = Math.round(percent); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
(percent) => {} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
console.log("MinIO 上传成功:", result); |
|
|
|
|
|
|
|
|
|
// 更新上传成功的记录 - 按照预期数据结构 |
|
|
|
|
const item = this.form.attachment.find((i) => i.id === tempId); |
|
|
|
|
if (item) { |
|
|
|
|
item.bucketName = bucket; |
|
|
|
|
item.bucket_compress = bucket; |
|
|
|
|
item.fileType = "CT"; |
|
|
|
|
item.objectKey = objectKey; |
|
|
|
|
item.object_compress = objectCompress; |
|
|
|
|
item.showInDoc = 0; |
|
|
|
|
item.uploading = false; |
|
|
|
|
item.uploadPercent = 100; |
|
|
|
|
delete item.file; // 删除文件对象释放内存 |
|
|
|
|
delete item.previewUrl; // 删除预览URL |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.$message.success("影像上传成功"); |
|
|
|
|
this.form.attachment.push({ |
|
|
|
|
bucketName: bucket, |
|
|
|
|
bucket_compress: bucket, |
|
|
|
|
fileType: "CT", |
|
|
|
|
objectKey: objectName, |
|
|
|
|
object_compress: objectName, |
|
|
|
|
showInDoc: 0, |
|
|
|
|
}); |
|
|
|
|
} catch (error) { |
|
|
|
|
throw error; |
|
|
|
|
} |
|
|
|
|
@ -836,13 +791,19 @@ export default { |
|
|
|
|
await this.$store.dispatch("GetNetConfig"); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
handleDeleteImg(row) { |
|
|
|
|
this.$confirm("确定删除该影像?").then(() => { |
|
|
|
|
this.form.attachment = this.form.attachment.filter( |
|
|
|
|
(i) => i.id !== row.id |
|
|
|
|
); |
|
|
|
|
this.$message.success("删除成功"); |
|
|
|
|
}); |
|
|
|
|
handleAttachmentClick(row) { |
|
|
|
|
row.showInDoc = 1; |
|
|
|
|
}, |
|
|
|
|
handleDeleteImg(row, index) { |
|
|
|
|
this.$modal |
|
|
|
|
.confirm("确定删除该影像?") |
|
|
|
|
.then(function () { |
|
|
|
|
return this.form.attachment.splice(index, 1); |
|
|
|
|
}) |
|
|
|
|
.then(() => { |
|
|
|
|
this.$modal.msgSuccess("删除成功"); |
|
|
|
|
}) |
|
|
|
|
.catch(() => {}); |
|
|
|
|
}, |
|
|
|
|
// 根据路由参数获取病例数据 |
|
|
|
|
getReportInfo(id) { |
|
|
|
|
@ -877,6 +838,7 @@ export default { |
|
|
|
|
// // 构建提交参数,确保格式与后端接口一致 |
|
|
|
|
return postReportEdit({ |
|
|
|
|
// 基本信息 |
|
|
|
|
attachment: JSON.stringify(form.attachment || []), |
|
|
|
|
area_number: form.area_number || "", |
|
|
|
|
bed_number: form.bed_number || "", |
|
|
|
|
comment: form.comment || "", |
|
|
|
|
@ -936,7 +898,12 @@ export default { |
|
|
|
|
this.$refs.UltrasoundReportPrintRef.print(this.form); |
|
|
|
|
}, |
|
|
|
|
handleClose() { |
|
|
|
|
this.$modal |
|
|
|
|
.confirm("尚有修改未提交,是否确定退出") |
|
|
|
|
.then(() => { |
|
|
|
|
this.$router.back(); |
|
|
|
|
}) |
|
|
|
|
.catch(() => {}); |
|
|
|
|
}, |
|
|
|
|
handleShare() { |
|
|
|
|
this.$refs.createGroupDialogRef.show(); |
|
|
|
|
|