WXL (wul)
2026-06-15 741805d8daa2d2baa0b6b75bc1724488baf9c6bc
src/views/followvisit/record/detailpage/index.vue
@@ -76,7 +76,8 @@
                  gettoken360(
                    scope.row.sfzh,
                    scope.row.drcode,
                    scope.row.drname
                    scope.row.drname,
                    scope.row.patid
                  )
                "
                ><span class="button-textsc">{{
@@ -94,43 +95,45 @@
          >
          </el-table-column>
          <el-table-column
            prop="sendstate"
            label="随访状态"
            align="center"
            width="200"
            label="任务状态"
            key="sendstateView"
            prop="sendstateView"
            width="120"
          >
            <template slot-scope="scope">
              <div v-if="scope.row.sendstate == 1">
                <el-tag type="primary" :disable-transitions="false"
                  >表单已领取</el-tag
                >
              </div>
              <div v-if="scope.row.sendstate == 2">
                <el-tag type="primary" :disable-transitions="false"
                  >待随访</el-tag
                >
              </div>
              <div v-if="scope.row.sendstate == 3">
                <el-tag type="success" :disable-transitions="false"
                  >表单已发送</el-tag
                >
              </div>
              <div v-if="scope.row.sendstate == 4">
                <el-tag type="info" :disable-transitions="false">不执行</el-tag>
              </div>
              <div v-if="scope.row.sendstate == 5">
                <el-tag type="danger" :disable-transitions="false"
                  >发送失败</el-tag
                >
              </div>
              <div v-if="scope.row.sendstate == 6">
                <el-tag type="success" :disable-transitions="false"
                  >已完成</el-tag
                >
              </div>
              <div v-if="scope.row.sendstate == 7">
                <el-tag type="danger" :disable-transitions="false">超时</el-tag>
              </div>
              <el-tooltip
                class="item"
                effect="dark"
                :content="scope.row.remark"
                placement="top-start"
              >
                <div v-if="scope.row.sendstateView == 1">
                  <el-tag type="primary" :disable-transitions="false"
                    >待随访</el-tag
                  >
                </div>
                <div v-if="scope.row.sendstateView == 2">
                  <el-tag type="primary" :disable-transitions="false"
                    >随访中</el-tag
                  >
                </div>
                <div v-if="scope.row.sendstateView == 3">
                  <el-tag type="warning" :disable-transitions="false"
                    >未完成</el-tag
                  >
                </div>
                <div v-if="scope.row.sendstateView == 4">
                  <el-tag type="success" :disable-transitions="false"
                    >已完成</el-tag
                  >
                </div>
                <div v-if="scope.row.sendstateView == 5">
                  <el-tag type="danger" :disable-transitions="false"
                    >无需随访</el-tag
                  >
                </div>
              </el-tooltip>
            </template>
          </el-table-column>
          <el-table-column
@@ -141,6 +144,18 @@
            show-overflow-tooltip
          >
          </el-table-column>
            <el-table-column
            v-if="orgname == '南华大学附属第一医院'"
            label="入院日期"
            width="200"
            align="center"
            key="starttime"
            prop="starttime"
          >
            <template slot-scope="scope">
              <span>{{ formatTime(scope.row.starttime) }}</span>
            </template></el-table-column
          >
          <el-table-column
            label="出院日期"
            width="200"
@@ -152,6 +167,7 @@
              <span>{{ formatTime(scope.row.endtime) }}</span>
            </template></el-table-column
          >
          <el-table-column
            label="责任护士"
            width="120"
@@ -261,9 +277,33 @@
      <!-- 随访内容 -->
      <div class="call-action">
        <div class="call-container">
          <!-- <div class="call-header">
            <h2>一键呼叫功能</h2>
          </div> -->
          <div
            style="display: flex"
            v-if="orgname == '南华大学附属第一医院' && !Voicetype"
          >
            <template-selector
              v-model="form.templateid"
              :templateName="form.templatename"
              :service-type="form.serviceType"
              :is-editable="form.sendState !== 2"
              @select="handleTemplateSelect"
              @clear="handleTemplateClear"
            />
            <div
              v-if="defaultKey"
              style="
                display: flex;
                align-items: center;
                justify-content: center;
                height: 100%;
                padding: 33px 0 0 50px;
              "
            >
              <el-button type="success" round @click="handleConfirmReplace">
                默认填充
              </el-button>
            </div>
          </div>
          <div class="headline">
            <div>随访内容</div>
@@ -290,9 +330,14 @@
                        v-if="item.scriptType == 1 && !item.astrict"
                      >
                        <div class="dev-text">
                          {{ index + 1 }}、[单选]<span>{{
                            item.scriptContent
                          }}</span>
                          {{ index + 1 }}. [单选]
                          <span> {{ item.scriptContent }}</span>
                          <span style="margin-left: 20px"
                            ><dict-tag
                              :options="dict.type.dimensionality_type"
                              :value="item.dimension"
                          /></span>
                        </div>
                        <div class="dev-xx">
                          <el-radio-group v-model="item.scriptResult">
@@ -343,9 +388,14 @@
                        v-if="item.scriptType == 2 && !item.astrict"
                      >
                        <div class="dev-text">
                          {{ index + 1 }}、[多选]<span>{{
                          {{ index + 1 }}. [多选]<span>{{
                            item.scriptContent
                          }}</span>
                          <span style="margin-left: 20px"
                            ><dict-tag
                              :options="dict.type.dimensionality_type"
                              :value="item.dimension"
                          /></span>
                        </div>
                        <div class="dev-xx">
                          <el-checkbox-group
@@ -377,9 +427,14 @@
                        v-if="item.scriptType == 4 && !item.astrict"
                      >
                        <div class="dev-text">
                          {{ index + 1 }}、[问答]<span>{{
                          {{ index + 1 }}. [问答]<span>{{
                            item.scriptContent
                          }}</span>
                          <span style="margin-left: 20px"
                            ><dict-tag
                              :options="dict.type.dimensionality_type"
                              :value="item.dimension"
                          /></span>
                          <span v-if="item.valueType == 3">(只能输入数字)</span>
                        </div>
                        <div class="dev-xx" v-if="item.valueType == 3">
@@ -413,9 +468,8 @@
                    >
                      <div v-if="item.targetvalue">
                        <div class="dev-text">
                          {{ index + 1 }}、[单选]<span>{{
                            item.questiontext
                          }}</span>
                          {{ index + 1 }}. [单选]
                          <span>{{ item.questiontext }}</span>
                        </div>
                        <div class="dev-xx">
                          <el-radio-group
@@ -446,8 +500,8 @@
                      <div class="scriptTopic-dev" :key="index" v-else>
                        <div class="dev-text">
                          {{ index + 1 }}、[问答]<span>{{
                            item.scriptContent
                          {{ index + 1 }}. [问答]<span>{{
                            item.questiontext
                          }}</span>
                          <span v-if="item.valueType == 3">(只能输入数字)</span>
                        </div>
@@ -558,11 +612,7 @@
            <div class="header-actions">
              <!-- 基础操作按钮组 -->
              <div class="action-group basic-actions">
                <el-button
                  type="primary"
                  plain
                  @click="Editsingletasksonyic('')"
                >
                <el-button type="primary" plain @click="alterpatient('')">
                  保存基础信息
                </el-button>
@@ -580,7 +630,7 @@
                  type="primary"
                  round
                  @click="sendAgain"
                  v-if="form.isVisitAgain != 2"
                  v-if="(form.isVisitAgain != 2) & (visitAgain == 2)"
                >
                  再次随访
                </el-button>
@@ -755,16 +805,54 @@
                  />
                </div>
              </div>
              <el-form-item label="任务处理状态">
                <el-select
                  v-model="serviceStates"
                  placeholder="请选择状态"
                  clearable
                  style="width: 150px; margin-right: 10px"
                >
                  <el-option
                    v-for="item in serviceState"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
              <!-- 随访内容/记录 -->
              <el-form-item
                :label="orgname == '丽水市中医院' ? '随访内容' : '随访记录'"
              >
                <el-input type="textarea" v-model="form.remark"></el-input>
                <!-- 快捷短语标签 -->
                <div style="margin-bottom: 8px">
                  <el-tag
                    v-for="(item, index) in dict.type.quickfollow_up"
                    :key="index"
                    style="margin-right: 8px; cursor: pointer"
                    @click="insertText(item.value)"
                  >
                    {{ item.value }}
                  </el-tag>
                </div>
                <!-- 文本域 -->
                <el-input
                  type="textarea"
                  :rows="4"
                  v-model="form.remark"
                  ref="textareaRef"
                  placeholder="可点击上方快捷标签或手动输入"
                ></el-input>
              </el-form-item>
              <!-- 随访情况 -->
              <el-form-item label="随访情况" v-if="orgname == '丽水市中医院'">
              <el-form-item
                label="随访情况"
                v-if="
                  orgname == '丽水市中医院' ||
                  orgname == '景宁畲族自治县人民医院'
                "
              >
                <el-radio-group v-model="form.taskSituation">
                  <el-radio
                    v-for="city in cities"
@@ -1128,7 +1216,10 @@
  savequestiondetail,
  addPersonVoices,
  query360PatInfo,
  updateTemplate,
  query360PatInfonh,
  sendMsg,
  getconfigKey,
} from "@/api/AiCentre/index";
import {
  messagelistpatient,
@@ -1136,13 +1227,16 @@
  listcontactinformation,
} from "@/api/patient/homepage";
import CallButton from "@/components/CallButton";
import TemplateSelector from "@/components/optionalModule";
import MergeAndModify from "./MergeAndModify.vue";
import CallCenterLs from "@/components/CallCenterLs";
import store from "@/store";
export default {
  components: {
    CallButton,
    MergeAndModify,
    CallCenterLs,
    TemplateSelector,
  },
  directives: {
    numericOnly: {
@@ -1205,7 +1299,14 @@
      },
    },
  },
  dicts: ["sys_normal_disable", "sys_user_sex", "sys_yujing", "sys_suggest"],
  dicts: [
    "sys_normal_disable",
    "dimensionality_type",
    "quickfollow_up",
    "sys_user_sex",
    "sys_yujing",
    "sys_suggest",
  ],
  data() {
    const validatePhone = (rule, value, callback) => {
      if (!value) {
@@ -1220,7 +1321,9 @@
      }, 300);
    };
    return {
      visitAgain: 1,
      userid: "",
      defaultKey: false, //是否可默认填报
      currentPhoneNumber: "",
      callType: "", // 用于区分是哪个电话
      isSipRegistering: true, // SIP注册状态
@@ -1230,11 +1333,35 @@
      isEndingCall: false,
      CaldialogVisible: false,
      currentCall: null, // 当前通话对象
      serviceStates: 6,
      serviceState: [
        {
          value: 2,
          label: "待随访",
        },
        {
          value: 3,
          label: "表单已发送",
        },
        {
          value: 5,
          label: "发送失败",
        },
        {
          value: 6,
          label: "已完成",
        },
        {
          value: 4,
          label: "不执行",
        },
      ],
      // 新增功能数据
      showPatientInfo: true,
      showContinuationCareBtn: false, // 控制延续护理按钮显示
      // 路由监听相关
      routeWatcher: null,
      lastRoutePath: this.$route.path,
      input: "今天身体还不错",
      radio: "2",
@@ -1275,6 +1402,14 @@
          label: "其他",
          value: "7",
        },
      ],
      quickContents: [
        "病情稳定,继续当前治疗",
        "患者已死亡",
        "患者不需要随访",
        "按时服药,注意休息",
        "饮食清淡,忌辛辣",
        "预约下次复诊",
      ],
      tableDatatop: [], //题目表
      voiceDatatop: [], //题目表
@@ -1371,56 +1506,6 @@
          // 禁用今天及之前的日期
          return time.getTime() < Date.now() - 24 * 60 * 60 * 1000;
        },
        // shortcuts: [
        //   {
        //     text: "七天后",
        //     onClick(picker) {
        //       const date = new Date();
        //       date.setTime(date.getTime() + 3600 * 1000 * 24 * 7);
        //       picker.$emit("pick", date);
        //     },
        //   },
        //   {
        //     text: "15天后",
        //     onClick(picker) {
        //       const date = new Date();
        //       date.setTime(date.getTime() + 3600 * 1000 * 24 * 15);
        //       picker.$emit("pick", date);
        //     },
        //   },
        //   {
        //     text: "一个月后",
        //     onClick(picker) {
        //       const date = new Date();
        //       date.setTime(date.getTime() + 3600 * 1000 * 24 * 30);
        //       picker.$emit("pick", date);
        //     },
        //   },
        //   {
        //     text: "三个月后",
        //     onClick(picker) {
        //       const date = new Date();
        //       date.setTime(date.getTime() + 3600 * 1000 * 24 * 90);
        //       picker.$emit("pick", date);
        //     },
        //   },
        //   {
        //     text: "六个月后",
        //     onClick(picker) {
        //       const date = new Date();
        //       date.setTime(date.getTime() + 3600 * 1000 * 24 * 180);
        //       picker.$emit("pick", date);
        //     },
        //   },
        //   {
        //     text: "一年后",
        //     onClick(picker) {
        //       const date = new Date();
        //       date.setTime(date.getTime() + 3600 * 1000 * 24 * 365);
        //       picker.$emit("pick", date);
        //     },
        //   },
        // ],
      },
      options: [
        {
@@ -1506,6 +1591,9 @@
    this.Voicetype = this.$route.query.Voicetype;
    this.visitCount = this.$route.query.visitCount;
    this.serviceType = this.$route.query.serviceType;
    this.visitAgain = store.getters.visitAgain;
    console.log(store.getters.visitAgain);
    this.orgname = localStorage.getItem("orgname");
    if (this.orgname == "省立同德翠苑院区") {
      this.showContinuationCareBtn = true;
@@ -1540,6 +1628,7 @@
      ];
    }
    this.getTaskservelist();
    this.getconfigKey();
  },
  mounted() {
    // 监听子组件的sipStatus属性变化
@@ -1570,8 +1659,6 @@
  methods: {
    // 获取主题样式类
    getTopicClass(item) {
      console.log(item.isabnormal, "getTopicClass");
      // 根据状态值返回对应的样式类
      if (item.isabnormal == 1) {
        return "scriptTopic-isabnormal"; // 异常 - 红色
@@ -1581,7 +1668,30 @@
        return "scriptTopic-dev"; // 正常 - 默认样式
      }
    },
    getconfigKey() {
      getconfigKey("default.value.icon").then((res) => {
        if (res.msg) {
          if (
            this.getAssignArr(res.msg).includes(this.$store.state.user.name) ||
            this.$store.state.user.name == "admin"
          ) {
            this.defaultKey = true;
          } else {
            this.defaultKey = false;
          }
        }
      });
    },
    getAssignArr(rule) {
      let arr = [];
      let assiginArr = rule.split(",");
      for (let i = 0; i < assiginArr.length; i++) {
        arr[i] = assiginArr[i];
      }
      arr.sort(this.compare);
      return arr;
    },
    // 获取选项样式类
    getOptionClass(items) {
      if (items.isabnormal == 1) {
@@ -1590,6 +1700,29 @@
        return "yellow-star"; // 警告 - 黄色星号
      }
      return ""; // 正常 - 无特殊样式
    },
    insertText(text) {
      const textarea = this.$refs.textareaRef;
      console.log(textarea);
      if (!textarea) return;
      const target = textarea.$el.querySelector("textarea");
      const start = target.selectionStart;
      const end = target.selectionEnd;
      const original = this.form.remark;
      console.log(original, 11);
      // 在光标处插入,并更新光标位置
      this.form.remark =
        original.substring(0, start) + text + original.substring(end);
      // 保持焦点并移动光标到插入内容后
      this.$nextTick(() => {
        target.focus();
        const newPos = start + text.length;
        target.setSelectionRange(newPos, newPos);
      });
    },
    // 获取问卷数据
    getsearchrResults(id) {
@@ -1614,13 +1747,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;
@@ -1629,8 +1764,25 @@
      });
    },
    //患者360跳转
    gettoken360(sfzh, drcode, drname) {
      // this.$modal.msgWarning("360功能暂未开通");
    gettoken360(sfzh, drcode, drname, id) {
      const orgname = localStorage.getItem("orgname");
      if (orgname == "南华大学附属第一医院") {
        query360PatInfonh(id).then((res) => {
          if (res.data) {
            window.open(res.data, "_blank");
          } else {
            this.$modal.msgWarning("360查询无结果");
          }
        });
        return;
      } else if (
        orgname == "第一人民医院湖滨院区" ||
        orgname == "第一人民医院吴山院区"
      ) {
        let url = `http://192.200.81.189:9100/blj/view?BINGRENID=${id}&YONGHUID=DBA`;
        window.open(url, "_blank");
        return;
      }
      this.postData.YeWuXX.BingRenXX.ZhengJianHM = sfzh;
@@ -1744,7 +1896,7 @@
            if (item.targetvalue) {
              item.scriptResult = item.targetvalue.split("&");
            } else {
              item.scriptResult = [];
              item.scriptResult = item.asrtext;
            }
          });
@@ -1760,19 +1912,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 = [];
            }
          });
        }
