WXL (wul)
2 天以前 78c84cf61b2a7f558582673a3eecdf8b91eb24c3
src/views/followvisit/record/detailpage/index.vue
@@ -447,7 +447,7 @@
                      <div class="scriptTopic-dev" :key="index" v-else>
                        <div class="dev-text">
                          {{ index + 1 }}、[问答]<span>{{
                            item.scriptContent
                            item.questiontext
                          }}</span>
                          <span v-if="item.valueType == 3">(只能输入数字)</span>
                        </div>
@@ -561,7 +561,7 @@
                <el-button
                  type="primary"
                  plain
                  @click="Editsingletasksonyic('')"
                  @click="alterpatient('')"
                >
                  保存基础信息
                </el-button>
@@ -651,6 +651,23 @@
                        icon="el-icon-phone"
                        @click="handleCall(userform.telcode, 'tel')"
                        :disabled="!isValidPhone(userform.telcode)"
                      ></el-button>
                    </el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="10">
                  <el-form-item
                    label="短号电话"
                    v-if="orgname == '景宁畲族自治县人民医院'"
                  >
                    <el-input
                      placeholder="联系电话缺失"
                      v-model="userform.telshortcode"
                    >
                      <el-button
                        slot="append"
                        icon="el-icon-phone"
                        @click="handleCall(userform.telshortcode, 'tel', true)"
                      ></el-button>
                    </el-input>
                  </el-form-item>
@@ -1108,6 +1125,7 @@
  serviceSubtaskDetailedit,
  serviceSubtaskDetailadd,
  updatePersonVoices,
  savequestiondetail,
  addPersonVoices,
  query360PatInfo,
  sendMsg,
