From 0db8c9b94a9ac655549d5eba5c2a6c92ac386c06 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期四, 08 十月 2026 11:20:56 +0800
Subject: [PATCH] 提交最新代码
---
culture/src/views/strainReportLibrary/reportLibraryOne/add.vue | 78 +++++++++++----------------------------
1 files changed, 22 insertions(+), 56 deletions(-)
diff --git a/culture/src/views/strainReportLibrary/reportLibraryOne/add.vue b/culture/src/views/strainReportLibrary/reportLibraryOne/add.vue
index c83f700..489bafb 100644
--- a/culture/src/views/strainReportLibrary/reportLibraryOne/add.vue
+++ b/culture/src/views/strainReportLibrary/reportLibraryOne/add.vue
@@ -161,7 +161,7 @@
<script>
import AiEditor from '@/components/AiEditor'
import ChooseProject from '@/components/chooseProject/index.vue'
-import { customUploadRequest, getFullUrl ,downloadFileByUrl,getAllocateIp,isImageFile} from "@/utils/utils";
+import { customUploadRequest, getFullUrl, downloadFileByUrl, getAllocateIp, getUploadedFilePath, isImageFile, normalizeFileList } from "@/utils/utils";
import SelectMember from '@/components/SelectMember'
import { add, getDetail, update } from './service'
@@ -255,6 +255,9 @@
};
},
activated() {
+ if (!["/strainReportLibrary/add", "/strainReportLibrary/detail"].includes(this.$route.path)) {
+ return;
+ }
if (this.cacheData) {
// 恢复表单数据
this.form = JSON.parse(JSON.stringify(this.cacheData.form));
@@ -285,41 +288,6 @@
this.$nextTick(() => {
window.scrollTo(0, 0);
});
-
- if (this.$route.query.id && !this.cacheData) {
- getDetail(this.$route.query.id).then(res => {
- const data = res.data || res;
-
- this.form = {
- ...this.form,
- ...data,
- processData: []
- };
-
- let arr = data.evaluate.split(',')
- this.fileList = (data.enclosureUrl ? JSON.parse(data.enclosureUrl) : [])
- this.assessmentTable = this.assessmentTable.map((item, index) => {
- item.selectedScore = Number(arr[index])
- return item
- })
-
- this.selectedMember = [{
- nickName: data.experimentName,
- userId: data.experimentId
- }]
-
- this.projectData = data.projectTeam ?
- [{ ...data.projectTeam, staffName: data.projectTeam.staff || '' }] :
- [];
-
- console.log('qwe45645664', this.tableData);
-
-
-
- }).catch(err => {
- this.$message.error('获取详情失败');
- });
- }
},
methods: {
// 👇 添加这个方法
@@ -333,8 +301,8 @@
processData: []
};
- let arr = data.evaluate.split(',')
- this.fileList = (data.enclosureUrl ? JSON.parse(data.enclosureUrl) : [])
+ const arr = String(data.evaluate || '').split(',')
+ this.fileList = normalizeFileList(data.enclosureUrl)
this.assessmentTable = this.assessmentTable.map((item, index) => {
item.selectedScore = Number(arr[index])
return item
@@ -366,11 +334,9 @@
// 图片文件:使用 window.open 预览
if (file.url && file.url.startsWith('http')) {
console.log('图片链接', file.url)
- window.open(file.url, '_blank');
+ window.open(getFullUrl(file.url), '_blank');
} else {
- let newUrl = getAllocateIp() + file.url;
- console.log('图片链接', newUrl)
- window.open(newUrl, '_blank');
+ window.open(getFullUrl(file.url), '_blank');
}
} else {
// 非图片文件:使用下载方式
@@ -390,11 +356,12 @@
customUploadRequest({
file,
onSuccess: (res) => {
- if (res.code === 200) {
+ const uploadedPath = getUploadedFilePath(res)
+ if (uploadedPath) {
const fileObj = {
id: new Date().getTime(),
reportId: this.$route.query.id ? this.$route.query.id : "",
- fileUrl: res.msg || res.data || "",
+ fileUrl: uploadedPath,
reportType: 2, // 报告类型
fileName: file.name,
fileSize: file.size,
@@ -403,17 +370,15 @@
// 添加到文件列表显示
this.fileList.push({
name: file.name,
- url: getFullUrl(fileObj.fileUrl),
+ url: fileObj.fileUrl,
uid: fileObj.id,
});
- // 添加到表单数据
- this.form.feasibilityReportFiles.push(fileObj);
this.$message.success("文件上传成功");
onSuccess(res);
}else {
- this.$message.error("文件上传失败");
- onError(res.msg);
+ this.$message.error(res && res.msg ? res.msg : "上传接口未返回文件地址");
+ onError(new Error('missing uploaded file path'));
}
},
onError: (err) => {
@@ -427,7 +392,6 @@
const index = this.fileList.findIndex((item) => item.name === file.name);
if (index !== -1) {
this.fileList.splice(index, 1);
- this.form.feasibilityReportFiles.splice(index, 1);
}
},
addData() {
@@ -460,7 +424,7 @@
isDraft: 0,
projectId: this.projectData[0].id,
experimentId: this.selectedMember[0].userId,
- enclosureUrl: this.fileList.length && JSON.stringify(this.fileList),
+ enclosureUrl: JSON.stringify(this.fileList),
// reportCode: this.form.reportCode,
reportContent: this.$refs.materialEditor.getContent(),
reportName: this.form.reportName,
@@ -475,7 +439,7 @@
if (res.code == 200) {
this.$message.success('编辑成功');
this.cacheData = null;
- this.$router.back()
+ this.$closeCurrentView('/strainReportLibrary/reportLibraryOne')
} else {
this.$message.error(res.msg || '编辑失败');
this.submitLoading = false;
@@ -489,7 +453,7 @@
if (res.code == 200) {
this.$message.success('发送成功');
this.cacheData = null;
- this.$router.push('/strainReportLibrary/reportLibraryOne');
+ this.$closeCurrentView('/strainReportLibrary/reportLibraryOne');
} else {
this.$message.error(res.msg || '发送失败');
this.submitLoading = false;
@@ -511,7 +475,7 @@
isDraft: 1,
projectId: this.projectData[0].id,
experimentId: this.selectedMember[0].userId,
- enclosureUrl: this.fileList.length && JSON.stringify(this.fileList),
+ enclosureUrl: JSON.stringify(this.fileList),
// reportCode: this.form.reportCode,
reportContent: this.$refs.materialEditor.getContent(),
reportName: this.form.reportName,
@@ -525,7 +489,8 @@
this.submitLoading = false;
if (res.code == 200) {
this.$message.success('编辑成功');
- this.$router.back()
+ this.cacheData = null;
+ this.$closeCurrentView('/strainReportLibrary/reportLibraryOne')
} else {
this.$message.error(res.msg || '编辑失败');
this.submitLoading = false;
@@ -537,7 +502,8 @@
this.submitLoading = false;
if (res.code == 200) {
this.$message.success('保存成功');
- this.$router.push('/strainReportLibrary/reportLibraryOne');
+ this.cacheData = null;
+ this.$closeCurrentView('/strainReportLibrary/reportLibraryOne');
} else {
this.$message.error(res.msg || '保存失败');
this.submitLoading = false;
--
Gitblit v1.7.1