WXL (wul)
23 小时以前 0c7cc21d8a51e164dd2fe4ce73ab566b3a9081a9
src/views/sfstatistics/percentage/satisfaction.vue
@@ -531,11 +531,13 @@
                <el-table-column prop="chosenQuantity" label="选择人数">
                </el-table-column>
                <el-table-column prop="chosenPercentage" label="比例">
                   <template slot-scope="scope">
                  <span class="button-zx"
                    >{{ (Number(scope.row.chosenPercentage) * 100).toFixed(2) }}%</span
                  >
                </template>
                  <template slot-scope="scope">
                    <span class="button-zx"
                      >{{
                        (Number(scope.row.chosenPercentage) * 100).toFixed(2)
                      }}%</span
                    >
                  </template>
                </el-table-column>
              </el-table>
            </div>
@@ -550,19 +552,15 @@
</template>
<script>
import {
  toamendtag,
  addapitag,
  deletetag,
  changetagcategory,
} from "@/api/system/label";
import store from "@/store";
import {
  getSfStatisticsJoy,
  getSfStatisticsJoyInfo,
  selectTimelyRate,
} from "@/api/system/user";
import ExcelJS from "exceljs";
import { saveAs } from "file-saver";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
const shortcuts = [
@@ -730,7 +728,6 @@
      },
      // 查询标签列表参数
      queryParams: {
        serviceType: [2],
        dateRange: [],
        statisticaltype: 1,
@@ -771,12 +768,14 @@
          ? this.allDeptCodes
          : this.queryParams.deptcodes,
      };
      this.loading = true;
      // 移除可能存在的"all"值
      delete params.leavehospitaldistrictcodes.all;
      delete params.deptcodes.all;
      getSfStatisticsJoy(params).then((response) => {
        console.log(response);
        this.loading = false;
        this.total = response.total;
        this.userList = response.data;
      });
