From 527efb36f35b471710e445972673abff45bacdac Mon Sep 17 00:00:00 2001
From: 董国庆 <364620639@qq.com>
Date: 星期五, 12 九月 2025 17:36:09 +0800
Subject: [PATCH] 401跳转登录

---
 laboratory/src/views/dataManagement/confirmation-sheet/components/add.vue |  139 +++++++++++++++++++---------------------------
 1 files changed, 57 insertions(+), 82 deletions(-)

diff --git a/laboratory/src/views/dataManagement/confirmation-sheet/components/add.vue b/laboratory/src/views/dataManagement/confirmation-sheet/components/add.vue
index 6eec636..8b64ebe 100644
--- a/laboratory/src/views/dataManagement/confirmation-sheet/components/add.vue
+++ b/laboratory/src/views/dataManagement/confirmation-sheet/components/add.vue
@@ -50,19 +50,11 @@
       <el-button type="primary" @click="handleSubmit">提交确认单</el-button>
       <el-button @click="handleSaveDraft">存草稿</el-button>
     </div>
-    <experimentalScheduling :show="showScheduling" @close="showScheduling = false" @submit="setSelectedScheduling"/>
-    <add-test-item
-      :dialogVisible="testItemDialogVisible"
-      :editData="currentTestItem"
-      @close="handleTestItemDialogClose"
-      @confirm="handleTestItemConfirm"
-    />
-    <confirm-dialog
-      :visible.sync="confirmDialogVisible"
-      :formData="confirmFormData"
-      :sampleData="testItems"
-      @confirm="handleConfirmSubmit"
-    />
+    <experimentalScheduling :show="showScheduling" @close="showScheduling = false" @submit="setSelectedScheduling" />
+    <add-test-item :dialogVisible="testItemDialogVisible" :editData="currentTestItem" @close="handleTestItemDialogClose"
+      @confirm="handleTestItemConfirm" />
+    <confirm-dialog :visible.sync="confirmDialogVisible" :formData="confirmFormData" :sampleData="testItems"
+      @confirm="handleConfirmSubmit" />
   </Card>
 </template>
 
@@ -71,7 +63,7 @@
 import AddTestItem from './add-test-item.vue'
 import ConfirmDialog from './confirm-dialog.vue'
 import { add, update, getDetail } from '../service'
-
+import { mapState } from "vuex";
 export default {
   name: 'AddConfirmationSheet',
   components: {
@@ -102,7 +94,6 @@
         planName: '', // 项目课题方案名称
         testCode: '', // 实验编号
         testName: '', // 实验名称
-        sampleCode: '' // 取样单编号
       },
       selectedScheduling: null, // 添加选中的实验调度数据
       currentTestItem: null, // 当前编辑的检测项
@@ -129,36 +120,37 @@
       this.getDetailData(id)
     }
   },
+  computed: {
+    ...mapState(["tagList", "isFold"]),
+  },
   mounted() { },
   methods: {
     setSelectedScheduling(data) {
-      console.log('data',data)
       if (!data || data.length === 0) return;
       const selectedData = data[0]; // 获取选中的第一条数据
       this.selectedScheduling = selectedData;
-      
+
       // 更新表格数据
       this.tableData = [{
         planCode: selectedData.projectName || '', // 所属项目课题方案
         planName: selectedData.experimentCode || '', // 实验编号
         testName: selectedData.experimentName || '', // 实验名称
-        notifyTime: selectedData.experimentDate || '', // 通知时间
+        notifyTime: selectedData.createTime || '', // 通知时间
         startTime: selectedData.experimentStartTime || '', // 实验开始时间
         endTime: selectedData.experimentEndTime || '', // 实验结束时间
         participants: selectedData.participantsName || '', // 参加人员
         status: this.getStatusText(selectedData.status) // 状态
       }];
       this.total = this.tableData.length;
-      
+
       // 更新确认表单数据
       this.confirmFormData = {
         planName: selectedData.projectName || '',
         testCode: selectedData.experimentCode || '',
         testName: selectedData.experimentName || '',
-        sampleCode: selectedData.experimentCode || '' // 使用实验编号作为取样单编号
       };
     },
-    
+
     // 添加状态转换方法
     getStatusText(status) {
       const statusMap = {
@@ -194,7 +186,7 @@
             obj.roleId = this.$route.query.roleId
             edit(obj).then(() => {
               this.msgsuccess('保存成功')
-              this.$router.go(-1)
+              this.back()
             })
           } else {
             add(obj).then(() => {
@@ -204,7 +196,7 @@
                 remark: "",
               }
               this.menu = []
-              this.$router.go(-1)
+              this.back()
             })
           }
         }
@@ -338,7 +330,7 @@
       }).then(() => {
         this.testItems.splice(index, 1)
         this.$message.success('删除成功')
-      }).catch(() => {})
+      }).catch(() => { })
     },
     generateUniqueId() {
       return 'test_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9)
@@ -357,7 +349,6 @@
         planName: this.selectedScheduling.projectName || '', // 所属项目课题方案
         testCode: this.selectedScheduling.experimentCode || '', // 实验编号
         testName: this.selectedScheduling.experimentName || '', // 实验名称
-        sampleCode: this.selectedScheduling.experimentCode || '' // 取样单编号
       }
       this.confirmDialogVisible = true
     },
