fix
13404089107
2025-08-15 9cb1c3c39136c89974bc4049fca5e450e757b1be
laboratory/src/views/dataManagement/schemeManagement/addPlan.vue
@@ -223,7 +223,7 @@
            ref="purposeEditor"
            :readOnly="isEdit"
            :value="editorContents.purpose"
            height="200px"
            height="400px"
            placeholder="请输入实验目的..."
          />
        </div>
@@ -239,7 +239,7 @@
            ref="processEditor"
            :readOnly="isEdit"
            :value="editorContents.process"
            height="200px"
            height="400px"
            placeholder="请输入工艺参数及路线..."
          />
        </div>
@@ -356,6 +356,7 @@
} from "./service";
import moment from "moment";
import { add, update, updateTester } from "./service";
import { mapState } from "vuex";
export default {
  name: "AddProject",
@@ -432,6 +433,9 @@
      this.editId = this.$route.query.id;
      await this.loadEditData();
    }
  },
  computed: {
    ...mapState(["tagList", "isFold"]),
  },
  methods: {
    // ===== 人员相关方法 =====
@@ -572,7 +576,7 @@
          }
          // 根据是否为编辑模式调用不同接口
          const apiCall = this.editId
          const apiCall = (this.editId && !this.isEdit)
            ? update(formData)
            : this.isEdit
            ? updateTester(formData)
@@ -584,7 +588,11 @@
                this.$message.success(
                  status === 1 ? "保存成功" : "草稿保存成功"
                );
                this.$router.go(-1);
                this.$router.back();
      this.$store.commit(
        "SET_TAGLIST",
        this.tagList.filter((item) => item.path !== this.$route.path)
      );
              } else {
                this.$message.error(
                  res.msg || (status === 1 ? "保存失败" : "草稿保存失败")
@@ -623,13 +631,11 @@
        this.$message.error("请选择实验调度");
        return false;
      }
      // 校验实验日期
      if (!this.form.experimentDate) {
        this.$message.error("请填写实验日期");
        return false;
      }
      // 校验参与人员
      if (
        !this.selectedParticipants ||
@@ -638,46 +644,67 @@
        this.$message.error("请选择参与人员");
        return false;
      }
      // 校验实验目的
      const purpose = this.$refs.purposeEditor.getContent();
      if (!purpose || purpose === "<p></p>" || purpose.trim() === "<p></p>") {
        this.$message.error("请填写实验目的");
        return false;
      }
      // 校验工艺参数及路线
      const process = this.$refs.processEditor.getContent();
      if (!process || process === "<p></p>" || process.trim() === "<p></p>") {
        this.$message.error("请填写工艺参数及路线");
        return false;
      }
      // 校验 DynamicComponent 里的表格
      function checkDynamicComponentTables(list, label) {
        if (!Array.isArray(list)) return true;
        for (const comp of list) {
          if (comp.type === 'customTable') {
            if (!comp.data || !Array.isArray(comp.data.headers) || comp.data.headers.length === 0) {
              this.$message.error(`${label}中有表格未添加表头`);
              return false;
            }
            if (!Array.isArray(comp.data.rows) || comp.data.rows.length === 0) {
              this.$message.error(`${label}中有表格未添加数据`);
              return false;
            }
          }
        }
        return true;
      }
      // 校验实验材料
      if (!this.form.experimentMaterial) {
        this.$message.error("请添加实验材料");
        return false;
      }
      if (!checkDynamicComponentTables.call(this, this.form.experimentMaterial, '实验材料')) {
        return false;
      }
      // 校验实验设备
      if (!this.form.experimentDevice) {
        this.$message.error("请添加实验设备");
        return false;
      }
      if (!checkDynamicComponentTables.call(this, this.form.experimentDevice, '实验设备')) {
        return false;
      }
      // 校验实验步骤记录
      if (!this.stepList || this.stepList.length === 0) {
        this.$message.error("请添加实验操作步骤");
        return false;
      }
      // 校验每个步骤是否都有内容
      const invalidStep = this.stepList.findIndex((step) => !step.content);
      if (invalidStep !== -1) {
        this.$message.error(`请完善第${invalidStep + 1}个步骤的内容`);
        return false;
      // 校验每个步骤是否都有内容及表格
      for (let i = 0; i < this.stepList.length; i++) {
        const step = this.stepList[i];
        if (!step.content) {
          this.$message.error(`请完善第${i + 1}个步骤的内容`);
          return false;
        }
        if (!checkDynamicComponentTables.call(this, step.content, `第${i + 1}个步骤`)) {
          return false;
        }
      }
      return true;
    },
    handleStopExperiment() {
@@ -706,7 +733,6 @@
          });
        getParticipantsByDispatchId({ dispatchId: data[0].id })
          .then((res) => {
            console.log("获取参加人员列表:", res);
            if (res) {
              this.participantsData = res || [];
            } else {
@@ -731,7 +757,6 @@
          return;
        }
        console.log("编辑数据", res);
        const data = res;
        // 填充基本表单数据
@@ -740,10 +765,6 @@
        // 填充实验调度信息
        if (data.experimentDispatch?.id) {
          this.form.dispatchId = data.experimentDispatch.id;
          console.log(
            "experimentStepRecord experimentStepRecord",
            JSON.parse(data.experimentStepRecord)
          );
          this.groupTableData = [{ ...data.experimentDispatch }];
          // 获取组别信息
@@ -755,6 +776,18 @@
          } catch (err) {
            console.error("获取组别列表失败:", err);
          }
          getParticipantsByDispatchId({ dispatchId: data.experimentDispatch.id })
          .then((res) => {
            if (res) {
              this.participantsData = res || [];
            } else {
              this.$message.error(res.msg || "获取参加人员列表失败");
            }
          })
          .catch((err) => {
            this.$message.error("获取参加人员列表失败");
            console.error("获取参加人员列表失败:", err);
          });
        }
        // 填充参与人员
@@ -954,12 +987,12 @@
}
.groupTable {
  width: 65%;
  width: 100%;
  padding-left: 40px;
}
.rwuTable {
  width: 85%;
  width: 100%;
  padding-left: 40px;
}
@@ -1167,7 +1200,7 @@
.content-box {
  padding: 0 25px;
  margin-bottom: 20px;
  width: 65%;
  width: 95%;
  display: flex;
  .content-box-left {
    flex: 1;