WXL (wul)
3 天以前 c899dff1fce7f8054008cd9887a9729cdffd88cb
src/views/followvisit/record/detailpage/index.vue
@@ -636,10 +636,16 @@
                  <el-button
                    v-if="showQuestionnaireForm"
                    type="primary"
                    :disabled="!canSaveQuestionnaire"
                    :loading="savingQuestion"
                    @click="getdetail"
                    >保存问卷详情</el-button
                  >
                  <el-button v-else type="primary" @click="yuyingetdetail"
                  <el-button
                    v-else
                    type="primary"
                    :loading="savingQuestion"
                    @click="yuyingetdetail"
                    >保存问卷详情</el-button
                  >
                </div>
@@ -697,10 +703,15 @@
                  <el-button
                    v-if="Voicetype"
                    type="primary"
                    :loading="savingVoice"
                    @click="yuyingetdetail"
                    >保存随访详情</el-button
                  >
                  <el-button v-else type="primary" @click="getdetail"
                  <el-button
                    v-else
                    type="primary"
                    :loading="savingQuestion"
                    @click="getdetail"
                    >保存随访详情</el-button
                  >
                </div>
@@ -709,6 +720,38 @@
          </div>
        </div>
      </div>
      <!-- 未选选项提示:大字醒目提醒,允许用户坚持保存 -->
      <el-dialog
        :visible.sync="confirmSaveVisible"
        width="640px"
        append-to-body
        :close-on-click-modal="false"
        custom-class="unanswered-dialog"
      >
        <div slot="title" class="unanswered-title">
          <i class="el-icon-warning"></i> 注意:有题目没有选择选项
        </div>
        <div class="unanswered-warn">
          当前问卷还有
          <span class="unanswered-count">{{ unansweredQuestions.length }}</span>
          道题<strong>没有选择任何选项</strong>,继续保存将按“未作答”记录:
        </div>
        <div class="unanswered-list">
          <div v-for="q in unansweredQuestions" :key="q.index">
            第 {{ q.index }} 题:{{ q.title }}
          </div>
        </div>
        <div class="unanswered-tip">确定还要保存吗?</div>
        <span slot="footer">
          <el-button size="medium" @click="confirmSaveVisible = false"
            >返回补填</el-button
          >
          <el-button type="danger" size="medium" @click="confirmForceSave"
            >仍要保存</el-button
          >
        </span>
      </el-dialog>
      <!-- 人工处理 -->
      <div class="manual-action">
        <div class="Followuserinfos">
@@ -1170,7 +1213,7 @@
          <!-- 注意这里可能使用 userform.telcode -->
        </el-form-item>
        <el-form-item label="科室">
          <el-input style="width: 400px" v-model="form.deptname"></el-input>
          <el-input style="width: 400px" v-model="form.leaveldeptname"></el-input>
        </el-form-item>
        <el-form-item label="病区">
          <el-input
@@ -1224,7 +1267,7 @@
              <el-input
                style="width: 100%"
                disabled
                v-model="form.deptname"
                v-model="form.leaveldeptname"
              ></el-input>
            </el-form-item>
            <el-form-item label="病区">
@@ -1422,6 +1465,7 @@
import {
  messagelistpatient,
  alterpatient,
  particularpatient,
  listcontactinformation,
} from "@/api/patient/homepage";
import CallButton from "@/components/CallButton";
@@ -1615,6 +1659,12 @@
        "预约下次复诊",
      ],
      tableDatatop: [], //题目表
      // 保存问卷:未答题提示弹窗 / 用户坚持保存标记
      confirmSaveVisible: false,
      forceSave: false,
      // 防重复提交:保存中禁用按钮
      savingQuestion: false,
      savingVoice: false,
      voiceDatatop: [], //题目表
      dynamicTags: [],
      isMergeMode: false,
