From 3cf6f5204b0ade9aa5022d5fcecbef095c575918 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期二, 16 十二月 2025 09:44:41 +0800
Subject: [PATCH] 测试完成
---
src/views/sfstatistics/percentage/index.vue | 324 +++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 309 insertions(+), 15 deletions(-)
diff --git a/src/views/sfstatistics/percentage/index.vue b/src/views/sfstatistics/percentage/index.vue
index fe833bd..15efdc4 100644
--- a/src/views/sfstatistics/percentage/index.vue
+++ b/src/views/sfstatistics/percentage/index.vue
@@ -113,7 +113,7 @@
plain
icon="el-icon-download"
size="medium"
- @click="handleExport"
+ @click="exportTable"
>瀵煎嚭</el-button
>
<el-button
@@ -128,6 +128,8 @@
</el-form>
<div class="your-table-container">
<el-table
+ ref="exportTable"
+ id="exportTableid"
v-loading="loading"
:data="userList"
:border="true"
@@ -864,7 +866,10 @@
} from "@/api/system/label";
import store from "@/store";
import { getSfStatistics, selectTimelyRate } from "@/api/system/user";
-
+import * as XLSX from "xlsx";
+import FileSaver from "file-saver";
+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 = [
@@ -1089,7 +1094,7 @@
sums[index] = "鍚堣";
return;
}
- if (index === 1||index === 2) {
+ if (index === 1 || index === 2) {
sums[index] = "/";
return;
}
@@ -1460,16 +1465,293 @@
})
.catch(() => {});
},
- /** 瀵煎嚭鎸夐挳鎿嶄綔 */
- handleExport() {
- this.download(
- "smartor/serviceSubtask/getSfStatisticsExport",
- {
- ...this.queryParams,
- },
- `user_${new Date().getTime()}.xlsx`
- );
+ // 瀵煎嚭鏂规硶
+ // 鏇挎崲鎮ㄥ師鏉ョ殑 exportTable 鏂规硶
+ async exportTable() {
+ try {
+ // 鑾峰彇褰撳墠鏃ユ湡
+ const now = new Date();
+ // 鑾峰彇褰撳墠鏈堜唤锛堟敞鎰忔湀浠戒粠0寮�濮嬶紝闇�瑕佸姞1锛�
+ const currentMonth = now.getMonth() + 1;
+ // 鏋勫缓鏂囦欢鍚�
+ const excelName = `${currentMonth}鏈堝嚭闄㈤殢璁跨粺璁¤〃.xlsx`;
+ // 鍒涘缓鏂扮殑宸ヤ綔绨垮拰宸ヤ綔琛�
+ const workbook = new ExcelJS.Workbook();
+ const worksheet = workbook.addWorksheet("闅忚缁熻");
+
+ // 瀹氫箟鏍峰紡
+ 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" } },
+ },
+ };
+
+ const summaryStyle = {
+ font: {
+ name: "瀹嬩綋",
+ size: 10,
+ bold: true,
+ color: { argb: "FF409EFF" },
+ },
+ fill: {
+ type: "pattern",
+ pattern: "solid",
+ fgColor: { argb: "FFF5F7FA" },
+ },
+ 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" } },
+ },
+ };
+
+ // 1. 棣栧厛锛屽垱寤哄苟璁剧疆绗簩琛岋紙瀛愯〃澶达級鐨勬墍鏈夊崟鍏冩牸
+ const secondRowHeaders = [
+ "", // A2 灞曞紑鍒楀崰浣嶏紙鍏跺�煎皢鐢辩涓�琛屽悎骞跺悗鐨勪富鍗曞厓鏍煎喅瀹氾級
+ "鍑洪櫌鐥呭尯",
+ "绉戝",
+ "鍑洪櫌浜烘",
+ "鏃犻渶闅忚浜烘",
+ "搴旈殢璁夸汉娆�", // B2 to F2
+ // 棣栨鍑洪櫌闅忚瀛愯〃澶�
+ "闇�闅忚",
+ "寰呴殢璁�",
+ "闅忚鎴愬姛",
+ "闅忚澶辫触",
+ "闅忚鐜�",
+ "鍙婃椂鐜�",
+ "浜哄伐",
+ "鐭俊",
+ "寰俊",
+ // 鍐嶆鍑洪櫌闅忚瀛愯〃澶�
+ "闇�闅忚",
+ "寰呴殢璁�",
+ "闅忚鎴愬姛",
+ "闅忚澶辫触",
+ "闅忚鐜�",
+ "浜哄伐",
+ "鐭俊",
+ "寰俊",
+ ];
+
+ // 娣诲姞绗簩琛屽苟璁剧疆鏍峰紡
+ secondRowHeaders.forEach((header, index) => {
+ // 娉ㄦ剰锛氬垪绱㈠紩浠�1寮�濮嬶紝瀵瑰簲A鍒楁槸1锛孊鍒楁槸2锛屼互姝ょ被鎺ㄣ��
+ const cell = worksheet.getCell(2, index + 1);
+ cell.value = header;
+ cell.style = headerStyle;
+ });
+
+ // 2. 鐒跺悗锛屽垱寤虹涓�琛岀殑涓绘爣棰樺崟鍏冩牸骞惰缃牱寮忥紝绱ф帴鐫�杩涜绾靛悜鍚堝苟
+ // 鍚堝苟 A1:A2 骞惰缃��
+ worksheet.mergeCells(1, 1, 2, 1); // 鍚堝苟 A1 鍒� A2
+ worksheet.getCell(1, 1).value = ""; // 璁剧疆涓诲崟鍏冩牸(A1)鐨勫��
+ worksheet.getCell(1, 1).style = headerStyle; // 璁剧疆涓诲崟鍏冩牸鏍峰紡
+
+ // 鍚堝苟 B1:B2 骞惰缃��
+ worksheet.mergeCells(1, 2, 2, 2); // 鍚堝苟 B1 鍒� B2
+ worksheet.getCell(1, 2).value = "鍑洪櫌鐥呭尯";
+ worksheet.getCell(1, 2).style = headerStyle;
+
+ // 鍚堝苟 C1:C2 骞惰缃��
+ worksheet.mergeCells(1, 3, 2, 3); // 鍚堝苟 C1 鍒� C2
+ worksheet.getCell(1, 3).value = "绉戝";
+ worksheet.getCell(1, 3).style = headerStyle;
+
+ // 鍚堝苟 D1:D2 骞惰缃��
+ worksheet.mergeCells(1, 4, 2, 4); // 鍚堝苟 D1 鍒� D2
+ worksheet.getCell(1, 4).value = "鍑洪櫌浜烘";
+ worksheet.getCell(1, 4).style = headerStyle;
+
+ // 鍚堝苟 E1:E2 骞惰缃��
+ worksheet.mergeCells(1, 5, 2, 5); // 鍚堝苟 E1 鍒� E2
+ worksheet.getCell(1, 5).value = "鏃犻渶闅忚浜烘";
+ worksheet.getCell(1, 5).style = headerStyle;
+
+ // 鍚堝苟 F1:F2 骞惰缃��
+ worksheet.mergeCells(1, 6, 2, 6); // 鍚堝苟 F1 鍒� F2
+ worksheet.getCell(1, 6).value = "搴旈殢璁夸汉娆�";
+ worksheet.getCell(1, 6).style = headerStyle;
+
+ // 3. 璁剧疆绗竴琛岀殑妯悜鍚堝苟鏍囬锛堣繖浜涗繚鎸佷笉鍙橈紝鍥犱负鍙秹鍙婄涓�琛岋級
+ // 棣栨鍑洪櫌闅忚锛堝悎骞禛1鍒癘1锛�
+ worksheet.mergeCells("G1:O1");
+ worksheet.getCell("G1").value = "棣栨鍑洪櫌闅忚";
+ worksheet.getCell("G1").style = headerStyle;
+
+ // 鍐嶆鍑洪櫌闅忚锛堝悎骞禤1鍒癢1锛�
+ worksheet.mergeCells("P1:W1");
+ worksheet.getCell("P1").value = "鍐嶆鍑洪櫌闅忚";
+ worksheet.getCell("P1").style = headerStyle;
+
+ // 4. 璁剧疆琛岄珮锛堝彲閫夛紝浣嗗缓璁缃級
+ worksheet.getRow(1).height = 28; // 绗竴琛岃楂�
+ worksheet.getRow(2).height = 25; // 绗簩琛岃楂�
+
+ // 娣诲姞鏁版嵁琛�
+ this.userList.forEach((item, rowIndex) => {
+ const dataRow = worksheet.addRow([
+ "", // 灞曞紑鍒�
+ item.leavehospitaldistrictname || "",
+ item.deptname || "",
+ item.dischargeCount || 0,
+ item.nonFollowUp || 0,
+ item.followUpNeeded || 0,
+ // 棣栨鍑洪櫌闅忚鏁版嵁
+ item.needFollowUp || 0,
+ item.pendingFollowUp || 0,
+ item.followUpSuccess || 0,
+ item.followUpFail || 0,
+ item.followUpRate || "0%",
+ item.rate ? (Number(item.rate) * 100).toFixed(2) + "%" : "0%",
+ item.manual || 0,
+ item.sms || 0,
+ item.weChat || 0,
+ // 鍐嶆鍑洪櫌闅忚鏁版嵁
+ item.needFollowUpAgain || 0,
+ item.pendingFollowUpAgain || 0,
+ item.followUpSuccessAgain || 0,
+ item.followUpFailAgain || 0,
+ item.followUpRateAgain || "0%",
+ item.manualAgain || 0,
+ item.smsAgain || 0,
+ item.weChatAgain || 0,
+ ]);
+
+ // 搴旂敤鏁版嵁琛屾牱寮�
+ dataRow.eachCell((cell) => {
+ cell.style = cellStyle;
+ });
+ dataRow.height = 24;
+ });
+
+ // 娣诲姞鍚堣琛�
+ const summaries = this.getSummaries({
+ columns: [
+ { property: "" },
+ { property: "leavehospitaldistrictname" },
+ { property: "deptname" },
+ { property: "dischargeCount" },
+ { property: "nonFollowUp" },
+ { property: "followUpNeeded" },
+ { property: "needFollowUp" },
+ { property: "pendingFollowUp" },
+ { property: "followUpSuccess" },
+ { property: "followUpFail" },
+ { property: "followUpRate" },
+ { property: "rate" },
+ { property: "manual" },
+ { property: "sms" },
+ { property: "weChat" },
+ { property: "needFollowUpAgain" },
+ { property: "pendingFollowUpAgain" },
+ { property: "followUpSuccessAgain" },
+ { property: "followUpFailAgain" },
+ { property: "followUpRateAgain" },
+ { property: "manualAgain" },
+ { property: "smsAgain" },
+ { property: "weChatAgain" },
+ ],
+ data: this.userList,
+ });
+
+ const summaryRow = worksheet.addRow(summaries);
+ summaryRow.eachCell((cell, colNumber) => {
+ cell.style = summaryStyle;
+ // 绗竴鍒楁樉绀�"鍚堣"
+ if (colNumber === 1) {
+ cell.value = "鍚堣";
+ }
+ });
+ summaryRow.height = 28;
+
+ // 璁剧疆鍒楀
+ worksheet.columns = [
+ { width: 8 }, // 灞曞紑鍒�
+ { width: 20 }, // 鍑洪櫌鐥呭尯
+ { width: 15 }, // 绉戝
+ { width: 12 }, // 鍑洪櫌浜烘
+ { width: 12 }, // 鏃犻渶闅忚浜烘
+ { width: 12 }, // 搴旈殢璁夸汉娆�
+ // 棣栨鍑洪櫌闅忚鍒�
+ { width: 10 },
+ { width: 10 },
+ { width: 10 },
+ { width: 10 },
+ { width: 12 },
+ { width: 12 },
+ { width: 8 },
+ { width: 8 },
+ { width: 8 },
+ // 鍐嶆鍑洪櫌闅忚鍒�
+ { width: 10 },
+ { width: 10 },
+ { width: 10 },
+ { width: 10 },
+ { width: 12 },
+ { width: 8 },
+ { width: 8 },
+ { width: 8 },
+ ];
+
+ // 鐢熸垚骞朵笅杞芥枃浠�
+ const buffer = await workbook.xlsx.writeBuffer();
+ const blob = new Blob([buffer], {
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ });
+ saveAs(blob, excelName);
+
+ this.$message.success("瀵煎嚭鎴愬姛");
+ return true;
+ } catch (error) {
+ console.error("瀵煎嚭澶辫触:", error);
+ this.$message.error(`瀵煎嚭澶辫触: ${error.message}`);
+ return false;
+ }
},
+
// 鏄剧ず鍥捐〃寮圭獥
showChartDialog() {
@@ -1931,9 +2213,21 @@
}
// 鐧惧垎姣斿瓧娈电壒娈婃牱寮�
-.your-table-container ::v-deep .el-table__footer .el-table__cell[data-field="followUpRate"] .cell,
-.your-table-container ::v-deep .el-table__footer .el-table__cell[data-field="rate"] .cell,
-.your-table-container ::v-deep .el-table__footer .el-table__cell[data-field="followUpRateAgain"] .cell {
+.your-table-container
+ ::v-deep
+ .el-table__footer
+ .el-table__cell[data-field="followUpRate"]
+ .cell,
+.your-table-container
+ ::v-deep
+ .el-table__footer
+ .el-table__cell[data-field="rate"]
+ .cell,
+.your-table-container
+ ::v-deep
+ .el-table__footer
+ .el-table__cell[data-field="followUpRateAgain"]
+ .cell {
color: #e6a23c !important;
font-weight: 700 !important;
}
--
Gitblit v1.9.3