From 9dcad0c65f2564fc2fe43e21b23f9faf4a073d30 Mon Sep 17 00:00:00 2001
From: 董国庆 <364620639@qq.com>
Date: 星期二, 28 四月 2026 13:49:47 +0800
Subject: [PATCH] fix: 修复多个页面样式、交互及路由问题
---
laboratory/src/views/chemistQa/projectTesting/add.vue | 74 ++++++++++++++++++++----------------
1 files changed, 41 insertions(+), 33 deletions(-)
diff --git a/laboratory/src/views/chemistQa/projectTesting/add.vue b/laboratory/src/views/chemistQa/projectTesting/add.vue
index 12d87cf..8c3ab70 100644
--- a/laboratory/src/views/chemistQa/projectTesting/add.vue
+++ b/laboratory/src/views/chemistQa/projectTesting/add.vue
@@ -120,6 +120,7 @@
import chooseProject from '@/components/chooseProject'
import ShowDelConfirm from "@/components/showDelConfirm/index.vue";
import { addData, editData, getDetail,revokedReport,deleteDetail } from './service'
+import { mapState } from "vuex";
export default {
name: "AddProjectTesting",
@@ -133,6 +134,7 @@
isDetail: false,
currentType: 'list', // 当前显示类型:list-列表,draft-草稿箱
expandRowKeys: [],
+ allReportTableData: [],
reportTableData: [],
reportTotal: 0,
form: {
@@ -164,35 +166,33 @@
}
},
mounted() {
- const routeName = this.$route.name;
- if (routeName === "EditProjectTesting" && this.$route.query.id) {
- if (this.$route.query.type === 'detail') {
- this.isDetail = true
- } else if (this.$route.query.type === 'edit') {
- this.isEdit = true
- }
- this.getDetail()
- }
- if (this.$route.query.itemId) {
- this.itemId = this.$route.query.itemId
- }
- },
- activated() {
- const routeId = this.$route.query.id;
- const routeName = this.$route.name;
-
- // 如果是编辑路由,且id发生变化,重新加载数据
- if (routeName === "EditProjectTesting" && routeId && routeId !== this.form.id) {
- if (this.$route.query.type === 'detail') {
- this.isDetail = true
- } else if (this.$route.query.type === 'edit') {
- this.isEdit = true
- }
- this.getDetail()
- }
- // 如果是新增路由,不重置表单,保留用户填写的数据
- },
+ this.initPageMode();
+ this.initRouteData();
+ },
+ activated() {
+ this.initPageMode();
+ this.itemId = this.$route.query.itemId || null;
+
+ const routeId = this.$route.query.id;
+ if ((this.isEdit || this.isDetail) && routeId && routeId !== this.form.id) {
+ this.getDetail();
+ }
+ },
+ computed: {
+ ...mapState(["tagList"])
+ },
methods: {
+ initPageMode() {
+ const routeName = this.$route.name;
+ this.isEdit = routeName === 'EditProjectTesting';
+ this.isDetail = routeName === 'DetailProjectTesting';
+ },
+ initRouteData() {
+ this.itemId = this.$route.query.itemId || null;
+ if ((this.isEdit || this.isDetail) && this.$route.query.id) {
+ this.getDetail();
+ }
+ },
getDetail() {
getDetail(this.$route.query.id).then(res => {
if (res) {
@@ -220,6 +220,14 @@
this.$forceUpdate()
this.showChoose = false
},
+ backToListAndCloseTag() {
+ const currentPath = this.$route.path;
+ this.$router.push('/chemistQa/projectTesting');
+ this.$store.commit(
+ "SET_TAGLIST",
+ this.tagList.filter((item) => item.path !== currentPath)
+ );
+ },
submit() {
if (this.tableData.length === 0) {
this.$message.error('请选择项目组')
@@ -236,7 +244,7 @@
request.then(res => {
if (res.code === 200) {
this.$message.success(this.isEdit ? '修改成功' : '提交成功')
- this.$router.push('/chemistQa/projectTesting')
+ this.backToListAndCloseTag()
} else {
this.$message.error(res.msg || (this.isEdit ? '修改失败' : '提交失败'))
}
@@ -263,7 +271,7 @@
request.then(res => {
if (res.code === 200) {
this.$message.success(this.isEdit ? '修改成功' : '保存成功')
- this.$router.push('/chemistQa/projectTesting')
+ this.backToListAndCloseTag()
} else {
this.$message.error(res.msg || (this.isEdit ? '修改失败' : '保存失败'))
}
@@ -292,7 +300,7 @@
path: '/chemistQa/addDetectionReport',
query: {
id: row.id,
- itemId: this.$route.query.id,
+ itemId: this.form.id || this.$route.query.id,
type: 'detail'
}
})
@@ -319,7 +327,7 @@
path: '/chemistQa/addDetectionReport',
query: {
id: row.id,
- itemId: this.$route.query.id,
+ itemId: this.form.id || this.$route.query.id,
type: 'edit'
}
})
@@ -536,4 +544,4 @@
margin-bottom: 20px;
}
}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.7.1