WXL (wul)
8 天以前 fb34ba28cb908bd328cf6690ab0b19a56428f4e2
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">
      <!--用户数据-->
@@ -73,7 +75,7 @@
        <el-form-item label="经管医生" prop="managementDoctor">
          <el-input
            v-model="topqueryParams.managementDoctor"
            placeholder="请输入主治医生"
            placeholder="请输入经管医生"
          ></el-input>
        </el-form-item>
        <el-form-item label="日期限制" prop="status">
@@ -121,6 +123,34 @@
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="当前执行方式" prop="currentPreachforms">
          <el-select
            v-model="topqueryParams.currentPreachforms"
            placeholder="请选择"
            multiple
            clearable
            collapse-tags
          >
            <el-option
              v-for="item in currentPreachformOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          v-if="isTongdeCampus"
          label="日间标记"
          prop="importanceFlagCode"
        >
          <el-input
            v-model="topqueryParams.importanceFlagCode"
            placeholder="请输入日间标记"
          ></el-input>
        </el-form-item>
        <el-form-item>
@@ -255,6 +285,15 @@
          </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">{{
@@ -442,6 +481,16 @@
        >
        </el-table-column>
        <el-table-column
          v-if="isTongdeCampus"
          label="日间标记"
          align="center"
          key="importanceFlagCode"
          prop="importanceFlagCode"
          width="120"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          label="随访完成时间"
          sortable
          align="center"
@@ -587,8 +636,7 @@
        />
        <el-table-column
          v-if="
            orgname == '景宁畲族自治县人民医院' ||
            orgname == '丽水市中医院'
            orgname == '景宁畲族自治县人民医院' || orgname == '丽水市中医院'
          "
          label="拨号状态"
          width="120"
@@ -1242,9 +1290,12 @@
            { value: 1, label: "被领取" },
            { value: 2, label: "待发送" },
            { value: 3, label: "已发送" },
            { value: 5, label: "发送失败" },
            { value: 7, label: "超时" },
          ],
        },
        {
          value: 40, // 一级:发送失败(单独列出,方便直接筛)
          label: "发送失败",
        },
        {
          value: 20, // 一级:已完成
@@ -1278,6 +1329,8 @@
      ],
      lastScopeType: 3, // 患者范围上次选择的一级类型(1=科室,2=病区,3=全部)
      loading: false,
      // 顶部卡片点击带来的临时筛选(只作用于下面列表,不动表单、不改卡片数字;点「搜索」时清空)
      cardFilter: null,
      cardlist: [
        {
          name: "患者服务总量",
@@ -1294,6 +1347,10 @@
        },
        {
          name: "待随访",
          value: 0,
        },
        {
          name: "发送失败",
          value: 0,
        },
        {
@@ -1319,8 +1376,7 @@
        btstatus: "",
      },
      // endOut: 1,
      endOut:
        localStorage.getItem("orgname") == "景宁畲族自治县人民医院" ? 0 : 1, //0 出院时间(正序)    1 出院时间(倒序)   2 发送时间(正序)    3 发送时间(倒序)  7应随访日期(倒序) 应随访日期(正序)
      endOut: localStorage.getItem("orgname") == "丽水市中医院" ? 0 : 1, //0 出院时间(正序)    1 出院时间(倒序)   2 发送时间(正序)    3 发送时间(倒序)  7应随访日期(倒序) 应随访日期(正序)
      endOuts: [
        {
          value: 0,
@@ -1384,6 +1440,8 @@
            : "",
        leaveldeptcodes: [],
        leavehospitaldistrictcodes: [],
        currentPreachforms: [],
        importanceFlagCode: "",
      },
      orgname: "",
      propss: { multiple: true },
@@ -1414,6 +1472,16 @@
          value: 5,
          label: "无需随访",
        },
      ],
      currentPreachformOptions: [
        { value: "1", label: "人工" },
        { value: "2", label: "纸质" },
        { value: "3", label: "智能语音" },
        { value: "4", label: "短信" },
        { value: "5", label: "微信公众号" },
        { value: "6", label: "微信小程序" },
        { value: "7", label: "术后随访" },
      ],
      sextype: [
@@ -1506,6 +1574,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 +1613,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 +1636,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 +1700,12 @@
      }
      try {
        const response = await getTaskservelist(this.topqueryParams);
        // 当前执行方式为多选,需转成逗号分隔字符串(如 1,2,5)
        const params = { ...this.topqueryParams };
        if (Array.isArray(params.currentPreachforms)) {
          params.currentPreachforms = params.currentPreachforms.join(",");
        }
        const response = await getTaskservelist(params);
        // ✅ 第一步:先锁定恢复状态
        this.isRestoring = true;
@@ -1630,15 +1722,14 @@
        // ✅ 第四步:处理其他数据
        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;
          if (this.isTongdeOrg) {
            // 省立同德/南华:顶部卡片数字不跟「随访状态/异常」走,单独查一次去掉状态条件的统计
            this.refreshCardCounts(params);
          } else {
            // 其他医院:顶部数据跟随筛选条件变动,单次查询即可
            this.setCardValues(response.rows[0]);
          }
        }
        // ✅ 第五步:处理 preachform 等其他数据