@@ -1779,6 +1829,27 @@
    }
  },
  computed: {
    // 是否有任意一道题「选了选项」或「填了备注」
    hasAnyAnswer() {
      return (this.tableDatatop || []).some((item) => this.isQuestionAnswered(item));
    },
    // 右侧处理意见/备注框是否有内容
    hasRemarkText() {
      const remark = this.form && this.form.remark;
      return remark !== null && remark !== undefined && String(remark).trim() !== "";
    },
    // 保存问卷详情的可点条件:问卷有作答 或 右边备注框有内容(有其一即可)
    canSaveQuestionnaire() {
      return this.hasAnyAnswer || this.hasRemarkText;
    },
    // 没有选择选项的题目(保存前用大字醒目提示,不区分有没有填备注)
    // index 用题目在问卷里的原始序号,方便和左边问卷对照
    unansweredQuestions() {
      return (this.tableDatatop || [])
        .map((item, i) => ({ index: i + 1, title: item.scriptContent || "未命名题目", raw: item }))
        // astrict=1 表示该题因选项跳转被跳过(已隐藏),跳过题不算“未作答”
        .filter((q) => !q.raw.astrict && !this.hasOptionValue(q.raw));
    },
    callStatusText() {
      if (this.customCallStatus) {
        return this.customCallStatus;
@@ -1831,13 +1902,7 @@
    this.orgname = localStorage.getItem("orgname");
    console.log(localStorage.getItem("orgname"));
    if (
      this.orgname == "省立同德翠苑院区" ||
      this.orgname == "省立同德之江院区" ||
      this.orgname == "省立同德闲林院区" ||
      this.orgname == "省立同德青山湖院区" ||
      this.orgname == "省立同德天目山路院区"
    ) {
    if (this.isTongdeCampus) {
      this.showContinuationCareBtn = true;
    }
@@ -1980,6 +2045,35 @@
        const newPos = start + text.length;
        target.setSelectionRange(newPos, newPos);
      });
      // 快捷语包含“死亡”时,过滤排除该患者
      if (text && text.includes("死亡")) {
        this.filterDeathPatient(text);
      }
    },
    // 快捷语包含“死亡”时过滤排除患者(参考 discharge 页患者过滤)
    filterDeathPatient(text) {
      this.$modal
        .confirm(
          "该快捷语包含“死亡”,确认将该患者过滤排除吗?过滤后该患者所有进行中任务将全部停止,且无法匹配新的随访任务,请谨慎操作!"
        )
        .then(() => {
          particularpatient(this.patid).then((response) => {
            const patient = response.data;
            patient.isoperation = 2;
            patient.notrequiredFlag = 1;
            patient.notrequiredreason = text;
            patient.filterDrname = store.getters.nickName;
            alterpatient(patient).then((res) => {
              if (res.code == 200) {
                this.$modal.msgSuccess("患者过滤成功");
              } else {
                this.$modal.msgError("患者过滤失败");
              }
            });
          });
        })
        .catch(() => {});
    },
    // 获取问卷数据
    getsearchrResults(id) {
@@ -2019,6 +2113,8 @@
          });
          this.taskname = res.data.taskName;
          this.overdata();
          // 根据已保存答案回放选项跳转逻辑,恢复被跳过题目的隐藏状态
          this.restoreJumpState();
        }
      });
    },
@@ -2194,8 +2290,52 @@
        }
      });
    },
    // 题目是否选了选项(单选字符串 / 多选数组)
    hasOptionValue(item) {
      if (!item) {
        return false;
      }
      const val = item.scriptResult;
      if (Array.isArray(val)) {
        return val.some(
          (v) => v !== null && v !== undefined && String(v).trim() !== ""
        );
      }
      return val !== null && val !== undefined && String(val).trim() !== "";
    },
    // 题目是否填了备注
    hasRemarkValue(item) {
      if (!item) {
        return false;
      }
      const remark = item.answerps;
      return (
        remark !== null && remark !== undefined && String(remark).trim() !== ""
      );
    },
    // 题目是否已作答:选了选项 或 填了备注(两者有其一即算已答)
    isQuestionAnswered(item) {
      return this.hasOptionValue(item) || this.hasRemarkValue(item);
    },
    // 未答题提示里点「仍要保存」
    confirmForceSave() {
      this.forceSave = true;
      this.confirmSaveVisible = false;
      this.getdetail();
    },
    // 医护人员存储数据
    getdetail() {
      // 问卷没作答、右边备注框也空 → 不允许保存
      if (!this.canSaveQuestionnaire) {
        this.$message.warning("请先在问卷中作答,或在右侧填写处理意见/备注");
        return;
      }
      // 还有题目没作答:大字提示,用户坚持才继续
      if (this.unansweredQuestions.length > 0 && !this.forceSave) {
        this.confirmSaveVisible = true;
        return;
      }
      this.forceSave = false;
      console.log(1);
      let excep = "";
@@ -2250,6 +2390,11 @@
        param6: this.id,
        type: 2,
      };
      // 防重复提交:保存中再次点击直接忽略
      if (this.savingQuestion) {
        return;
      }
      this.savingQuestion = true;
      savequestiondetail(obj).then((res) => {
        if (res.code == 200) {
          this.$modal.msgSuccess("服务保存成功");
@@ -2292,6 +2437,8 @@
              });
          }
        }
      }).finally(() => {
        this.savingQuestion = false;
      });
    },
    Torouter() {
@@ -2615,6 +2762,11 @@
        type: 1,
      };
      console.log("c", 4);
      // 防重复提交:保存中再次点击直接忽略
      if (this.savingVoice) {
        return;
      }
      this.savingVoice = true;
      const orgName = localStorage.getItem("orgname");
      console.log(orgName, "orgName");
@@ -2657,6 +2809,8 @@
              this.Torouter();
            });
        }
      }).finally(() => {
        this.savingVoice = false;
      });
    },
    // 再次随访数据更替
