WXL (wul)
7 天以前 fb34ba28cb908bd328cf6690ab0b19a56428f4e2
src/views/followvisit/discharge/index.vue
@@ -75,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">
@@ -123,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>
@@ -259,8 +287,12 @@
      </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>
        <span class="tip-desc"
          >(不影响上方表单条件,点「搜索」可恢复表单条件)</span
        >
        <el-button type="text" size="mini" @click="clearCardFilter"
          >清除</el-button
        >
      </div>
      <div class="selected-info">
        已选中
@@ -449,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"
@@ -594,8 +636,7 @@
        />
        <el-table-column
          v-if="
            orgname == '景宁畲族自治县人民医院' ||
            orgname == '丽水市中医院'
            orgname == '景宁畲族自治县人民医院' || orgname == '丽水市中医院'
          "
          label="拨号状态"
          width="120"
@@ -1249,9 +1290,12 @@
            { value: 1, label: "被领取" },
            { value: 2, label: "待发送" },
            { value: 3, label: "已发送" },
            { value: 5, label: "发送失败" },
            { value: 7, label: "超时" },
          ],
        },
        {
          value: 40, // 一级:发送失败(单独列出,方便直接筛)
          label: "发送失败",
        },
        {
          value: 20, // 一级:已完成
@@ -1306,6 +1350,10 @@
          value: 0,
        },
        {
          name: "发送失败",
          value: 0,
        },
        {
          name: "已完成",
          value: 0,
        },
@@ -1328,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,
@@ -1393,6 +1440,8 @@
            : "",
        leaveldeptcodes: [],
        leavehospitaldistrictcodes: [],
        currentPreachforms: [],
        importanceFlagCode: "",
      },
      orgname: "",
      propss: { multiple: true },
@@ -1423,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: [
@@ -1641,9 +1700,12 @@
      }
      try {
        // 顶部卡片点击的临时条件只加在本次请求上,不写回表单
        const query = this.applyCardFilter({ ...this.topqueryParams });
        const response = await getTaskservelist(query);
        // 当前执行方式为多选,需转成逗号分隔字符串(如 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;
@@ -1661,9 +1723,13 @@
        // ✅ 第四步:处理其他数据
        if (refresh) {
          this.yfsvalue = response.rows[0].yfs;
          // 顶部卡片的数字不跟「随访状态/异常」走:单独查一次去掉状态条件的统计,
          // 否则筛了「待随访」后「已完成」永远是 0,看着像算错了
          this.refreshCardCounts(query);
          if (this.isTongdeOrg) {
            // 省立同德/南华:顶部卡片数字不跟「随访状态/异常」走,单独查一次去掉状态条件的统计
            this.refreshCardCounts(params);
          } else {
            // 其他医院:顶部数据跟随筛选条件变动,单次查询即可
            this.setCardValues(response.rows[0]);
          }
        }
        // ✅ 第五步:处理 preachform 等其他数据
@@ -1672,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(
@@ -1686,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;
          }
        });
@@ -1816,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) => {
@@ -1927,7 +1995,7 @@
    },
    /**
     * 右下角「待处理随访任务」卡片点击数字跳转过来:
     * 按出院年月 + 待随访(sendstate 1/2/3/5/7)+ 出院满 7 天 过滤,口径与卡片一致
     * 按出院年月 + 待随访(sendstate 1/2/3/7)+ 出院满 7 天 过滤,口径与卡片一致
     * @returns {boolean} 是否已按卡片条件发起查询
     */
    applyPendingTaskQuery() {
@@ -1945,11 +2013,8 @@
      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;
      }
      // 卡片统计的是「出院满 7 天」的任务,截止日 = min(该月最后一天, 今天-7 天)
      const end = this.pendingTaskMonthEnd(month);
      this.dateRange = [start, end];
      this.topqueryParams.serviceType = serviceType;
      this.topqueryParams.sendstateView = 1;
@@ -1957,24 +2022,47 @@
      // 卡片统计的是全部待随访任务(不区分首轮/复诊),列表这里同步放开
      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;
    },
    /**
     * 卡片口径的月份结束日:
     * 当月只统计出院满 7 天的,所以取「今天 - 7 天」;历史月份取当月最后一天
     * 该月最后一天(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();
      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);
      }
      // 出院满 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;
@@ -2060,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;
@@ -2083,6 +2176,8 @@
        scopetype: [],
        leaveldeptcodes: [],
        leavehospitaldistrictcodes: [],
        currentPreachforms: [],
        importanceFlagCode: "",
      };
      this.handleQuery(1);
    },
@@ -2103,6 +2198,8 @@
        scopetype: [],
        leaveldeptcodes: [],
        leavehospitaldistrictcodes: [],
        currentPreachforms: [],
        importanceFlagCode: "",
      };
    },
    handleSelectionChange(rows) {
@@ -2425,6 +2522,18 @@
    // 顶部统计卡片点击:把对应筛选条件下带到下面的列表(数值为 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),
@@ -2438,13 +2547,11 @@
      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;
        // 接口没返回统计行时保持原值,避免一次异常把卡片全刷成 0
        if (!res || !res.rows || !res.rows.length) {
          return;
        }
        this.setCardValues(row);
      } catch (e) {
        console.warn("刷新顶部卡片统计失败", e);
      }
@@ -2472,6 +2579,8 @@
        query.sendstateView = 3;
      } else if (name === "待随访") {
        query.sendstateView = 1;
      } else if (name === "发送失败") {
        query.sendstates = [5];
      } else if (name === "已完成") {
        query.sendstateView = 2;
      } else if (name === "需随访") {