@@ -1647,10 +1738,13 @@
          if (item.endtime) {
            item.endDay = this.daysBetween(item.endtime);
          }
          console.log(item, "3");
          if (item.preachform) {
            item.preachformson = item.preachform;
            idArray = item.preachform.split(",");
            console.log(this.checkboxlist);
            console.log(idArray);
            item.preachform = idArray.map((value) => {
              const item = this.checkboxlist.find(
@@ -1661,9 +1755,8 @@
          }
          if (item.currentPreachform) {
            item.currentPreachform = this.checkboxlist.find(
              (item) => item.value == item.currentPreachform
            )?.value;
            console.log(item.currentPreachform, "mi");
              (items) => items.value == item.currentPreachform
            )?.label;
          }
        });
@@ -1791,9 +1884,9 @@
        this.cardlist[2].value = response.rows[0].ysf;
        this.ycvalue = Number(response.rows[0].yc) || 0;
        this.jgvalue = response.rows[0].jg;
        this.cardlist[3].value = response.rows[0].fssb;
        this.cardlist[4].value = response.rows[0].dsf;
        // this.cardlist[5].value = response.rows[0].yfs2;
        this.cardlist[3].value = response.rows[0].dsf;
        this.cardlist[4].value = response.rows[0].fssb;
        this.cardlist[5].value = response.rows[0].ywc;
        this.yfsvalue = response.rows[0].yfs;
        this.loading = false;
        this.userList.forEach((item) => {
@@ -1875,6 +1968,8 @@
    },
    /** 搜索按钮操作 */
    handleQuery(refresh) {
      // 点「搜索」时以表单条件为准,清掉卡片点击带来的临时条件
      this.cardFilter = null;
      this.applyDeptWardScope();
      this.clearAllSelection();
      this.topqueryParams.pageNum = 1;
@@ -1897,6 +1992,80 @@
      if (wardCode) scope.push([2, wardCode]);
      this.topqueryParams.scopetype = scope;
      this.lastScopeType = deptCode ? 1 : 2;
    },
    /**
     * 右下角「待处理随访任务」卡片点击数字跳转过来:
     * 按出院年月 + 待随访(sendstate 1/2/3/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";
      // 卡片统计的是「出院满 7 天」的任务,截止日 = min(该月最后一天, 今天-7 天)
      const end = this.pendingTaskMonthEnd(month);
      this.dateRange = [start, end];
      this.topqueryParams.serviceType = serviceType;
      this.topqueryParams.sendstateView = 1;
      this.topqueryParams.sendstate = null;
      // 卡片统计的是全部待随访任务(不区分首轮/复诊),列表这里同步放开
      this.topqueryParams.visitCount = null;
      this.topqueryParams.pageNum = 1;
      // 当月还没到第 8 天时,该月不可能有「出院满 7 天」的任务(卡片显示 0),列表直接给空。
      // 日期框仍显示该月的自然区间,避免出现「起止倒挂」的筛选条件。
      if (end < start) {
        this.dateRange = [start, this.pendingTaskMonthLastDay(month)];
        this.userList = [];
        this.total = 0;
        this.loading = false;
        this.$message.info("该月暂无出院满 7 天的待随访任务");
        return true;
      }
      this.handleQuery(1);
      return true;
    },
    /**
     * 该月最后一天(yyyy-MM-dd),只用于「当月还没有满 7 天任务」时展示正常月份区间
     */
    pendingTaskMonthLastDay(month) {
      const parts = String(month).split("-");
      const date = new Date(Number(parts[0]), Number(parts[1]), 0);
      const mm = String(date.getMonth() + 1).padStart(2, "0");
      const dd = String(date.getDate()).padStart(2, "0");
      return date.getFullYear() + "-" + mm + "-" + dd;
    },
    /**
     * 卡片口径的月份结束日:卡片只统计「出院满 7 天仍未随访」的任务,
     * 所以截止日永远是 min(该月最后一天, 今天-7 天);
     * 历史月份同样要按「今天-7 天」截断,否则月末几天出院的患者会被算进来(卡片 49、列表 77)。
     */
    pendingTaskMonthEnd(month) {
      const parts = String(month).split("-");
      const year = Number(parts[0]);
      const mon = Number(parts[1]);
      const now = new Date();
      // 出院满 7 天:出院日期 <= 今天-7(与后端 endtime < 今天-6 00:00 等价)
      const cutoff = new Date(
        now.getFullYear(),
        now.getMonth(),
        now.getDate() - 7
      );
      const monthEnd = new Date(year, mon, 0);
      const date = cutoff < monthEnd ? cutoff : monthEnd;
      const mm = String(date.getMonth() + 1).padStart(2, "0");
      const dd = String(date.getDate()).padStart(2, "0");
      return date.getFullYear() + "-" + mm + "-" + dd;
    },
    // 患者范围处理:从多选级联 scopetype 解析科室/病区
    applyDeptWardScope() {
@@ -1979,6 +2148,11 @@
            break;
        }
        this.topqueryParams.sendstate = null;
        // 一级「发送失败」:按状态 5 直接过滤(不等同于待随访)
        if (value === 40) {
          this.topqueryParams.sendstateView = null;
          this.topqueryParams.sendstate = 5;
        }
      } else {
        // 选中了二级(具体状态)
        this.topqueryParams.sendstateView = null;
@@ -2002,6 +2176,8 @@
        scopetype: [],
        leaveldeptcodes: [],
        leavehospitaldistrictcodes: [],
        currentPreachforms: [],
        importanceFlagCode: "",
      };
      this.handleQuery(1);
    },
