WXL (wul)
6 天以前 a5cba9ab040f6f97558046885dce3017f9bab7e9
src/views/sfstatistics/percentage/components/FirstFollowUp.vue
@@ -231,11 +231,13 @@
                  </template>
                </el-table-column>
                <el-table-column
                  v-if="orgname != '景宁畲族自治县人民医院'"
                  label="成功率"
                  align="center"
                  width="120"
                  key="successRate"
                  prop="successRate"
                  :render-header="Tooltipcgl"
                >
                  <template slot-scope="scope">
                    <span class="success-rate">{{
@@ -253,6 +255,7 @@
                  width="120"
                  key="followUpRate"
                  prop="followUpRate"
                  :render-header="Tooltipsfl"
                />
                <el-table-column
                  v-if="orgname != '丽水市中医院'"
@@ -261,6 +264,7 @@
                  width="120"
                  key="rate"
                  prop="rate"
                  :render-header="Tooltipjsl"
                >
                  <template slot-scope="scope">
                    <el-button
@@ -275,7 +279,6 @@
                  </template>
                </el-table-column>
                <el-table-column
                  v-if="orgname != '丽水市中医院'"
                  label="人工"
                  align="center"
                  key="manual"
@@ -299,7 +302,6 @@
                  </template>
                </el-table-column>
                <el-table-column
                  v-if="orgname != '丽水市中医院'"
                  label="语音"
                  align="center"
                  key="voice"
@@ -323,7 +325,6 @@
                  </template>
                </el-table-column>
                <el-table-column
                  v-if="orgname != '丽水市中医院'"
                  label="短信"
                  align="center"
                  key="sms"
@@ -347,7 +348,6 @@
                  </template>
                </el-table-column>
                <el-table-column
                  v-if="orgname != '丽水市中医院'"
                  label="微信"
                  align="center"
                  key="weChat"
@@ -542,11 +542,13 @@
            </template>
          </el-table-column>
          <el-table-column
            v-if="orgname != '景宁畲族自治县人民医院'"
            label="成功率"
            align="center"
            width="120"
            key="successRate"
            prop="successRate"
            :render-header="Tooltipcgl"
          >
            <template slot-scope="scope">
              <span class="success-rate">{{
@@ -564,6 +566,7 @@
            width="120"
            key="followUpRate"
            prop="followUpRate"
            :render-header="Tooltipsfl"
          />
          <el-table-column
            v-if="orgname != '丽水市中医院'"
@@ -572,6 +575,7 @@
            width="120"
            key="rate"
            prop="rate"
            :render-header="Tooltipjsl"
          >
            <template slot-scope="scope">
              <el-button
@@ -586,7 +590,6 @@
            </template>
          </el-table-column>
          <el-table-column
            v-if="orgname != '丽水市中医院'"
            label="人工"
            align="center"
            key="manual"
@@ -604,13 +607,7 @@
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            v-if="orgname != '丽水市中医院'"
            label="语音"
            align="center"
            key="voice"
            prop="voice"
          >
          <el-table-column label="语音" align="center" key="voice" prop="voice">
            <template slot-scope="scope">
              <el-button
                size="medium"
@@ -623,13 +620,7 @@
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            v-if="orgname != '丽水市中医院'"
            label="短信"
            align="center"
            key="sms"
            prop="sms"
          >
          <el-table-column label="短信" align="center" key="sms" prop="sms">
            <template slot-scope="scope">
              <el-button
                size="medium"
@@ -641,7 +632,6 @@
            </template>
          </el-table-column>
          <el-table-column
            v-if="orgname != '丽水市中医院'"
            label="微信"
            align="center"
            key="weChat"
@@ -719,6 +709,7 @@
<script>
import { getSfStatisticsHyperlink } from "@/api/AiCentre/index";
import store from "@/store";
import { getSfStatistics, selectTimelyRate } from "@/api/system/user";
import ExcelJS from "exceljs";
@@ -755,6 +746,7 @@
      expands: [],
      ids: [],
      patientqueryParams: { pn: 1, ps: 10 },
      tasktypes: store.getters.tasktypes,
    };
  },
  methods: {
@@ -774,7 +766,7 @@
      delete params.leavehospitaldistrictcodes.all;
      delete params.deptcodes.all;
      params.rateDay = 7;
      params.rateDay = this.orgname == "龙泉市人民医院" ? 21 : 7;
      getSfStatistics(params)
        .then((response) => {
          this.tableData = this.customSort(response.data);
@@ -879,7 +871,46 @@
        return indexA - indexB;
      });
    },
    Tooltipcgl(h, { column }) {
      return h(
        "el-tooltip",
        {
          props: {
            content: "随访成功/(需随访-待随访)",
            placement: "top",
            effect: "dark",
          },
        },
        [h("span", column.label)]
      );
    },
    Tooltipjsl(h, { column }) {
      return h(
        "el-tooltip",
        {
          props: {
            content:
              "(出院时间+任务周期)小于完成时间即为超时;(需随访-超时)/需随访",
            placement: "top",
            effect: "dark",
          },
        },
        [h("span", column.label)]
      );
    },
    Tooltipsfl(h, { column }) {
      return h(
        "el-tooltip",
        {
          props: {
            content: "(随访成功+首次随访失败)/首次应随访",
            placement: "top",
            effect: "dark",
          },
        },
        [h("span", column.label)]
      );
    },
    sortChineseNumber(aRow, bRow) {
      const a = aRow.leavehospitaldistrictname;
      const b = bRow.leavehospitaldistrictname;
@@ -987,7 +1018,7 @@
      if (!row.doctorStats) {
        this.loading = true;
        params.rateDay = 7;
        params.rateDay = this.orgname == "龙泉市人民医院" ? 21 : 7;
        getSfStatistics(params).then((res) => {
          this.$set(row, "doctorStats", res.data);
@@ -1201,31 +1232,106 @@
        let dateRangeString = "";
        let sheetNameSuffix = "";
        // 判断是否是丽水市中医院
        const isLishuiHospital = this.orgname == "丽水市中医院";
        if (
          this.queryParams.dateRange &&
          this.queryParams.dateRange.length === 2
        ) {
          const startDateStr = this.queryParams.dateRange[0];
          const endDateStr = this.queryParams.dateRange[1];
          const formatDateForDisplay = (dateTimeStr) => {
            return dateTimeStr.split(" ")[0];
          };
          const startDateFormatted = formatDateForDisplay(startDateStr);
          const endDateFormatted = formatDateForDisplay(endDateStr);
          dateRangeString = `${startDateFormatted}至${endDateFormatted}`;
          sheetNameSuffix = `${startDateFormatted}至${endDateFormatted}`;
          if (isLishuiHospital) {
            // 丽水市中医院:只显示年月
            const formatMonthOnly = (dateTimeStr) => {
              const date = new Date(dateTimeStr);
              const year = date.getFullYear();
              const month = date.getMonth() + 1;
              return `${year}年${month}月`;
            };
            const startDateFormatted = formatMonthOnly(startDateStr);
            const endDateFormatted = formatMonthOnly(endDateStr);
            dateRangeString = `${startDateFormatted}至${endDateFormatted}`;
            sheetNameSuffix = `${startDateFormatted}至${endDateFormatted}`;
          } else {
            // 其他医院:显示年月日
            const formatDateForDisplay = (dateTimeStr) => {
              return dateTimeStr.split(" ")[0];
            };
            const startDateFormatted = formatDateForDisplay(startDateStr);
            const endDateFormatted = formatDateForDisplay(endDateStr);
            dateRangeString = `${startDateFormatted}至${endDateFormatted}`;
            sheetNameSuffix = `${startDateFormatted}至${endDateFormatted}`;
          }
        } else {
          const now = new Date();
          const currentMonth = now.getMonth() + 1;
          dateRangeString = `${currentMonth}月`;
          sheetNameSuffix = `${currentMonth}月`;
          const currentYear = now.getFullYear();
          if (isLishuiHospital) {
            // 丽水市中医院:显示年月
            dateRangeString = `${currentYear}年${currentMonth}月`;
            sheetNameSuffix = `${currentYear}年${currentMonth}月`;
          } else {
            // 其他医院:显示月份
            dateRangeString = `${currentMonth}月`;
            sheetNameSuffix = `${currentMonth}月`;
          }
        }
        const excelName = `首次出院随访统计表_${dateRangeString}.xlsx`;
        const worksheetName = `首次随访统计_${sheetNameSuffix}`;
        // 根据 serviceType 生成随访类型名称
        let serviceTypeName = "首次出院随访"; // 文件名使用的名称
        let sheetTypeName = "首次随访"; // 工作表使用的名称(简化版)
        if (
          this.queryParams.serviceType &&
          Array.isArray(this.queryParams.serviceType) &&
          this.queryParams.serviceType.length > 0
        ) {
          // 使用 props 中的 options(即 tasktypes)
          if (this.options && Array.isArray(this.options)) {
            const matchedTypes = this.options.filter((task) =>
              this.queryParams.serviceType.includes(task.value)
            );
            console.log(matchedTypes, "matchedTypes");
            if (matchedTypes.length === 1) {
              const label = matchedTypes[0].label;
              serviceTypeName = `首次${label}`;
              sheetTypeName = `首次${label}`;
            } else if (matchedTypes.length > 1) {
              const typeNames = matchedTypes.map((task) => task.label);
              serviceTypeName = `首次${typeNames.join("/")}`;
              // 工作表名简化(取第一个+“等”)
              sheetTypeName = `首次${typeNames[0]}等`;
            } else if (this.queryParams.serviceType.length > 0) {
              // 无匹配时使用原始值
              const typeStr = this.queryParams.serviceType.join("/");
              serviceTypeName = `首次${typeStr}`;
              sheetTypeName = "首次随访";
            }
          } else if (this.queryParams.serviceType.length > 0) {
            const typeStr = this.queryParams.serviceType.join("/");
            serviceTypeName = `首次${typeStr}`;
            sheetTypeName = "首次随访";
          }
        }
        const excelName = `${serviceTypeName}统计表_${dateRangeString}.xlsx`;
        // 清理工作表名称,移除非法字符
        const cleanSheetName = (name) => {
          // Excel工作表名不能包含的字符: * ? : \ / [ ]
          return name.replace(/[*?:\\/[\]]/g, " ");
        };
        const worksheetName = cleanSheetName(
          `${sheetTypeName}统计_${sheetNameSuffix}`
        );
        if (!this.tableData || this.tableData.length === 0) {
          this.$message.warning("暂无首次随访数据可导出");
          this.$message.warning(`暂无${serviceTypeName}数据可导出`);
          return false;
        }
@@ -1233,7 +1339,7 @@
        const worksheet = workbook.addWorksheet(worksheetName);
        // 构建表格
        this.buildExportSheet(worksheet, sheetNameSuffix);
        this.buildExportSheet(worksheet, sheetNameSuffix, serviceTypeName);
        const buffer = await workbook.xlsx.writeBuffer();
        const blob = new Blob([buffer], {
@@ -1462,7 +1568,7 @@
      return sums;
    },
    buildExportSheet(worksheet, sheetNameSuffix) {
    buildExportSheet(worksheet, sheetNameSuffix, serviceTypeName) {
      const titleStyle = {
        font: {
          name: "微软雅黑",
@@ -1536,11 +1642,11 @@
          right: { style: "thin", color: { argb: "FFD0D0D0" } },
        },
      };
      const titleText = `${serviceTypeName}统计表_${sheetNameSuffix}`;
      // 添加标题行
      worksheet.mergeCells(1, 1, 1, 16);
      const titleCell = worksheet.getCell(1, 1);
      titleCell.value = `首次出院随访统计表_${sheetNameSuffix}`;
      titleCell.value = titleText; // 使用动态标题
      titleCell.style = titleStyle;
      worksheet.getRow(1).height = 35;
@@ -1586,7 +1692,7 @@
      worksheet.getCell(2, 6).value = "应随访人次";
      worksheet.mergeCells(2, 7, 2, 16); // 从7合并到16(原来是7-15)
      worksheet.getCell(2, 7).value = "首次出院随访";
      worksheet.getCell(2, 7).value = serviceTypeName; // 或适当截取
      worksheet.getCell(2, 7).style = headerStyle;
      worksheet.getRow(2).height = 28;
@@ -1769,7 +1875,6 @@
      this.patientqueryParams.serviceTypes = queryParams.serviceType
        ? queryParams.serviceType.join(",")
        : null;
      console.log(2);
      return selectTimelyRate(this.patientqueryParams);
    },