@@ -1552,8 +1570,6 @@
  methods: {
    // 获取主题样式类
    getTopicClass(item) {
      console.log(item.isabnormal, "getTopicClass");
      // 根据状态值返回对应的样式类
      if (item.isabnormal == 1) {
        return "scriptTopic-isabnormal"; // 异常 - 红色
@@ -1596,13 +1612,15 @@
          this.tableDatatop = res.data.scriptResult;
          this.tableDatatop.forEach((item) => {
            if (item.scriptType == 2) item.scriptResult = [];
            if (item.scriptResultId && item.scriptType != 2) {
              item.isoption = 3;
              item.scriptResult = item.scriptResult;
            } else if (item.scriptResultId && item.scriptType == 2) {
              console.log(item.scriptResult, "item.scriptResult");
              item.scriptResult = item.scriptResult.split("&");
              item.isoption = 3;
            } else if (!item.scriptResultId && item.scriptType == 2) {
              item.scriptResult = [];
            }
          });
          this.taskname = res.data.taskName;
@@ -1726,7 +1744,7 @@
            if (item.targetvalue) {
              item.scriptResult = item.targetvalue.split("&");
            } else {
              item.scriptResult = [];
              item.scriptResult = item.asrtext;
            }
          });
@@ -1742,19 +1760,19 @@
        if (res.code == 200) {
          this.tableDatatop = res.data.ivrTaskTemplateScriptVOList;
          this.tableDatatop.forEach((item) => {
            item.scriptID = item.id;
            item.id = null;
            // 类型判断赋值
            if (item.ivrTaskScriptTargetoptionList) {
            if (item.ivrTaskScriptTargetoptionList.length) {
              item.targetvalue = 1;
              item.questiontext = item.scriptContent;
              item.targetvalue = item.ivrTaskScriptTargetoptionList
                .map((obj) => obj.targetvalue)
                .join("&");
            }
            if (item.targetvalue) {
              item.scriptResult = item.targetvalue.split("&");
            } else {
              item.scriptResult = [];
            }
          });
        }
@@ -1762,16 +1780,18 @@
    },
    // 医护人员存储数据
    getdetail() {
      console.log(1);
      let excep = "";
      const promises = [];
      // 先处理 tableDatatop 中的数据
      this.tableDatatop.forEach((item) => {
        if (item.valueType == 3 && item.scriptResult) {
          // 验证是否为有效数字
          if (!/^\d+$/.test(item.scriptResult)) {
            this.$message.error(`问题 "${item.scriptContent}" 必须输入数字`);
            return;
          }
        }
        var objs = item.svyTaskTemplateTargetoptions.find(
          (items) => items.optioncontent == item.scriptResult
        );
@@ -1782,44 +1802,43 @@
            this.selectedTag = objs.isabnormal;
          }
        }
        console.log(excep, "excep");
        let obj = {
          asrtext: null,
          patid: this.patid,
          subId: this.id,
          taskid: this.taskid,
          scriptid: item.id,
          excep: excep,
          questiontext: item.scriptContent,
          categoryid: item.categoryid,
          answerps: item.answerps || null, // 添加附加信息
        };
        if (item.scriptType == 2 && item.scriptResult[0]) {
          obj.asrtext = item.scriptResult.join("&");
        // 处理 scriptResult,直接修改原始数据
        if (item.scriptType == 2 && item.scriptResult) {
          // 处理数组类型的 scriptResult
          if (Array.isArray(item.scriptResult)) {
            item.originalScriptResult = item.scriptResult; // 保存原始数组(可选)
            item.scriptResult = item.scriptResult.join("&"); // 转换为字符串
          }
        } else if (item.scriptType != 2 && item.scriptResult) {
          obj.asrtext = item.scriptResult;
        }
        if (item.isoption == 3) {
          promises.push(serviceSubtaskDetailedit(obj));
        } else {
          promises.push(serviceSubtaskDetailadd(obj));
          // 确保非数组类型已经是字符串
          if (Array.isArray(item.scriptResult)) {
            item.originalScriptResult = item.scriptResult; // 保存原始数组(可选)
            item.scriptResult =
              item.scriptResult.length > 0 ? item.scriptResult[0] : "";
          }
        }
      });
      // 使用 Promise.all 等待所有异步操作完成
      Promise.all(promises)
        .then((results) => {
          // 所有异步操作成功完成后的逻辑
          results.forEach((res) => {
            if (res.code !== 200) {
              this.$modal.error("修改失败");
            }
          });
      // 创建副本用于保存,避免影响显示
      const saveData = this.tableDatatop.map((item) => ({
        ...item,
        // 如果需要,可以在这里做最后的数据清理
        scriptResult: item.scriptResult || "", // 确保不为 undefined
      }));
      let obj = {
        svyTaskTemplateScriptVOS: saveData, // 使用处理后的数据
        param1: this.taskid,
        param2: this.patid,
        param6: this.id,
        type: 2,
      };
      savequestiondetail(obj).then((res) => {
        if (res.code == 200) {
          this.$modal.msgSuccess("服务保存成功");
          this.Editsingletasksonyic(6);
          const orgName = localStorage.getItem("orgname");
          console.log(orgName, "orgName");
          if (this.form.isVisitAgain != 1 || orgName == "丽水市中医院") {
            this.Torouter();
@@ -1848,11 +1867,8 @@
            .catch(() => {
              this.Torouter();
            });
        })
        .catch((error) => {
          // 如果有任何一个异步操作失败,会进入这里
          console.error("发生错误:", error);
        });
        }
      });
    },
    Torouter() {
      if (this.form.serviceType == 13) {
@@ -1913,8 +1929,8 @@
    isValidPhone(phone) {
      return this.validatePhoneNumber(phone).isValid;
    },
    handleCall(phone, type) {
      if (!this.isValidPhone(phone)) {
    handleCall(phone, type, dh) {
      if (!this.isValidPhone(phone) && !dh) {
        this.$message.error("请输入正确的手机号码");
        return;
      }
@@ -1984,28 +2000,40 @@
    },
    yuyingetdetail() {
      const dataToSubmit = JSON.parse(JSON.stringify(this.tableDatatop));
      console.log(dataToSubmit, "dataToSubmit");
      // return;
      dataToSubmit.forEach((item, index) => {
        // 对拷贝的数据进行操作,不影响原始的 scriptResult 数组
        item.scriptResult = item.scriptResult.join("&");
        if (item.targetvalue) {
          item.scriptResult = item.scriptResult.join("&");
          item.asrtext = item.matchedtext;
          item.ivrtext = item.matchedtext;
        } else {
          item.asrtext = item.scriptResult;
          item.ivrtext = item.scriptResult;
        }
        item.templatequestionnum = index + 1;
        item.subId = this.id;
        item.taskid = this.taskid;
        item.asrtext = item.matchedtext;
        if (!item.id) {
          item.isoperation = 1;
        }
        item.patid = this.patid;
        item.templateid = item.templateID;
        if (item.nextScriptno == null) {
          item.nextScriptno = index == dataToSubmit.length - 1 ? 0 : index + 2;
        }
      });
      console.log("c", 3);
      let obj = {
        serviceSubtaskDetailList: dataToSubmit, // 提交处理后的副本
        ivrTaskTemplateScriptVOList: dataToSubmit, // 提交处理后的副本
        param1: this.taskid,
        param2: this.patid,
        subId: this.id,
        param6: this.id,
        type: 1,
      };
      console.log("c", 4);
      const orgName = localStorage.getItem("orgname");
      console.log(orgName, "orgName");
@@ -2013,7 +2041,7 @@
        this.Torouter();
        return;
      }
      addPersonVoices(obj).then((res) => {
      savequestiondetail(obj).then((res) => {
        if (res.code == 200) {
          this.$modal.msgSuccess("服务保存成功");
          this.$modal
@@ -2074,7 +2102,6 @@
          this.form = res.rows[0].serviceSubtaskList.find(
            (item) => item.id == this.id
          );
          console.log(this.form, "serviceType");
          this.logsheetlist = res.rows[0].serviceSubtaskList;
          this.templateid = this.form.templateid;
@@ -2175,6 +2202,15 @@
        }
      });
    },
    alterpatient(sendstate) {
      alterpatient(this.userform).then((res) => {
        if (res.code == 200) {
          this.$modal.msgSuccess("基础信息保存成功");
        } else {
          this.$modal.msgError("基础信息修改失败");
        }
      });
    },
    // 异常列渲染
    tableRowClassName({ row, rowIndex }) {
      if (row.id == this.id) {
@@ -2259,35 +2295,7 @@
        })
        .catch(() => {});
    },
    aahandleOptionChange(a, b, c) {
      const result = c.find((item) => item.optioncontent == a);
      if (result.nextQuestion == 0) {
        this.tableDatatop = this.tableDatatop.reduce((acc, item, i) => {
          acc.push(i > b ? { ...item, astrict: 1 } : item);
          return acc;
        }, []);
      } else {
        this.tableDatatop = this.tableDatatop.reduce((acc, item, i) => {
          acc.push(i > b ? { ...item, astrict: 0 } : item);
          return acc;
        }, []);
      }
      if (this.Voicetype) {
        var obj = this.tableDatatop[b].ivrTaskScriptTargetoptionList.find(
          (item) => item.optioncontent == a
        );
      } else {
        var obj = this.tableDatatop[b].svyTaskTemplateTargetoptions.find(
          (item) => item.optioncontent == a
        );
      }
      if (obj.isabnormal) {
        this.tableDatatop[b].isabnormal = true;
      } else {
        this.tableDatatop[b].isabnormal = false;
      }
      this.$forceUpdate();
    },
    handleRadioToggles(questionItem, optionValue) {
      if (!questionItem.matchedtext) {
        questionItem.matchedtext == "";
@@ -2346,7 +2354,13 @@
      this.tableDatatop[questionIndex].showAppendInput =
        selectedOptionObj.appendflag == 1;
      console.log(this.tableDatatop);
      if (
        selectedOptionObj.nextQuestion !== undefined &&
        selectedOptionObj.nextQuestion !== null
      ) {
        this.tableDatatop[questionIndex].nextScriptno =
          selectedOptionObj.nextQuestion;
      }
      // if (!this.tableDatatop[questionIndex].showAppendInput) {
      //   this.tableDatatop[questionIndex].answerps = ""; // 清除附加信息
      // }
@@ -2416,7 +2430,6 @@
          hiddenByEnd: index === questionIndex + 1 ? false : item.hiddenByEnd,
        }));
      }
      2;
      this.$forceUpdate();
    },