@@ -2022,6 +2198,8 @@
        scopetype: [],
        leaveldeptcodes: [],
        leavehospitaldistrictcodes: [],
        currentPreachforms: [],
        importanceFlagCode: "",
      };
    },
    handleSelectionChange(rows) {
@@ -2340,6 +2518,86 @@
        this.topqueryParams.scopetype = null;
      }
      this.handleQuery(1);
    },
    // 顶部统计卡片点击:把对应筛选条件下带到下面的列表(数值为 0 的卡片同样可点)
    // 顶部卡片统计:去掉「随访状态 / 异常」条件后再统计,
    // 这样卡片数字只跟日期、科室/病区等条件走,不会因为筛了「待随访」就把「已完成」算成 0
    // 把一次查询返回的统计行写入顶部卡片
    setCardValues(row) {
      if (!row) return;
      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.fssb) || 0;
      this.cardlist[5].value = Number(row.ywc) || 0;
      this.ycvalue = Number(row.yc) || 0;
      this.jgvalue = Number(row.jg) || 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]) || {};
        // 接口没返回统计行时保持原值,避免一次异常把卡片全刷成 0
        if (!res || !res.rows || !res.rows.length) {
          return;
        }
        this.setCardValues(row);
      } 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.sendstates = [5];
      } 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 +3140,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;