WXL
2025-04-30 6be49398a90a339a6c72ac9ea7a09fc368acda87
src/views/knowledge/questionnaire/compilequer/index.vue
@@ -310,7 +310,7 @@
              >下一步</el-button
            >
            <el-button type="info" @click="closeFm('ruleForm')">关闭</el-button>
            <el-button @click="Departmenttreatment('ruleForm')"
            <el-button @click="toExamine('ruleForm')"
              >保存问卷基础信息</el-button
            >
          </el-form-item>
@@ -634,9 +634,9 @@
                          label="ABC等级"
                        >
                          <el-radio-group v-model="item.score">
                            <el-radio label="A">A</el-radio>
                            <el-radio label="B">B</el-radio>
                            <el-radio label="C">C</el-radio>
                            <el-radio :label="1">A</el-radio>
                            <el-radio :label="2">B</el-radio>
                            <el-radio :label="3">C</el-radio>
                          </el-radio-group>
                        </el-form-item>
                        <el-form-item
@@ -747,7 +747,7 @@
        >
        <el-button type="primary" @click="laststep()">上一步</el-button>
        <el-button type="info" @click="closeFm('ruleForm')">关闭</el-button>
        <el-button @click="Departmenttreatment('ruleForm')"
        <el-button @click="toExamine('ruleForm')"
          >保存问题数据</el-button
        >
      </div>
@@ -1146,9 +1146,9 @@
                          label="ABC等级"
                        >
                          <el-radio-group v-model="item.score">
                            <el-radio label="A">A</el-radio>
                            <el-radio label="B">B</el-radio>
                            <el-radio label="C">C</el-radio>
                            <el-radio :label="1">A</el-radio>
                            <el-radio :label="2">B</el-radio>
                            <el-radio :label="3">C</el-radio>
                          </el-radio-group>
                        </el-form-item>
                        <el-form-item
@@ -1539,21 +1539,22 @@
      });
      this.tempDetpRelevanceslist = [];
      this.tempbelongWards = [];
      depthospgetsonlist(this.queryParamsdept).then((res) => {
        if (res.code == 200) {
          let arr = res.rows;
          arr.forEach((item) => {
            if (item.deptType == 1) {
              this.deptlist.push(item);
              this.tempDetpRelevanceslist.push(item.deptCode);
            } else if (item.deptType == 2) {
              this.hosplist.push(item);
              this.tempbelongWards.push(item.deptCode);
            }
          });
        }
      });
      if (this.queryParamsdept.tempid) {
        depthospgetsonlist(this.queryParamsdept).then((res) => {
          if (res.code == 200) {
            let arr = res.rows;
            arr.forEach((item) => {
              if (item.deptType == 1) {
                this.deptlist.push(item);
                this.tempDetpRelevanceslist.push(item.deptCode);
              } else if (item.deptType == 2) {
                this.hosplist.push(item);
                this.tempbelongWards.push(item.deptCode);
              }
            });
          }
        });
      }
    },
    // 获取科室树
    getDeptTree() {
@@ -1635,6 +1636,44 @@
        });
      }
    },
    // 题目校验
    toExamine() {
      // 遍历题目集合
      for (let i = 0; i <  this.ruleForm.svyTemplateLibScripts.length; i++) {
        const question =  this.ruleForm.svyTemplateLibScripts[i];
        // 如果 scriptType 为 4,则跳过当前题目
        if (question.scriptType === 4) {
          continue;
        }
        // 获取当前题目的选项集合
        const options = question.svyLibTemplateTargetoptions;
        // 创建一个 Set 来存储选项名称,用于检测重复
        const optionNames = new Set();
        // 遍历选项集合
        for (let j = 0; j < options.length; j++) {
          const option = options[j];
          const optionContent = option.optioncontent;
          // 如果选项名称已经存在于 Set 中,说明重复
          if (optionNames.has(optionContent)) {
            this.$message.error(
              `题目 ${question.id} 的选项名称 "${optionContent}" 重复`
            );
            return false; // 返回 false 表示校验失败
          }
          // 将选项名称添加到 Set 中
          optionNames.add(optionContent);
        }
      }
      // 如果所有题目都校验通过,返回 true
      console.log("所有题目校验通过,选项名称无重复");
       this.Departmenttreatment();
    },
    // 科室/院区处理
    Departmenttreatment() {
      this.tempDetpRelevanceslist.forEach((item) => {