WXL (wul)
12 小时以前 e9f35f9782f3d99d742c294fe503fc1294f203c4
src/views/outsideChainnew.vue
@@ -8,7 +8,9 @@
            {{
              kcb
                ? kcb
                : "亲爱的患者-家属,我们是"+localStorage.getItem("orgname")+"的医护人员,为了更好地了解您的康复情况,请您抽一点宝贵时间,完成这份随访问卷。"
                : "亲爱的患者-家属,我们是" +
                  localStorage.getItem("orgname") +
                  "的医护人员,为了更好地了解您的康复情况,请您抽一点宝贵时间,完成这份随访问卷。"
            }}
            <!-- 亲爱的患者/家属您好,为了更好的了解您出院后的康复情况,给您适当及时的健康指导,请您抽一点宝贵时间,完成这份出院随访问卷调查。 -->
          </div>
@@ -20,9 +22,15 @@
          v-for="(item, index) in questionList"
          :key="item.aaa"
        >
          <div class="scriptTopic-dev" :key="index" v-if="item.scriptType == 1">
          <div
            class="scriptTopic-dev"
            :key="index"
            v-if="item.scriptType == 1"
            :class="{ 'required-error': item.requiredError }"
          >
            <div class="dev-text">
              {{ index + 1 }}、<span style="line-height: 1.5"
                ><span v-if="isRequired(item)" class="required-star">*</span
                >{{ item.scriptContent }}
                <span style="color: #3ba2f7">[单选]</span></span
              >
@@ -52,9 +60,15 @@
            </div>
          </div>
          <!-- 多选 -->
          <div class="scriptTopic-dev" :key="index" v-if="item.scriptType == 2">
          <div
            class="scriptTopic-dev"
            :key="index"
            v-if="item.scriptType == 2"
            :class="{ 'required-error': item.requiredError }"
          >
            <div class="dev-text">
              {{ index + 1 }}、<span style="line-height: 1.5"
                ><span v-if="isRequired(item)" class="required-star">*</span
                >{{ item.scriptContent }}
                <span style="color: #3ba2f7">[多选]</span></span
              >
@@ -82,9 +96,15 @@
            </div>
          </div>
          <!-- 填空 -->
          <div class="scriptTopic-dev" :key="index" v-if="item.scriptType == 4||item.scriptType == 3">
          <div
            class="scriptTopic-dev"
            :key="index"
            v-if="item.scriptType == 4 || item.scriptType == 3"
            :class="{ 'required-error': item.requiredError }"
          >
            <div class="dev-text">
              {{ index + 1 }}、<span style="line-height: 1.5"
                ><span v-if="isRequired(item)" class="required-star">*</span
                >{{ item.scriptContent
                }}<span style="color: #3ba2f7">[问答]</span></span
              >
@@ -163,6 +183,7 @@
      kcb: "",
      excep: "",
      taskname: "",
      param6: null,
      questionList: [
        // {
        //   scriptType: 1,
@@ -288,12 +309,14 @@
      geturlinfo(url).then((res) => {
        if (res.code == 200) {
          this.getQuestionnaire(
            res.data.param1,
            res.data.param2,
            res.data.param3,
            res.data.param5
          );
          this.param6 = res.data.param6;
        }
      });
    },
@@ -322,7 +345,7 @@
      // let taskids = this.encrypt(this.taskid);
      // let patids = this.encrypt(this.patid);
      // 先取缓存
      getCachequestionnaire({ param1: this.taskid, param2: this.patid }).then(
      getCachequestionnaire({ param1: this.taskid, param2: this.patid,param6:this.param6 }).then(
        (res) => {
          if (res.code == 200) {
            this.questionList = res.data;
@@ -347,7 +370,7 @@
    },
    // 获取数据
    getExternalfollowup() {
      getExternalfollowup({ param1: this.taskid, param2: this.patid }).then(
      getExternalfollowup({ param1: this.taskid, param2: this.patid,param6:this.param6 }).then(
        (res) => {
          if (res.code == 200) {
            this.questionList = res.data.script;
@@ -385,10 +408,12 @@
      let form = {
        param1: this.taskid,
        param2: this.patid,
        param6: this.param6,
        excep: this.excep,
        type: this.type,
        serviceSubtaskDetailList: [],
      };
      const arr = structuredClone(this.questionList);
      // arr.forEach((item) => {
      //   item.asrtext = JSON.stringify(item.questionResult);
@@ -410,16 +435,21 @@
    // 缓存
    cache(subm) {
      console.log("进入缓存");
      // 提交场景:先做必填项校验
      if (subm === true && !this.validateRequired()) {
        return;
      }
      let form = {
        param1: this.taskid,
        param2: this.patid,
        param6: this.param6,
        type: this.type,
        ivrTaskTemplateScriptVOList: [],
      };
      const arr = structuredClone(this.questionList);
      console.log(arr, "srr");
      arr.forEach((item, index) => {
        if (item.scriptType == 3||item.scriptType == 4) return;
        if (item.scriptType == 3 || item.scriptType == 4) return;
        var obj = item.ivrTaskScriptTargetoptionList.find(
          (items) => items.targetvalue == item.questionResult
        );
@@ -447,6 +477,45 @@
          }
        }
      });
    },
    // 是否必填(1必填 2不必填)
    isRequired(item) {
      return item.ismandatory == 1 || item.ismandatory == "1";
    },
    // 判断题目是否未填写
    isQuestionEmpty(item) {
      const val = item.questionResult;
      if (item.scriptType == 2) {
        return !val || (Array.isArray(val) && val.length === 0);
      }
      return val === undefined || val === null || val === "";
    },
    // 保存前必填项校验
    validateRequired() {
      const list = this.questionList || [];
      list.forEach((item) => {
        if (item.requiredError) this.$set(item, "requiredError", false);
      });
      const unfilled = [];
      list.forEach((item) => {
        if (!this.isRequired(item)) return;
        if (this.isQuestionEmpty(item)) unfilled.push(item);
      });
      if (unfilled.length > 0) {
        unfilled.forEach((item) => this.$set(item, "requiredError", true));
        this.$modal.msgWarning(
          `还有 ${unfilled.length} 道必填题未填写,请补充后再提交`
        );
        this.$nextTick(() => {
          const idx = this.questionList.indexOf(unfilled[0]);
          const els = this.$el.querySelectorAll(".scriptTopic-dev");
          if (els[idx]) {
            els[idx].scrollIntoView({ behavior: "smooth", block: "center" });
          }
        });
        return false;
      }
      return true;
    },
    // 处理单选选项
    handleOptionChange(selectedvalue, index, arr) {
@@ -598,6 +667,18 @@
}
.toptitle {
}
.required-star {
  color: #f56c6c;
  margin-right: 2px;
  font-weight: 600;
}
.scriptTopic-dev.required-error {
  border: 1px solid #f56c6c;
  border-left: 4px solid #f56c6c;
  background: #fef0f0;
  border-radius: 4px;
  padding: 8px;
}
.bottom-fixed {
  position: fixed;
  bottom: 0;