工具-数据对接

main
ysn 3 days ago
parent 837ffacdb8
commit 20768dc853
  1. 2
      src/views/cases/index.vue
  2. 80
      src/views/knowledge/index.vue
  3. 47
      src/views/utility/index.vue

@ -1177,7 +1177,7 @@ export default {
},
//
handleView(row) {
this.$tab.openPage(row.patient_name + row.id, "/cases/detail/" + row.id);
this.$tab.openPage(row.patient_name + "-" + row.id, "/cases/detail/" + row.id);
},
},
};

@ -674,14 +674,17 @@ export default {
this.uploadProgressDialogVisible = true;
this.uploadPercent = 0;
//
const recordId = this.createTransferRecord(file);
// MinIO
this.uploadToMinio(file);
this.uploadToMinio(file, recordId);
//
event.target.value = "";
},
// MinIO PDF
async uploadToMinio(file) {
async uploadToMinio(file, recordId) {
try {
// MinIO
await this.ensureMinioInitialized();
@ -713,7 +716,8 @@ export default {
result.objectName,
file,
result.thumbnailPath,
bucket
bucket,
recordId
);
//
@ -727,6 +731,8 @@ export default {
console.error("上传失败:", error);
this.uploadProgressDialogVisible = false;
this.$modal.msgError("上传失败: " + error.message);
//
this.updateTransferRecord(recordId, false, "");
}
},
// MinIO
@ -738,7 +744,7 @@ export default {
}
},
//
async saveKnowledgeToDB(filePath, file, thumbnailPath = "", bucket = "") {
async saveKnowledgeToDB(filePath, file, thumbnailPath = "", bucket = "", recordId = null) {
console.log("saveKnowledgeToDB:", filePath, file, thumbnailPath, bucket);
// bucket/object
@ -764,6 +770,72 @@ export default {
};
await postKnowledgeCreate(data);
console.log("知识库记录保存成功");
//
if (recordId) {
const minioEndpoint = this.$store.state.user.netConfig?.MINIO_ENDPOINT_HTTPS?.trim() || "http://47.92.6.51:9100/";
const fileUrl = minioEndpoint + fullFilePath;
this.updateTransferRecord(recordId, true, fileUrl);
}
},
//
createTransferRecord(file) {
const STORAGE_KEY = "file_transfer_records";
try {
//
const existingData = localStorage.getItem(STORAGE_KEY);
const records = existingData ? JSON.parse(existingData) : [];
// ID
const recordId = Date.now() + "_" + Math.random().toString(36).substr(2, 9);
// transfer_type: 3
const newRecord = {
id: recordId,
file_name: file.name,
file_size: file.size,
time: new Date().toISOString(),
transfer_type: 3, // 3
is_success: false, //
is_uploading: true, //
file_url: "",
};
//
records.unshift(newRecord);
// localStorage
localStorage.setItem(STORAGE_KEY, JSON.stringify(records));
console.log("上传记录已创建:", newRecord);
return recordId;
} catch (e) {
console.error("创建上传记录失败", e);
return null;
}
},
//
updateTransferRecord(recordId, isSuccess, fileUrl = "") {
const STORAGE_KEY = "file_transfer_records";
try {
//
const existingData = localStorage.getItem(STORAGE_KEY);
const records = existingData ? JSON.parse(existingData) : [];
//
const recordIndex = records.findIndex(record => record.id === recordId);
if (recordIndex !== -1) {
records[recordIndex].is_success = isSuccess;
records[recordIndex].is_uploading = false; //
if (fileUrl) {
records[recordIndex].file_url = fileUrl;
}
// localStorage
localStorage.setItem(STORAGE_KEY, JSON.stringify(records));
console.log("上传记录已更新:", records[recordIndex]);
}
} catch (e) {
console.error("更新上传记录失败", e);
}
},
},
};

@ -71,7 +71,7 @@
:type="
getStatusType(
scope.row.transfer_type,
scope.row.is_success
scope.row
)
"
size="mini"
@ -79,7 +79,7 @@
{{
getStatusText(
scope.row.transfer_type,
scope.row.is_success
scope.row
)
}}
</el-tag>
@ -247,31 +247,30 @@ export default {
return iconMap[suffix] || "el-icon-document";
},
// Qt UpdateTransferStatus
// type: 1=upload, 3=download, 9=other
getStatusText(type, isSuccess) {
// Qt switch(type << isSuccess)
const key = type << (isSuccess ? 1 : 0);
const statusMap = {
1: "上传中", // upload=1, is_success=false -> 1 << 0 = 1 ()
2: "上传成功", // upload=1, is_success=true -> 1 << 1 = 2
3: "下载中", // download=3, is_success=false -> 3 << 0 = 3 ()
6: "下载成功", // download=3, is_success=true -> 3 << 1 = 6
9: "其他", // other=9
18: "其他完成", // other=9, is_success=true -> 9 << 1 = 18
};
//
if (!isSuccess && key === 1) return "上传失败";
if (!isSuccess && key === 3) return "下载失败";
return statusMap[key] || "未知";
//
getStatusText(type, row) {
const isSuccess = row.is_success;
const isUploading = row.is_uploading;
if (type === 3) {
//
if (isUploading && !isSuccess) return "上传中";
if (!isSuccess) return "上传失败";
return "上传成功";
}
//
if (!isSuccess) return "失败";
return "成功";
},
// Element UI
getStatusType(type, isSuccess) {
getStatusType(type, row) {
const isSuccess = row.is_success;
const isUploading = row.is_uploading;
if (isUploading && !isSuccess) return "warning";
if (!isSuccess) return "danger";
if (type === 1) return "success";
if (type === 3) return "success";
return "info";
return "success";
},
//
@ -284,7 +283,7 @@ export default {
},
//
handleOpenLocation(item) {
if (item.local_path) {
if (item.file_url) {
this.$modal.msg("浏览器安全限制:请下载后在下载列表打开文件夹");
const a = document.createElement("a");
a.href = item.file_url;

Loading…
Cancel
Save