From ba1ad6cff887cecb836a9fff87d84c146c820ad7 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期一, 26 一月 2026 11:00:18 +0800
Subject: [PATCH] 测试完成
---
src/views/sfstatistics/percentage/index.vue | 263 +++++++++++++++++++++++++++++-----------------------
1 files changed, 147 insertions(+), 116 deletions(-)
diff --git a/src/views/sfstatistics/percentage/index.vue b/src/views/sfstatistics/percentage/index.vue
index de63b4a..89b81a6 100644
--- a/src/views/sfstatistics/percentage/index.vue
+++ b/src/views/sfstatistics/percentage/index.vue
@@ -1700,40 +1700,68 @@
// 鏇挎崲鎮ㄥ師鏉ョ殑 exportTable 鏂规硶
async exportTable() {
try {
- // 鑾峰彇褰撳墠鏃ユ湡
- const now = new Date();
- // 鑾峰彇褰撳墠鏈堜唤锛堟敞鎰忔湀浠戒粠0寮�濮嬶紝闇�瑕佸姞1锛�
- const currentMonth = now.getMonth() + 1;
- // 鏋勫缓鏂囦欢鍚�
- const excelName = `${currentMonth}鏈堝嚭闄㈤殢璁跨粺璁¤〃.xlsx`;
+ // 1. 鑾峰彇骞舵牸寮忓寲鏃ユ湡鑼冨洿
+ let dateRangeString = ""; // 鐢ㄤ簬鏂囦欢鍚�
+ let sheetNameSuffix = ""; // 鐢ㄤ簬宸ヤ綔琛ㄥ悕
+
+ // 妫�鏌ユ槸鍚﹀瓨鍦ㄩ�変腑鐨勬棩鏈熻寖鍥�
+ if (
+ this.queryParams.dateRange &&
+ this.queryParams.dateRange.length === 2
+ ) {
+ const startDateStr = this.queryParams.dateRange[0]; // 寮�濮嬫棩鏈熷瓧绗︿覆锛屼緥濡� "2026-01-01 00:00:00"
+ const endDateStr = this.queryParams.dateRange[1]; // 缁撴潫鏃ユ湡瀛楃涓�
+
+ // 鏍煎紡鍖栨棩鏈熶负 YYYY-MM-DD锛堝幓鎺夋椂闂撮儴鍒嗭級
+ const formatDateForDisplay = (dateTimeStr) => {
+ return dateTimeStr.split(" ")[0]; // 鍙栫┖鏍煎墠鐨勯儴鍒嗭紝鍗� "YYYY-MM-DD"
+ };
+
+ 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}鏈坄;
+ }
+
+ // 2. 鍔ㄦ�佹瀯寤烘枃浠跺悕鍜屽伐浣滆〃鍚�
+ const excelName = `鍑洪櫌闅忚缁熻琛╛${dateRangeString}.xlsx`;
+ const worksheetName = `闅忚缁熻_${sheetNameSuffix}`; // 宸ヤ綔琛ㄥ悕涓嶈兘瓒呰繃31涓瓧绗2](@ref)
// 鍒涘缓鏂扮殑宸ヤ綔绨垮拰宸ヤ綔琛�
const workbook = new ExcelJS.Workbook();
- const worksheet = workbook.addWorksheet(`${currentMonth}鏈堝嚭闄㈤殢璁跨粺璁¤〃`);
-// 瀹氫箟鏍峰紡锛堟柊澧炴�绘爣棰樻牱寮忥級
- 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 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: {
@@ -1801,12 +1829,12 @@
right: { style: "thin", color: { argb: "FFD0D0D0" } },
},
};
-// 1. 娣诲姞鎬绘爣棰樿锛堢涓�琛岋級
- worksheet.mergeCells(1, 1, 1, 23); // 鍚堝苟A1鍒癢1鐨勬墍鏈夊垪[1,4](@ref)
- const titleCell = worksheet.getCell(1, 1);
- titleCell.value = `${currentMonth}鏈堝嚭闄㈤殢璁跨粺璁¤〃`; // 浣跨敤鏂囦欢鍚嶄綔涓烘�绘爣棰�
- titleCell.style = titleStyle;
- worksheet.getRow(1).height = 35; // 璁剧疆鎬绘爣棰樿楂�
+ // 1. 娣诲姞鎬绘爣棰樿锛堢涓�琛岋級
+ worksheet.mergeCells(1, 1, 1, 23); // 鍚堝苟A1鍒癢1鐨勬墍鏈夊垪[1,4](@ref)
+ const titleCell = worksheet.getCell(1, 1);
+ titleCell.value = `${sheetNameSuffix}鍑洪櫌闅忚缁熻琛╜; // 浣跨敤鏂囦欢鍚嶄綔涓烘�绘爣棰�
+ titleCell.style = titleStyle;
+ worksheet.getRow(1).height = 35; // 璁剧疆鎬绘爣棰樿楂�
// 1. 棣栧厛锛屽垱寤哄苟璁剧疆绗簩琛岋紙瀛愯〃澶达級鐨勬墍鏈夊崟鍏冩牸
const secondRowHeaders = [
"", // A2 灞曞紑鍒楀崰浣嶏紙鍏跺�煎皢鐢辩涓�琛屽悎骞跺悗鐨勪富鍗曞厓鏍煎喅瀹氾級
@@ -1837,95 +1865,98 @@
];
// 娣诲姞绗簩琛岋紙鍘熺涓�琛屼笅绉伙級
- secondRowHeaders.forEach((header, index) => {
- const cell = worksheet.getCell(3, index + 1); // 鏀逛负绗�3琛�
- cell.value = header;
- cell.style = headerStyle;
- });
+ secondRowHeaders.forEach((header, index) => {
+ const cell = worksheet.getCell(3, index + 1); // 鏀逛负绗�3琛�
+ cell.value = header;
+ cell.style = headerStyle;
+ });
- // 3. 璋冩暣鍘熷悎骞跺崟鍏冩牸浣嶇疆锛堝師绗�1琛屽悎骞跺崟鍏冩牸涓嬬Щ鍒扮2琛岋級
- // 鍚堝苟 A2:A3
- worksheet.mergeCells(2, 1, 3, 1);
- worksheet.getCell(2, 1).value = "";
- worksheet.getCell(2, 1).style = headerStyle;
+ // 3. 璋冩暣鍘熷悎骞跺崟鍏冩牸浣嶇疆锛堝師绗�1琛屽悎骞跺崟鍏冩牸涓嬬Щ鍒扮2琛岋級
+ // 鍚堝苟 A2:A3
+ worksheet.mergeCells(2, 1, 3, 1);
+ worksheet.getCell(2, 1).value = "";
+ worksheet.getCell(2, 1).style = headerStyle;
- // 鍚堝苟 B2:B3
- worksheet.mergeCells(2, 2, 3, 2);
- worksheet.getCell(2, 2).value = "鍑洪櫌鐥呭尯";
- worksheet.getCell(2, 2).style = headerStyle;
+ // 鍚堝苟 B2:B3
+ worksheet.mergeCells(2, 2, 3, 2);
+ worksheet.getCell(2, 2).value = "鍑洪櫌鐥呭尯";
+ worksheet.getCell(2, 2).style = headerStyle;
- // 鍚堝苟 C2:C3
- worksheet.mergeCells(2, 3, 3, 3);
- worksheet.getCell(2, 3).value = "绉戝";
- worksheet.getCell(2, 3).style = headerStyle;
+ // 鍚堝苟 C2:C3
+ worksheet.mergeCells(2, 3, 3, 3);
+ worksheet.getCell(2, 3).value = "绉戝";
+ worksheet.getCell(2, 3).style = headerStyle;
- // 鍚堝苟 D2:D3
- worksheet.mergeCells(2, 4, 3, 4);
- worksheet.getCell(2, 4).value = "鍑洪櫌浜烘";
- worksheet.getCell(2, 4).style = headerStyle;
+ // 鍚堝苟 D2:D3
+ worksheet.mergeCells(2, 4, 3, 4);
+ worksheet.getCell(2, 4).value = "鍑洪櫌浜烘";
+ worksheet.getCell(2, 4).style = headerStyle;
- // 鍚堝苟 E2:E3
- worksheet.mergeCells(2, 5, 3, 5);
- worksheet.getCell(2, 5).value = "鏃犻渶闅忚浜烘";
- worksheet.getCell(2, 5).style = headerStyle;
+ // 鍚堝苟 E2:E3
+ worksheet.mergeCells(2, 5, 3, 5);
+ worksheet.getCell(2, 5).value = "鏃犻渶闅忚浜烘";
+ worksheet.getCell(2, 5).style = headerStyle;
- // 鍚堝苟 F2:F3
- worksheet.mergeCells(2, 6, 3, 6);
- worksheet.getCell(2, 6).value = "搴旈殢璁夸汉娆�";
- worksheet.getCell(2, 6).style = headerStyle;
+ // 鍚堝苟 F2:F3
+ worksheet.mergeCells(2, 6, 3, 6);
+ worksheet.getCell(2, 6).value = "搴旈殢璁夸汉娆�";
+ worksheet.getCell(2, 6).style = headerStyle;
- // 4. 璋冩暣妯悜鍚堝苟鏍囬浣嶇疆锛堜笅绉诲埌绗�2琛岋級
- // 棣栨鍑洪櫌闅忚锛堝悎骞禛2:O2锛�
- worksheet.mergeCells(2, 7, 2, 15); // G2:O2
- worksheet.getCell(2, 7).value = "棣栨鍑洪櫌闅忚";
- worksheet.getCell(2, 7).style = headerStyle;
+ // 4. 璋冩暣妯悜鍚堝苟鏍囬浣嶇疆锛堜笅绉诲埌绗�2琛岋級
+ // 棣栨鍑洪櫌闅忚锛堝悎骞禛2:O2锛�
+ worksheet.mergeCells(2, 7, 2, 15); // G2:O2
+ worksheet.getCell(2, 7).value = "棣栨鍑洪櫌闅忚";
+ worksheet.getCell(2, 7).style = headerStyle;
- // 鍐嶆鍑洪櫌闅忚锛堝悎骞禤2:W2锛�
- worksheet.mergeCells(2, 16, 2, 23); // P2:W2
- worksheet.getCell(2, 16).value = "鍐嶆鍑洪櫌闅忚";
- worksheet.getCell(2, 16).style = headerStyle;
+ // 鍐嶆鍑洪櫌闅忚锛堝悎骞禤2:W2锛�
+ worksheet.mergeCells(2, 16, 2, 23); // P2:W2
+ worksheet.getCell(2, 16).value = "鍐嶆鍑洪櫌闅忚";
+ worksheet.getCell(2, 16).style = headerStyle;
- // 5. 璁剧疆琛岄珮
- worksheet.getRow(1).height = 35; // 鎬绘爣棰樿楂�
- worksheet.getRow(2).height = 28; // 鍘熺涓�琛屼笅绉�
- worksheet.getRow(3).height = 25; // 鍘熺浜岃涓嬬Щ
+ // 5. 璁剧疆琛岄珮
+ worksheet.getRow(1).height = 35; // 鎬绘爣棰樿楂�
+ worksheet.getRow(2).height = 28; // 鍘熺涓�琛屼笅绉�
+ worksheet.getRow(3).height = 25; // 鍘熺浜岃涓嬬Щ
- // 6. 娣诲姞鏁版嵁琛岋紙娉ㄦ剰琛岀储寮曢渶瑕�+1锛屽洜涓轰笂闈㈡彃鍏ヤ簡涓�琛岋級
- 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,
- ], rowIndex + 4); // 浠庣4琛屽紑濮嬫坊鍔犳暟鎹紙鍘熺3琛岋級
+ // 6. 娣诲姞鏁版嵁琛岋紙娉ㄦ剰琛岀储寮曢渶瑕�+1锛屽洜涓轰笂闈㈡彃鍏ヤ簡涓�琛岋級
+ 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,
+ ],
+ rowIndex + 4
+ ); // 浠庣4琛屽紑濮嬫坊鍔犳暟鎹紙鍘熺3琛岋級
- // 搴旂敤鏁版嵁琛屾牱寮�
- dataRow.eachCell((cell) => {
- cell.style = cellStyle;
- });
- dataRow.height = 24;
- });
+ // 搴旂敤鏁版嵁琛屾牱寮�
+ dataRow.eachCell((cell) => {
+ cell.style = cellStyle;
+ });
+ dataRow.height = 24;
+ });
// 娣诲姞鍚堣琛�
const summaries = this.getSummaries({
--
Gitblit v1.9.3