@@ -919,27 +918,6 @@
        this.topiclist = response.data;
      });
    },
    // 添加/修改标签
    Maintenancetag() {
      if (this.lstamendtag) {
        toamendtag(this.addDateRange(this.tagform)).then((response) => {
          console.log(response);
          this.getList();
        });
      } else {
        addapitag(this.addDateRange(this.tagform)).then((response) => {
          console.log(response);
          this.getList();
        });
      }
      this.tagform = {
        isupload: "",
        tagname: "",
        tagcategoryid: "",
        tagdescription: "",
        tagid: "",
      };
    },
    routerErr(row) {
      console.log(row, "跳转异常");
      this.$router.push({
@@ -969,22 +947,7 @@
      };
      this.resetForm("form");
    },
    // 标签状态修改
    handleStatusChange(row) {
      console.log(row.isupload);
      let text = row.isupload === "0" ? "启用" : "停用";
      this.$modal
        .confirm('确认要"' + text + '""' + row.tagname + '"标签吗?')
        .then(function () {
          return changetagcategory(row.tagid, row.isupload);
        })
        .then(() => {
          this.$modal.msgSuccess(text + "成功");
        })
        .catch(function () {
          row.isupload = row.isupload === "0" ? "1" : "0";
        });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
@@ -1015,36 +978,193 @@
      this.multiple = !selection.length;
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      console.log(row, "删除弹窗");
      const tagids = row.tagid || this.ids;
      console.log(tagids);
      const tagname = row.tagname;
      this.$modal
        .confirm(
          tagname
            ? '是否确认删除标签名称为"' + tagname + '"的数据项?'
            : "是否确认删除选中的数据项?"
        )
        .then(function () {
          return deletetag(tagids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "smartor/serviceSubtask/getSfStatisticsExport",
        {
          ...this.queryParams,
        },
        `user_${new Date().getTime()}.xlsx`
      );
    /** 导出按钮操作 */
    async handleExport() {
      try {
        // 获取并格式化日期范围
        let dateRangeString = "";
        let sheetNameSuffix = "";
        // 检查是否存在选中的日期范围
        if (
          this.queryParams.dateRange &&
          this.queryParams.dateRange.length === 2
        ) {
          const startDateStr = this.queryParams.dateRange[0]; // 开始日期,格式 "yyyy-MM-dd"
          const endDateStr = this.queryParams.dateRange[1]; // 结束日期
          // 直接使用日期部分(已经是 yyyy-MM-dd 格式)
          const startDateFormatted = startDateStr;
          const endDateFormatted = endDateStr;
          // 构建日期范围字符串
          dateRangeString = `${startDateFormatted}至${endDateFormatted}`;
          sheetNameSuffix = `${startDateFormatted}至${endDateFormatted}`;
        } else {
          // 如果没有选择日期范围,则使用当前月份作为备选方案
          const now = new Date();
          const currentMonth = now.getMonth() + 1;
          dateRangeString = `${currentMonth}月`;
          sheetNameSuffix = `${currentMonth}月`;
        }
        // 构建文件名和工作表名
        const excelName = `满意度统计表_${dateRangeString}.xlsx`;
        const worksheetName = `满意度统计_${sheetNameSuffix}`;
        // 创建工作簿和工作表
        const workbook = new ExcelJS.Workbook();
        const worksheet = workbook.addWorksheet(worksheetName);
        // 定义样式
        const titleStyle = {
          font: {
            name: "微软雅黑",
            size: 16,
            bold: true,
            color: { argb: "FF000000" },
          },
          fill: {
            type: "pattern",
            pattern: "solid",
            fgColor: { argb: "FFE6F3FF" },
          },
          alignment: {
            vertical: "middle",
            horizontal: "center",
            wrapText: true,
          },
          border: {
            top: { style: "thin", color: { argb: "FFD0D0D0" } },
            left: { style: "thin", color: { argb: "FFD0D0D0" } },
            bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
            right: { style: "thin", color: { argb: "FFD0D0D0" } },
          },
        };
        const headerStyle = {
          font: {
            name: "微软雅黑",
            size: 11,
            bold: true,
            color: { argb: "FF000000" },
          },
          fill: {
            type: "pattern",
            pattern: "solid",
            fgColor: { argb: "FFF5F7FA" },
          },
          alignment: {
            vertical: "middle",
            horizontal: "center",
            wrapText: true,
          },
          border: {
            top: { style: "thin", color: { argb: "FFD0D0D0" } },
            left: { style: "thin", color: { argb: "FFD0D0D0" } },
            bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
            right: { style: "thin", color: { argb: "FFD0D0D0" } },
          },
        };
        const cellStyle = {
          font: {
            name: "宋体",
            size: 10,
            color: { argb: "FF000000" },
          },
          alignment: {
            vertical: "middle",
            horizontal: "center",
          },
          border: {
            top: { style: "thin", color: { argb: "FFD0D0D0" } },
            left: { style: "thin", color: { argb: "FFD0D0D0" } },
            bottom: { style: "thin", color: { argb: "FFD0D0D0" } },
            right: { style: "thin", color: { argb: "FFD0D0D0" } },
          },
        };
        // 添加总标题
        worksheet.mergeCells(1, 1, 1, 10);
        const titleCell = worksheet.getCell(1, 1);
        titleCell.value = `满意度统计表(${sheetNameSuffix})`;
        titleCell.style = titleStyle;
        worksheet.getRow(1).height = 35;
        // 添加表头
        const headers = [
          "出院病区",
          "科室",
          "出院人次",
          "无需随访人次",
          "应随访人次",
          "随访率",
          "及时率",
          "满意度题目总量",
          "满意度填报量",
          "完成比率",
        ];
        const headerRow = worksheet.addRow(headers);
        headerRow.eachCell((cell) => {
          cell.style = headerStyle;
        });
        headerRow.height = 25;
        // 添加数据行
        this.userList.forEach((item) => {
          const dataRow = worksheet.addRow([
            item.leavehospitaldistrictname || "",
            item.deptname || "",
            item.dischargeCount || 0,
            item.nonFollowUp || 0,
            item.followUpNeeded || 0,
            item.followUpRate || "0%",
            item.rate ? (Number(item.rate) * 100).toFixed(2) + "%" : "0%",
            item.joyAllCount || 0,
            item.joyCount || 0,
            item.joyTotal
              ? (Number(item.joyTotal) * 100).toFixed(2) + "%"
              : "0%",
          ]);
          dataRow.eachCell((cell) => {
            cell.style = cellStyle;
          });
          dataRow.height = 22;
        });
        // 设置列宽
        worksheet.columns = [
          { width: 20 }, // 出院病区
          { width: 15 }, // 科室
          { width: 12 }, // 出院人次
          { width: 12 }, // 无需随访人次
          { width: 12 }, // 应随访人次
          { width: 12 }, // 随访率
          { width: 12 }, // 及时率
          { width: 15 }, // 满意度题目总量
          { width: 15 }, // 满意度填报量
          { width: 12 }, // 完成比率
        ];
        // 生成并下载文件
        const buffer = await workbook.xlsx.writeBuffer();
        const blob = new Blob([buffer], {
          type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
        });
        // 使用FileSaver.js保存文件[2,3](@ref)
        saveAs(blob, excelName);
        this.$message.success("导出成功");
      } catch (error) {
        console.error("导出失败:", error);
        this.$message.error(`导出失败: ${error.message}`);
      }
    },
    // 显示图表弹窗
@@ -1460,7 +1580,8 @@
  }
}
.topicdia {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: #333; /* 主文字色 */
}