@@ -1780,16 +1932,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
        );
@@ -1800,34 +1954,33 @@
            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 (Array.isArray(item.scriptResult)) {
            item.originalScriptResult = item.scriptResult; // 保存原始数组(可选)
            item.scriptResult =
              item.scriptResult.length > 0 ? item.scriptResult[0] : "";
          }
        }
        // if (item.isoption == 3) {
        //   promises.push(serviceSubtaskDetailedit(obj));
        // } else {
        //   promises.push(serviceSubtaskDetailadd(obj));
        // }
      });
      console.log(this.tableDatatop);
      // 创建副本用于保存,避免影响显示
      const saveData = this.tableDatatop.map((item) => ({
        ...item,
        // 如果需要,可以在这里做最后的数据清理
        scriptResult: item.scriptResult || "", // 确保不为 undefined
      }));
      let obj = {
        svyTaskTemplateScriptVOS: this.tableDatatop, // 提交处理后的副本
        svyTaskTemplateScriptVOS: saveData, // 使用处理后的数据
        param1: this.taskid,
        param2: this.patid,
        param6: this.id,
@@ -1836,10 +1989,14 @@
      savequestiondetail(obj).then((res) => {
        if (res.code == 200) {
          this.$modal.msgSuccess("服务保存成功");
          this.Editsingletasksonyic(6);
          this.Editsingletasksonyic(this.serviceStates);
          const orgName = localStorage.getItem("orgname");
          if (this.form.isVisitAgain != 1 || orgName == "丽水市中医院") {
          if (
            this.form.isVisitAgain != 1 ||
            orgName == "丽水市中医院" ||
            this.visitAgain == 1
          ) {
            this.Torouter();
            return;
          }
@@ -1868,51 +2025,6 @@
            });
        }
      });
      // 使用 Promise.all 等待所有异步操作完成
      // Promise.all(promises)
      //   .then((results) => {
      //     // 所有异步操作成功完成后的逻辑
      //     results.forEach((res) => {
      //       if (res.code !== 200) {
      //         this.$modal.error("修改失败");
      //       }
      //     });
      //     this.Editsingletasksonyic(6);
      //     const orgName = localStorage.getItem("orgname");
      //     console.log(orgName, "orgName");
      //     if (this.form.isVisitAgain != 1 || orgName == "丽水市中医院") {
      //       this.Torouter();
      //       return;
      //     }
      //     this.$modal
      //       .confirm(
      //         '任务保存成功是否针对患者:"' +
      //           this.userform.name +
      //           '"再次随访?',
      //         "确认",
      //         {
      //           confirmButtonText: "确定",
      //           cancelButtonText: "取消",
      //           showCancelButton: true,
      //           dangerouslyUseHTMLString: true,
      //           confirmButtonClass: "custom-confirm-button", // 自定义确认按钮的类名
      //           cancelButtonClass: "custom-cancel-button", // 自定义取消按钮的类名
      //         }
      //       )
      //       .then(() => {
      //         document.querySelector("#app").scrollTo(0, 0);
      //         this.formtidy();
      //         this.dialogFormVisible = true;
      //       })
      //       .catch(() => {
      //         this.Torouter();
      //       });
      //   })
      //   .catch((error) => {
      //     // 如果有任何一个异步操作失败,会进入这里
      //     console.error("发生错误:", error);
      //   });
    },
    Torouter() {
      if (this.form.serviceType == 13) {
@@ -1968,6 +2080,68 @@
          message: "请输入正确的电话号码(手机号或带区号的固定电话)",
        };
      }
    },
    handleTemplateSelect(templateData) {
      console.log("选择了模板:", templateData);
      // 处理模板选择逻辑
      let templateobj = templateData.templateData;
      templateobj.templateid = templateobj.svyid;
      templateobj.taskid = this.form.taskid;
      templateobj.isoperation = 1;
      templateobj.svyTaskTemplateScriptVOS = templateobj.svyTemplateLibScripts;
      templateobj.svyTaskTemplateScriptVOS.forEach((item) => {
        item.taskid = this.form.taskid;
        item.templateid = item.svyid;
        item.svyTaskTemplateTargetoptions = item.svyLibTemplateTargetoptions;
      });
      let obj = {
        subId: this.form.id,
        svyTaskTemplateVO: templateobj,
      };
      updateTemplate(obj).then((res) => {
        if (res.code) {
          location.reload();
          this.$modal.msgSuccess("模板修改成功");
        } else {
        }
      });
    },
    handleTemplateClear() {
      console.log("清除了模板选择");
    },
    handleConfirmReplace() {
      // 遍历所有题目(tableDatatop)
      this.tableDatatop.forEach((item) => {
        // 只处理未填报的题目(scriptResult 为空或空数组)
        if (
          !item.scriptResult ||
          (Array.isArray(item.scriptResult) && item.scriptResult.length === 0)
        ) {
          // 查找选项中 defaultValue 为 2 的选项
          const defaultOption = item.svyTaskTemplateTargetoptions?.find(
            (opt) => opt.defaultValue == 2
          );
          console.log(item);
          if (defaultOption) {
            // 根据题目类型赋值
            if (item.scriptType === "1") {
              // 单选题:直接赋值为 optioncontent 字符串
              item.scriptResult = defaultOption.optioncontent;
            } else if (item.scriptType === "2") {
              // 多选题:赋值为包含 optioncontent 的数组
              item.scriptResult = [defaultOption.optioncontent];
            } else if (item.scriptType === "4") {
              // 填空题:一般没有选项,但如果有则赋值
              item.scriptResult = defaultOption.optioncontent;
            }
            // 触发视图更新(因为 Vue 可能无法检测到深层嵌套对象的变化)
            this.$forceUpdate();
          }
        }
      });
    },
    // 使用示例
    isValidPhone(phone) {
@@ -2044,21 +2218,31 @@
    },
    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 = {
        ivrTaskTemplateScriptVOList: dataToSubmit, // 提交处理后的副本
@@ -2067,10 +2251,15 @@
        param6: this.id,
        type: 1,
      };
      console.log("c", 4);
      const orgName = localStorage.getItem("orgname");
      console.log(orgName, "orgName");
      if (this.form.isVisitAgain != 1 || orgName == "丽水市中医院") {
      if (
        this.form.isVisitAgain != 1 ||
        orgName == "丽水市中医院" ||
        this.visitAgain == 1
      ) {
        this.Torouter();
        return;
      }
@@ -2135,13 +2324,17 @@
          this.form = res.rows[0].serviceSubtaskList.find(
            (item) => item.id == this.id
          );
          console.log(this.form, "serviceType");
          console.log(this.form.templatename, "templatename");
          this.form.remark = this.form.remark || "";
          this.logsheetlist = res.rows[0].serviceSubtaskList;
          this.templateid = this.form.templateid;
          this.selectedTag = this.form.excep;
          const targetDate = new Date(this.form.visitTime); // 目标日期
          const now = new Date(); // 当前时间
          console.log(now, "当前时间");
          console.log(targetDate, "目标日期");
          if (now < targetDate && this.form.sendstate == 2) {
            this.$confirm("当前服务未到发送时间请谨慎修改", "提示", {
              confirmButtonText: "确定",
@@ -2197,6 +2390,8 @@
        if (res.code == 200) {
          objson = res.rows[0].serviceSubtaskList[0];
          objson.suggest = son;
          objson.remark = this.form.remark;
          objson.taskSituation = this.form.taskSituation;
          Editsingletaskson(objson).then((res) => {
            if (res.code) {
              this.$modal.msgSuccess("服务记录成功");
@@ -2233,6 +2428,15 @@
              this.getTaskservelist();
            }
          });
        }
      });
    },
    alterpatient(sendstate) {
      alterpatient(this.userform).then((res) => {
        if (res.code == 200) {
          this.$modal.msgSuccess("基础信息保存成功");
        } else {
          this.$modal.msgError("基础信息修改失败");
        }
      });
    },
@@ -2320,35 +2524,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 == "";
@@ -2407,7 +2583,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 = ""; // 清除附加信息
      // }
@@ -2477,7 +2659,6 @@
          hiddenByEnd: index === questionIndex + 1 ? false : item.hiddenByEnd,
        }));
      }
      2;
      this.$forceUpdate();
    },
@@ -2985,6 +3166,7 @@
    .dev-text {
      margin-bottom: 10px;
      display: flex;
    }
  }
}