@@ -367,10 +358,10 @@
         const submitData = {
           dispatchId: this.selectedScheduling.id, // 实验调度ID
           auditStatus: 1, // 待确认状态
-          confirmSign:'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'|| signatureImage, // 签字图片
+          confirmSign: signatureImage, // 签字图片
           signTime: new Date().toISOString(), // 签字时间
           testMethodConfirmSheetTerms: this.testItems.map(item => ({
-            id: item.id, // 保留原有ID(编辑时使用)
+            id: '', // 保留原有ID(编辑时使用)
             termCode: item.termCode,
             termName: item.termName,
             termType: item.termType,
@@ -381,27 +372,27 @@
             testId: item.testId
           }))
         }
-
-        // 打印提交参数
-        console.log('提交确认单参数:', JSON.stringify(submitData, null, 2))
-
-        // 根据是否有 id 决定调用新增还是更新接口
         if (this.formData.id) {
           submitData.id = this.formData.id
-          console.log('调用更新接口,参数:', JSON.stringify(submitData, null, 2))
           await update(submitData)
           this.$message.success('更新成功')
         } else {
-          console.log('调用新增接口,参数:', JSON.stringify(submitData, null, 2))
           await add(submitData)
           this.$message.success('提交成功')
         }
-        
+
         this.confirmDialogVisible = false // 关闭弹窗
-        this.$router.go(-1)
+        this.back()
       } catch (error) {
         this.$message.error((this.formData.id ? '更新' : '提交') + '失败:' + (error.message || '未知错误'))
       }
+    },
+    back() {
+      this.$router.back();
+      this.$store.commit(
+        "SET_TAGLIST",
+        this.tagList.filter((item) => item.path !== this.$route.path)
+      );
     },
     async handleSaveDraft() {
       try {
@@ -415,7 +406,7 @@
           dispatchId: this.selectedScheduling.id,
           auditStatus: -1, // 草稿箱状态
           testMethodConfirmSheetTerms: this.testItems.map(item => ({
-            id: item.id, // 保留原有ID(编辑时使用)
+            id: '', // 保留原有ID(编辑时使用)
             termCode: item.termCode,
             termName: item.termName,
             termType: item.termType,
@@ -428,20 +419,16 @@
         }
 
         // 打印草稿参数
-        console.log('保存草稿参数:', JSON.stringify(draftData, null, 2))
-
         // 根据是否有 id 决定调用新增还是更新接口
         if (this.formData.id) {
           draftData.id = this.formData.id
-          console.log('调用更新草稿接口,参数:', JSON.stringify(draftData, null, 2))
           await update(draftData)
           this.$message.success('更新草稿成功')
         } else {
-          console.log('调用新增草稿接口,参数:', JSON.stringify(draftData, null, 2))
           await add(draftData)
           this.$message.success('保存草稿成功')
         }
-        
+
         this.$router.push('/dataManagement/confirmation-sheet')
       } catch (error) {
         this.$message.error((this.formData.id ? '更新' : '保存') + '草稿失败:' + (error.message || '未知错误'))
@@ -450,59 +437,47 @@
     async getDetailData(id) {
       try {
         const res = await getDetail({ id })
-        if (res.data) {
+        if (res) {
           // 设置实验调度数据
           this.selectedScheduling = {
-            id: res.data.dispatchId,
-            // ... 其他调度相关字段
+            ...res,
+            id: res.dispatchId,
           }
-          
+          this.tableData = [{
+            // planCode: res.projectName,
+            // planName: res.experimentCode,
+            // testName: res.experimentName,
+            // notifyTime: res.experimentDate,
+
+            planCode: res.projectName || '', // 所属项目课题方案
+            planName: res.experimentCode || '', // 实验编号
+            testName: res.experimentName || '', // 实验名称
+            notifyTime: res.experimentDate || '', // 通知时间
+            startTime: res.experimentStartTime || '', // 实验开始时间
+            endTime: res.experimentEndTime || '', // 实验结束时间
+            participants: res.participantsName || '', // 参加人员
+            status: this.getStatusText(res.status) // 状态
+
+          }]
+
           // 设置检测项数据
-          this.testItems = res.data.testMethodConfirmSheetTerms.map(item => ({
+          this.testItems = res.testMethodConfirmSheetTerms.map(item => ({
             ...item,
             id: item.id // 使用后端返回的ID
           }))
 
           // 设置表单数据
           this.formData = {
-            id: res.data.id,
-            dispatchId: res.data.dispatchId,
-            auditStatus: res.data.auditStatus,
-            confirmSign: res.data.confirmSign,
-            signTime: res.data.signTime
+            id: res.id,
+            dispatchId: res.dispatchId,
+            auditStatus: res.auditStatus,
+            confirmSign: res.confirmSign,
+            signTime: res.signTime
           }
+
         }
       } catch (error) {
-        this.$message.error('获取详情失败:' + (error.message || '未知错误'))
-      }
-    },
-
-    async handleEditSubmit(signatureImage) {
-      try {
-        const submitData = {
-          id: this.formData.id,
-          dispatchId: this.selectedScheduling.id,
-          auditStatus: 1,
-          confirmSign: signatureImage,
-          signTime: new Date().toISOString(),
-          testMethodConfirmSheetTerms: this.testItems.map(item => ({
-            id: item.id, // 保留原有ID
-            termCode: item.termCode,
-            termName: item.termName,
-            termType: item.termType,
-            termMethodCode: item.termMethodCode,
-            termMethod: item.termMethod,
-            sampleRequire: item.sampleRequire,
-            status: item.status,
-            testId: item.testId
-          }))
-        }
-
-        await update(submitData)
-        this.$message.success('更新成功')
-        this.$router.push('/dataManagement/confirmation-sheet')
-      } catch (error) {
-        this.$message.error('更新失败:' + (error.message || '未知错误'))
+        // this.$message.error('获取详情失败:' + (error.message || '未知错误'))
       }
     },
   },

--
Gitblit v1.7.1