zjk
6 小时以前 173766e82d7cde9a7ae30b8896a9a287dff411f8
laboratory/src/views/dataManagement/confirmation-sheet/components/add.vue
@@ -126,7 +126,6 @@
  mounted() { },
  methods: {
    setSelectedScheduling(data) {
      console.log('data', data)
      if (!data || data.length === 0) return;
      const selectedData = data[0]; // 获取选中的第一条数据
      this.selectedScheduling = selectedData;
@@ -362,7 +361,7 @@
          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,
@@ -407,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,
@@ -420,16 +419,12 @@
        }
        // 打印草稿参数
        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('保存草稿成功')
        }
@@ -445,8 +440,8 @@
        if (res) {
          // 设置实验调度数据
          this.selectedScheduling = {
            ...res,
            id: res.dispatchId,
            ...res
          }
          this.tableData = [{
            // planCode: res.projectName,
@@ -464,12 +459,6 @@
            status: this.getStatusText(res.status) // 状态
          }]
          // this.confirmFormData = {
          //   planName: res.projectName || '',
          //   testCode: res.experimentCode || '',
          //   testName: res.experimentName || '',
          // };
          console.log('confirmFormData confirmFormData ',this.confirmFormData)
          // 设置检测项数据
          this.testItems = res.testMethodConfirmSheetTerms.map(item => ({
@@ -488,36 +477,7 @@
        }
      } 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 || '未知错误'))
      }
    },
  },