liusheng
13 小时以前 9903954c85f651dd5cc6d4b538cfe66b17fc5baa
src/views/followvisit/discharge/outpatientService.vue
@@ -1117,7 +1117,21 @@
      rules: {},
    };
  },
  watch: {},
  watch: {
    // 右下角「待处理随访任务」卡片再次点击(当前已在本页)
    "$route.query": {
      handler(newQuery) {
        if (
          newQuery?.month &&
          newQuery?.fromPendingTask === "1" &&
          this.taskQueryReady
        ) {
          this.applyPendingTaskQuery();
        }
      },
      immediate: true,
    },
  },
  created() {
    this.serviceState = store.getters.serviceState;
    this.checkboxlist = store.getters.checkboxlist;
@@ -1136,7 +1150,9 @@
        value: dept.districtCode,
      };
    });
    if (this.errtype) {
    if (this.applyPendingTaskQuery()) {
      // 右下角「待处理随访任务」卡片跳转:已按年月 + 待随访条件查询
    } else if (this.errtype) {
      this.toleadExport(2);
    } else {
      this.getList(1);
@@ -1144,8 +1160,13 @@
    this.getConfigKey("sys.user.initPassword").then((response) => {
      this.initPassword = response.msg;
    });
    // created 初始化完成,之后路由 query 变化才按卡片条件重新查询
    this.taskQueryReady = true;
  },
  activated() {
    if (this.applyPendingTaskQuery()) {
      return;
    }
    this.getList(1);
  },
  methods: {
@@ -1350,6 +1371,60 @@
      };
      this.resetForm("form");
    },
    /**
     * 右下角「待处理随访任务」卡片点击数字跳转过来:
     * 按出院年月 + 待随访(sendstate 1/2/3/5/7)+ 出院满 7 天 过滤,口径与卡片一致
     * @returns {boolean} 是否已按卡片条件发起查询
     */
    applyPendingTaskQuery() {
      const query = this.$route.query || {};
      if (!query.month || query.fromPendingTask !== "1") {
        return false;
      }
      // 页面被 keep-alive 复用时会重复触发 activated,同一次点击只处理一次
      if (this.pendingTaskToken && this.pendingTaskToken === query._t) {
        return false;
      }
      this.pendingTaskToken = query._t;
      const month = String(query.month);
      const serviceType = Number(query.serviceType) === 3 ? 3 : 2;
      this.errtype = undefined;
      const start = month + "-01";
      let end = this.pendingTaskMonthEnd(month);
      // 月初 7 天内,"今天-7天" 会早于月初,兜底成月初,避免日期区间倒挂
      if (end < start) {
        end = start;
      }
      this.dateRange = [start, end];
      this.topqueryParams.serviceType = serviceType;
      this.topqueryParams.sendstateView = 1;
      this.topqueryParams.sendstate = null;
      // 卡片统计的是全部待随访任务(不区分首轮/复诊),列表这里同步放开
      this.topqueryParams.visitCount = null;
      this.topqueryParams.pageNum = 1;
      this.handleQuery(1);
      return true;
    },
    /**
     * 卡片口径的月份结束日:
     * 当月只统计出院满 7 天的,所以取「今天 - 7 天」;历史月份取当月最后一天
     */
    pendingTaskMonthEnd(month) {
      const parts = String(month).split("-");
      const year = Number(parts[0]);
      const mon = Number(parts[1]);
      const now = new Date();
      let date;
      if (year === now.getFullYear() && mon === now.getMonth() + 1) {
        date = new Date(year, mon - 1, now.getDate() - 7);
      } else {
        date = new Date(year, mon, 0);
      }
      const mm = String(date.getMonth() + 1).padStart(2, "0");
      const dd = String(date.getDate()).padStart(2, "0");
      return date.getFullYear() + "-" + mm + "-" + dd;
    },
    /** 搜索按钮操作 */
    handleQuery(refresh) {
      if (this.topqueryParams.searchscope == 3) {