liusheng
13 小时以前 9903954c85f651dd5cc6d4b538cfe66b17fc5baa
src/views/followvisit/discharge/index.vue
@@ -5,6 +5,8 @@
      :ycvalue="ycvalue"
      :jgvalue="jgvalue"
      :show-warning-condition="orgname == '省立同德翠苑院区'"
      clickable
      @card-click="handleCardClick"
    />
    <el-row :gutter="20">
      <!--用户数据-->
@@ -255,6 +257,11 @@
          </span>
        </div>
      </el-row>
      <div v-if="cardFilter" class="card-filter-tip">
        当前按顶部卡片筛选:<b>{{ cardFilter }}</b>
        <span class="tip-desc">(不影响上方表单条件,点「搜索」可恢复表单条件)</span>
        <el-button type="text" size="mini" @click="clearCardFilter">清除</el-button>
      </div>
      <div class="selected-info">
        已选中
        <span style="color: #409eff; font-weight: bold">{{
@@ -1278,6 +1285,8 @@
      ],
      lastScopeType: 3, // 患者范围上次选择的一级类型(1=科室,2=病区,3=全部)
      loading: false,
      // 顶部卡片点击带来的临时筛选(只作用于下面列表,不动表单、不改卡片数字;点「搜索」时清空)
      cardFilter: null,
      cardlist: [
        {
          name: "患者服务总量",
@@ -1506,6 +1515,15 @@
    // 监听路由参数变化
    "$route.query": {
      handler(newQuery, oldQuery) {
        // 右下角「待处理随访任务」卡片再次点击(当前已在本页)
        if (
          newQuery?.month &&
          newQuery?.fromPendingTask === "1" &&
          this.taskQueryReady
        ) {
          this.applyPendingTaskQuery();
          return;
        }
        if (newQuery?.errtype !== oldQuery?.errtype) {
          console.log(22);
          this.loadData();
@@ -1536,7 +1554,10 @@
    });
    // 免登直达:根据科室/病区编码预填患者范围
    this.applyFollowUpScope();
    if (this.errtype == 1) {
    // 右下角「待处理随访任务」卡片跳转:按出院年月 + 待随访 + 出院满 7 天过滤
    if (this.applyPendingTaskQuery()) {
      // 已按卡片条件查询,不再走默认分支
    } else if (this.errtype == 1) {
      this.toleadExport(2);
    } else if (this.errtype == 2) {
      // 待随访
@@ -1556,9 +1577,16 @@
    this.getConfigKey("sys.user.initPassword").then((response) => {
      this.initPassword = response.msg;
    });
    // created 初始化完成,之后路由 query 变化才按卡片条件重新查询
    this.taskQueryReady = true;
  },
  activated() {
    // 从别的标签页切回来时,以表单条件为准,丢弃卡片带来的一次性筛选
    this.cardFilter = null;
    this.errtype = this.$route.query.errtype;
    if (this.applyPendingTaskQuery()) {
      return;
    }
    if (this.errtype == 1) {
      this.toleadExport(2);
    } else if (this.errtype == 2) {
@@ -1613,7 +1641,9 @@
      }
      try {
        const response = await getTaskservelist(this.topqueryParams);
        // 顶部卡片点击的临时条件只加在本次请求上,不写回表单
        const query = this.applyCardFilter({ ...this.topqueryParams });
        const response = await getTaskservelist(query);
        // ✅ 第一步:先锁定恢复状态
        this.isRestoring = true;
@@ -1630,15 +1660,10 @@
        // ✅ 第四步:处理其他数据
        if (refresh) {
          this.cardlist[0].value =
            Number(response.rows[0].wxsf) + Number(response.rows[0].xsf) || 0;
          this.cardlist[1].value = response.rows[0].wxsf || 0;
          this.ycvalue = Number(response.rows[0].yc) || 0;
          this.jgvalue = response.rows[0].jg;
          this.cardlist[2].value = response.rows[0].xsf || 0;
          this.cardlist[3].value = response.rows[0].dsf || 0;
          this.cardlist[4].value = response.rows[0].ywc || 0;
          this.yfsvalue = response.rows[0].yfs;
          // 顶部卡片的数字不跟「随访状态/异常」走:单独查一次去掉状态条件的统计,
          // 否则筛了「待随访」后「已完成」永远是 0,看着像算错了
          this.refreshCardCounts(query);
        }
        // ✅ 第五步:处理 preachform 等其他数据
@@ -1875,6 +1900,8 @@
    },
    /** 搜索按钮操作 */
    handleQuery(refresh) {
      // 点「搜索」时以表单条件为准,清掉卡片点击带来的临时条件
      this.cardFilter = null;
      this.applyDeptWardScope();
      this.clearAllSelection();
      this.topqueryParams.pageNum = 1;
@@ -1897,6 +1924,60 @@
      if (wardCode) scope.push([2, wardCode]);
      this.topqueryParams.scopetype = scope;
      this.lastScopeType = deptCode ? 1 : 2;
    },
    /**
     * 右下角「待处理随访任务」卡片点击数字跳转过来:
     * 按出院年月 + 待随访(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;
    },
    // 患者范围处理:从多选级联 scopetype 解析科室/病区
    applyDeptWardScope() {
@@ -2340,6 +2421,74 @@
        this.topqueryParams.scopetype = null;
      }
      this.handleQuery(1);
    },
    // 顶部统计卡片点击:把对应筛选条件下带到下面的列表(数值为 0 的卡片同样可点)
    // 顶部卡片统计:去掉「随访状态 / 异常」条件后再统计,
    // 这样卡片数字只跟日期、科室/病区等条件走,不会因为筛了「待随访」就把「已完成」算成 0
    async refreshCardCounts(baseQuery) {
      const query = {
        ...(baseQuery || this.topqueryParams),
        pageNum: 1,
        pageSize: 1,
        sendstate: null,
        sendstateView: null,
        sendstates: null,
        excep: null,
      };
      try {
        const res = await getTaskservelist(query);
        const row = (res && res.rows && res.rows[0]) || {};
        this.cardlist[0].value = Number(row.wxsf || 0) + Number(row.xsf || 0);
        this.cardlist[1].value = Number(row.wxsf) || 0;
        this.cardlist[2].value = Number(row.xsf) || 0;
        this.cardlist[3].value = Number(row.dsf) || 0;
        this.cardlist[4].value = Number(row.ywc) || 0;
        this.ycvalue = Number(row.yc) || 0;
        this.jgvalue = Number(row.jg) || 0;
      } catch (e) {
        console.warn("刷新顶部卡片统计失败", e);
      }
    },
    // 顶部统计卡片点击:只给下面的列表加临时条件,不动上方表单、也不改卡片数字;
    // 卡片数字只在点「搜索」时按表单条件重算
    handleCardClick(item) {
      this.cardFilter = item && item.name ? item.name : null;
      this.topqueryParams.pageNum = 1;
      // 传 0:刷新列表,但不回写顶部卡片数字
      this.getList(0);
    },
    // 把卡片点击的条件叠加到查询参数(返回新对象,不修改表单本身)
    applyCardFilter(query) {
      const name = this.cardFilter;
      if (!name) return query;
      // 卡片数字是「不含随访状态/异常」的总量,所以点卡片时也把表单里的状态条件去掉,
      // 只按卡片自己的条件查,否则会出现「卡片 922、列表 3 条」
      query.sendstate = null;
      query.sendstateView = null;
      query.sendstates = null;
      query.excep = null;
      if (name === "无需随访") {
        query.sendstateView = 3;
      } else if (name === "待随访") {
        query.sendstateView = 1;
      } else if (name === "已完成") {
        query.sendstateView = 2;
      } else if (name === "需随访") {
        query.sendstates = [1, 2, 3, 5, 6, 7];
      } else if (name === "异常") {
        query.excep = "1";
      } else if (name === "警告") {
        query.excep = "2";
      }
      // 「患者服务总量」= 只去掉状态条件,不加别的
      return query;
    },
    // 清除卡片筛选,回到表单条件
    clearCardFilter() {
      this.cardFilter = null;
      this.topqueryParams.pageNum = 1;
      this.getList(0);
    },
    /** 导出按钮操作 */
    handleExport() {
@@ -2882,6 +3031,20 @@
  font-size: 14px;
  color: #666;
}
.card-filter-tip {
  margin: 2px 0 4px;
  padding: 6px 10px;
  font-size: 13px;
  color: #303133;
  background: #f0f7ff;
  border: 1px solid #d6e9ff;
  border-radius: 4px;
}
.card-filter-tip .tip-desc {
  margin: 0 6px;
  font-size: 12px;
  color: #909399;
}
/* ================= 清新高级简约风 ================= */
.app-container {
  background: #f5f7fb;