@@ -2731,7 +2885,7 @@
        name: this.form.sendname,
        age: this.form.age,
        phone: this.userform.telcode,
        deptName: this.form.deptname,
        deptName: this.form.leaveldeptname,
        wardName: this.form.leavehospitaldistrictname,
        smsTemplate: `尊敬的${this.form.sendname},您好!`,
      });
@@ -2913,7 +3067,7 @@
      getTaskservelist({
        patid: this.patid,
        visitCount: 2,
        leaveldeptcodes: [this.form.deptcode],
        leaveldeptcodes: [this.form.leaveldeptcode],
      }).then((res) => {
        if (res.rows[0].serviceSubtaskList.length) {
          if (
@@ -2923,7 +3077,7 @@
            this.$modal
              .confirm(
                '本患者在"' +
                  res.rows[0].serviceSubtaskList[0].deptname +
                  res.rows[0].serviceSubtaskList[0].leaveldeptname +
                  '"科室下已有再次随访服务进行中是否继续创建?'
              )
              .then(() => {
@@ -3131,6 +3285,63 @@
        }
      });
    },
    // 根据已保存答案回放“选项跳转”逻辑,恢复被跳过题目的隐藏状态(astrict)
    restoreJumpState() {
      const list = this.tableDatatop;
      if (!list || !list.length) return;
      // 先全部置为可见
      list.forEach((item) => {
        this.$set(item, "astrict", 0);
        this.$set(item, "hiddenByEnd", false);
      });
      for (let i = 0; i < list.length; ) {
        const q = list[i];
        let jumped = false;
        // 只有“单选 + 由选项配置跳转”且已作答的题目才可能产生跳转
        if (q.branchFlag == 1 && q.scriptType == 1 && this.hasOptionValue(q)) {
          const opt = (q.svyTaskTemplateTargetoptions || []).find(
            (o) => o.optioncontent == q.scriptResult
          );
          const next = opt ? opt.nextQuestion : null;
          if (next !== null && next !== undefined && next !== "") {
            const targetNum = Number(next);
            // 结束问答:隐藏后面所有题
            if (targetNum === 0) {
              for (let j = i + 1; j < list.length; j++) {
                this.$set(list[j], "astrict", 1);
                this.$set(list[j], "hiddenByEnd", true);
              }
              break;
            }
            const target = targetNum - 1; // 转 0-indexed
            if (target > i && target < list.length) {
              // 隐藏当前题和目标题之间的题
              for (let j = i + 1; j < target; j++) {
                this.$set(list[j], "astrict", 1);
                this.$set(list[j], "hiddenByEnd", false);
              }
              // 目标题保持可见
              this.$set(list[target], "astrict", 0);
              this.$set(list[target], "hiddenByEnd", false);
              i = target;
              jumped = true;
            }
          }
        }
        if (!jumped) {
          i++;
        }
      }
      this.$forceUpdate();
    },
    // 切换随访类型后,重置医生处理意见的校验状态(必填条件随类型变化)
    handleResourceChange() {
      this.$nextTick(() => {
@@ -3164,11 +3375,11 @@
            if (form.resource == 2) {
              form.visitDeptCode = localStorage.getItem("deptCode")
                ? localStorage.getItem("deptCode")
                : form.deptcode;
                : form.leaveldeptcode;
              form.visitDeptName = "随访中心";
            } else {
              form.visitDeptCode = form.deptcode;
              form.visitDeptName = form.deptname;
              form.visitDeptCode = form.leaveldeptcode;
              form.visitDeptName = form.leaveldeptname;
            }
          } else {
            this.$modal.msgError("未选择随访方式");
@@ -4540,4 +4751,53 @@
    margin-bottom: 12px;
  }
}
/* 未选选项提示:大字醒目提醒 */
.unanswered-title {
  font-size: 22px;
  font-weight: 700;
  color: #f56c6c;
  display: flex;
  align-items: center;
}
.unanswered-title i {
  font-size: 26px;
  margin-right: 10px;
}
.unanswered-warn {
  font-size: 20px;
  font-weight: 600;
  color: #303133;
  line-height: 1.8;
}
.unanswered-warn strong {
  color: #f56c6c;
  font-size: 22px;
}
.unanswered-count {
  font-size: 40px;
  font-weight: 700;
  color: #f56c6c;
  margin: 0 6px;
  vertical-align: middle;
}
.unanswered-list {
  margin-top: 14px;
  max-height: 300px;
  overflow-y: auto;
  padding: 12px 16px;
  background: #fef0f0;
  border: 1px solid #fbc4c4;
  border-radius: 6px;
  font-size: 18px;
  line-height: 2;
  color: #303133;
}
.unanswered-tip {
  margin-top: 18px;
  font-size: 22px;
  font-weight: 700;
  color: #f56c6c;
  text-align: center;
}
</style>