From fb34ba28cb908bd328cf6690ab0b19a56428f4e2 Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期五, 13 十一月 2026 10:56:55 +0800
Subject: [PATCH] 测试完成
---
src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue | 846 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 767 insertions(+), 79 deletions(-)
diff --git a/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue b/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
index 754e244..a5c3cf5 100644
--- a/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
+++ b/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
@@ -9,7 +9,11 @@
label-width="100px"
class="query-form"
>
- <el-form-item label="婊℃剰搴︾被鍨�" prop="satisfactionScope">
+ <el-form-item
+ v-if="isTongdeOrg"
+ label="婊℃剰搴︾被鍨�"
+ prop="satisfactionScope"
+ >
<el-select
v-model="satisfactionScope"
placeholder="榛樿鍦ㄩ櫌"
@@ -149,6 +153,8 @@
style="width: 100%"
@selection-change="handleSelectionChange"
:row-key="getRowKey"
+ show-summary
+ :summary-method="getSummaries"
>
<!-- 鐥呭尯缁熻锛氬湪闄㈢梾鍖� + 绂婚櫌鐥呭尯 -->
<el-table-column
@@ -389,6 +395,7 @@
} from "@/api/system/user";
import ExcelJS from "exceljs";
import { saveAs } from "file-saver";
+import { getTaskservelist } from "@/api/AiCentre/SingleTask";
import SeedetailsDialog from "./components/SeedetailsDialog.vue";
import TopicDialog from "./components/TopicDialog.vue";
@@ -398,11 +405,18 @@
SeedetailsDialog,
TopicDialog,
},
+ props: {
+ // 鏄惁鍦ㄩ《閮ㄧ敓鎴愭偅鑰呰〃鍗� / 闂璇︽儏鍒嗘瀽 tab锛堜粎婊℃剰搴︾粺璁′富椤靛紑鍚級
+ showAnalysisTabs: {
+ type: Boolean,
+ default: false,
+ },
+ },
data() {
return {
// 婊℃剰搴︾被鍨嬶細leave=绂婚櫌婊℃剰搴︼紙鎸夊嚭闄㈢梾鍖虹粺璁★級锛宧ospital=鍦ㄩ櫌婊℃剰搴︼紙鎸夊湪闄㈢梾鍖虹粺璁★級
- // 榛樿鍦ㄩ櫌婊℃剰搴�
- satisfactionScope: "hospital",
+ // 榛樿绂婚櫌婊℃剰搴�
+ satisfactionScope: "leave",
// 鏌ヨ鍙傛暟
queryParams: {
@@ -432,7 +446,7 @@
options: [
{
value: 6,
- label: "浣忛櫌婊℃剰搴�",
+ label: "鍑哄叆闄㈡弧鎰忓害",
raw: {
cssClass: "",
listClass: "",
@@ -458,6 +472,10 @@
// 鍔犺浇鐘舵��
loading: false,
orgname: "",
+ // 宸插畬鎴愭槑缁嗚姹傚簭鍙凤紝閬垮厤蹇�熷垏鎹㈢瓫閫夋椂鏃ц姹傝鐩栨柊缁撴灉
+ completedRequestSeq: 0,
+ // 闂璇︽儏璇锋眰搴忓彿
+ questionRequestSeq: 0,
// 閫変腑鐨勮
ids: [],
@@ -522,12 +540,21 @@
isInHospitalSatisfaction() {
return this.satisfactionScope !== "leave";
},
+ // patItem 鎺ュ彛鐨� serviceType 鍙帴鏀跺崟涓�硷紝澶氶�夋椂鍙栫涓�涓�
+ currentServiceType() {
+ const value = this.queryParams.serviceType;
+ const first = Array.isArray(value) ? value[0] : value;
+ return first || 6;
+ },
},
created() {
this.orgname = localStorage.getItem("orgname");
-
+ this.queryParams.serviceType = this.isTongdeOrg ? [6] : [2];
this.initData();
+ // 椤堕儴鎮h�呰〃鍗� / 闂璇︽儏鍒嗘瀽 tab锛氶粯璁ゆ寜褰撳墠缁熻鍙e緞鍔犺浇涓�娆�
+ this.maybeRefreshCompletedGroups();
+ this.maybeRefreshQuestionDetails();
},
methods: {
@@ -539,8 +566,12 @@
// 鑾峰彇绉戝鏍�
getDeptTree() {
- // 鑾峰彇鏈嶅姟绫诲瀷
- this.options = this.$store.getters.tasktypes || [];
+ // 鑾峰彇鏈嶅姟绫诲瀷锛堝瓧鍏搁噷鐨勩�屼綇闄㈡弧鎰忓害銆嶅湪鏈〉鏄剧ず涓恒�屽嚭鍏ラ櫌婊℃剰搴︺�嶏級
+ const labelFix = { 浣忛櫌婊℃剰搴�: "鍑哄叆闄㈡弧鎰忓害" };
+ this.options = (this.$store.getters.tasktypes || []).map((o) =>
+ labelFix[o.label] ? { ...o, label: labelFix[o.label] } : o
+ );
+ console.log(11, this.options);
// 鑾峰彇绉戝鍒楄〃
this.flatArraydept = (this.$store.getters.belongDepts || []).map(
@@ -592,41 +623,41 @@
// 鐥呭尯缁熻
let wardCodes = params.leavehospitaldistrictcodes || [];
if (wardCodes.includes("all")) {
- // 濡傛灉閫夋嫨浜�"鍏ㄩ儴"锛屽垯浣跨敤褰撳墠鐢ㄦ埛鎵�灞炵殑鍏ㄩ儴鐥呭尯
- wardCodes = (this.$store.getters.belongWards || []).map(
- (ward) => ward.districtCode
- );
+ // 閫夋嫨"鍏ㄩ儴"鏃朵笉鍔犵梾鍖洪檺鍒讹紝鏌ュ叏閮ㄧ梾鍖�
+ wardCodes = [];
}
delete params.leavehospitaldistrictcodes;
delete params.hospitaldistrictcodes;
delete params.deptcodes;
delete params.leaveldeptcodes;
delete params.hospitaldeptcodes;
- if (this.isInHospitalSatisfaction) {
- params.hospitaldistrictcodes = wardCodes;
- } else {
- params.leavehospitaldistrictcodes = wardCodes;
+ if (wardCodes.length) {
+ if (this.isInHospitalSatisfaction) {
+ params.hospitaldistrictcodes = wardCodes;
+ } else {
+ params.leavehospitaldistrictcodes = wardCodes;
+ }
}
} else if (params.statisticaltype == 2) {
// 绉戝缁熻
let deptCodes = params.deptcodes || [];
if (deptCodes.includes("all")) {
- // 濡傛灉閫夋嫨浜�"鍏ㄩ儴"锛屽垯绉婚櫎"all"鍊�
+ // 閫夋嫨"鍏ㄩ儴"鏃朵笉鍔犵瀹ら檺鍒讹紝鏌ュ叏閮ㄧ瀹�
+ deptCodes = [];
+ } else {
deptCodes = deptCodes.filter((item) => item !== "all");
- // 濡傛灉闇�瑕佷紶鎵�鏈夌瀹や唬鐮侊紝鍙互浠巗tore涓幏鍙�
- deptCodes = (this.$store.getters.belongDepts || []).map(
- (dept) => dept.deptCode
- );
}
delete params.deptcodes;
delete params.leaveldeptcodes;
delete params.hospitaldeptcodes;
delete params.leavehospitaldistrictcodes;
delete params.hospitaldistrictcodes;
- if (this.isInHospitalSatisfaction) {
- params.hospitaldeptcodes = deptCodes;
- } else {
- params.leaveldeptcodes = deptCodes;
+ if (deptCodes.length) {
+ if (this.isInHospitalSatisfaction) {
+ params.hospitaldeptcodes = deptCodes;
+ } else {
+ params.leaveldeptcodes = deptCodes;
+ }
}
}
@@ -645,7 +676,10 @@
}
},
sortChineseNumber(aRow, bRow) {
- return this.compareWardNames(this.getWardName(aRow), this.getWardName(bRow));
+ return this.compareWardNames(
+ this.getWardName(aRow),
+ this.getWardName(bRow)
+ );
},
sortHospitalWard(aRow, bRow) {
return this.compareWardNames(
@@ -840,23 +874,368 @@
}
this.queryParams.pageNum = 1;
this.getList();
+ this.maybeRefreshCompletedGroups();
+ this.maybeRefreshQuestionDetails();
},
// 澶勭悊鏌ヨ
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
+ this.maybeRefreshCompletedGroups();
+ this.maybeRefreshQuestionDetails();
},
// 鍒囨崲婊℃剰搴︾被鍨嬶紙绂婚櫌/鍦ㄩ櫌锛夊悗閲嶆柊鏌ヨ
handleSatisfactionScopeChange() {
this.queryParams.pageNum = 1;
this.getList();
+ this.maybeRefreshCompletedGroups();
+ this.maybeRefreshQuestionDetails();
},
- // 閲嶇疆鏌ヨ锛堟仮澶嶉粯璁わ細鍦ㄩ櫌婊℃剰搴� + 鏈嶅姟绫诲瀷 6锛�
+ /**
+ * 椤堕儴銆屽凡瀹屾垚鎮h�呮槑缁嗐�峵ab 鏁版嵁
+ * 缁村害娌跨敤涓嬫柟銆岀粺璁$被鍨嬨�嶏細鐥呭尯缁熻 -> 鎸夌梾鍖哄垎缁勶紱绉戝缁熻 -> 鎸夌瀹ゅ垎缁�
+ * 鏃堕棿娌跨敤涓嬫柟銆岄殢璁挎椂闂淬�嶏紝鐘舵�佸浐瀹氫负宸插畬鎴�
+ */
+ maybeRefreshCompletedGroups() {
+ if (this.showAnalysisTabs) {
+ this.refreshCompletedGroups();
+ }
+ },
+
+ async refreshCompletedGroups() {
+ const seq = ++this.completedRequestSeq;
+ const payload = this.buildCompletedPayload();
+
+ // 娌℃湁绉戝/鐥呭尯鏉冮檺鏃朵笉鍙戣捣璇锋眰锛岄伩鍏嶆妸鍏ㄩ噺鏁版嵁鏌ュ嚭鏉�
+ if (!payload) {
+ this.emitCompletedGroups([], seq);
+ return;
+ }
+
+ this.$emit("completed-rows-change", {
+ ...this.buildCompletedMeta(),
+ loading: true,
+ });
+
+ try {
+ const res = await getTaskservelist(payload);
+ if (seq !== this.completedRequestSeq) return;
+
+ const rows = this.pickCompletedRows(res);
+ this.emitCompletedGroups(rows, seq);
+ } catch (error) {
+ if (seq !== this.completedRequestSeq) return;
+ console.error("鑾峰彇宸插畬鎴愭偅鑰呮槑缁嗗け璐�:", error);
+ this.emitCompletedGroups([], seq);
+ }
+ },
+
+ // 缁勮绗竴寮犮�屾弧鎰忓害鐘舵�佹煡璇€�嶉〉鍚屾鏌ヨ鏉′欢
+ buildCompletedPayload() {
+ const scope = this.buildCompletedScope();
+ if (!scope.all && !scope.depts.length && !scope.wards.length) {
+ return null;
+ }
+
+ const payload = {
+ pageNum: null,
+ pageSize: null,
+ sendstate: null,
+ sendstateView: 2, // 2 = 宸插畬鎴�
+ sort: 2,
+ serviceType: this.currentServiceType,
+ searchscope: scope.searchscope,
+ visitCount: 1,
+ scopetype: [],
+ // 涓庣涓�寮犲浘涓�鑷达細閫変簡鍏蜂綋绉戝/鐥呭尯鏃跺彧浼犲搴旂淮搴︼紱銆屽叏閮ㄣ�嶆椂涓や釜缁村害閮戒紶
+ deptOrDistrict: scope.deptOrDistrict,
+ };
+
+ // 鍦ㄩ櫌婊℃剰搴︾敤 hospital*锛岀闄㈡弧鎰忓害鐢� leave*
+ if (this.satisfactionScope === "hospital") {
+ if (scope.depts.length) {
+ payload.deptcodes = scope.depts;
+ }
+ if (scope.wards.length) {
+ payload.hospitaldistrictcodes = scope.wards;
+ }
+ } else {
+ if (scope.depts.length) {
+ payload.leaveldeptcodes = scope.depts;
+ }
+ if (scope.wards.length) {
+ payload.leavehospitaldistrictcodes = scope.wards;
+ }
+ }
+
+ const range = this.queryParams.dateRange || [];
+ if (range.length === 2 && range[0] && range[1]) {
+ payload.finishtimeStart = range[0];
+ payload.finishtimeEnd = range[1];
+ }
+
+ return payload;
+ },
+
+ // 缁勮鏌ヨ鑼冨洿锛氱粺璁$被鍨嬪喅瀹氭寜鐥呭尯杩樻槸绉戝杩囨护
+ buildCompletedScope() {
+ const allDepts = (this.$store.getters.belongDepts || [])
+ .map((dept) => dept.deptCode)
+ .filter(Boolean);
+ const allWards = (this.$store.getters.belongWards || [])
+ .map((ward) => ward.districtCode)
+ .filter(Boolean);
+
+ // 鐥呭尯缁熻锛堝惈缁熻绫诲瀷涓虹┖鐨勬儏鍐碉級
+ if (this.queryParams.statisticaltype != 2) {
+ const rawSelected = this.queryParams.leavehospitaldistrictcodes || [];
+ const selected = rawSelected.filter((code) => code && code !== "all");
+ const useAll = !rawSelected.length || rawSelected.includes("all");
+
+ if (!useAll && selected.length) {
+ return {
+ depts: [],
+ wards: selected,
+ deptOrDistrict: 1,
+ searchscope: 2,
+ };
+ }
+ // 鍏ㄩ儴锛氫笉浼犵梾鍖�/绉戝缂栫爜锛岀敱鍚庣杩斿洖褰撳墠鏈烘瀯鍏ㄩ儴鏁版嵁
+ return {
+ depts: [],
+ wards: [],
+ deptOrDistrict: 2,
+ searchscope: 3,
+ all: true,
+ };
+ }
+
+ // 绉戝缁熻
+ const rawSelected = this.queryParams.deptcodes || [];
+ const selected = rawSelected.filter((code) => code && code !== "all");
+ const useAll = !rawSelected.length || rawSelected.includes("all");
+ if (!useAll && selected.length) {
+ return {
+ depts: selected,
+ wards: [],
+ deptOrDistrict: 1,
+ searchscope: 1,
+ };
+ }
+ return {
+ depts: [],
+ wards: [],
+ deptOrDistrict: 2,
+ searchscope: 3,
+ all: true,
+ };
+ },
+
+ // 闂璇︽儏鍗犳瘮 / 鍥捐〃 / 楗煎浘 鍏辩敤鏁版嵁
+ maybeRefreshQuestionDetails() {
+ if (this.showAnalysisTabs) {
+ this.refreshQuestionDetails();
+ }
+ },
+
+ async refreshQuestionDetails() {
+ const seq = ++this.questionRequestSeq;
+ const payload = this.buildQuestionPayload();
+
+ if (!payload) {
+ this.$emit("question-details-change", { loading: false, list: [] });
+ return;
+ }
+
+ this.$emit("question-details-change", { loading: true });
+
+ try {
+ const res = await getSfStatisticsJoyInfo(payload);
+ if (seq !== this.questionRequestSeq) return;
+
+ this.$emit("question-details-change", {
+ loading: false,
+ list: res.data || [],
+ });
+ } catch (error) {
+ if (seq !== this.questionRequestSeq) return;
+ console.error("鑾峰彇闂璇︽儏鍗犳瘮澶辫触:", error);
+ this.$emit("question-details-change", { loading: false, list: [] });
+ }
+ },
+
+ buildQuestionPayload() {
+ const scope = this.buildCompletedScope();
+ if (!scope.all && !scope.depts.length && !scope.wards.length) {
+ return null;
+ }
+
+ const params = {
+ configKey: "joyCount",
+ statisticaltype: this.queryParams.statisticaltype,
+ serviceType: this.queryParams.serviceType,
+ searchscope: scope.searchscope,
+ pageNum: 1,
+ pageSize: 999,
+ };
+
+ const range = this.queryParams.dateRange || [];
+ if (range.length === 2 && range[0] && range[1]) {
+ params.startTime = range[0];
+ params.endTime = range[1];
+ }
+
+ if (this.queryParams.statisticaltype == 2) {
+ if (scope.depts.length) {
+ if (this.isInHospitalSatisfaction) {
+ params.hospitaldeptcodes = scope.depts;
+ } else {
+ params.leaveldeptcodes = scope.depts;
+ }
+ }
+ } else if (scope.wards.length) {
+ if (this.isInHospitalSatisfaction) {
+ params.hospitaldistrictcodes = scope.wards;
+ } else {
+ params.leavehospitaldistrictcodes = scope.wards;
+ }
+ }
+
+ return params;
+ },
+
+ // 鍏煎鎺ュ彛涓嶅悓鐨勮繑鍥炲眰绾�
+ pickCompletedRows(res) {
+ if (!res) return [];
+ const rowsWrap = res.rows || (res.data && res.data.rows);
+ let list = [];
+
+ if (Array.isArray(rowsWrap) && rowsWrap[0]) {
+ list =
+ rowsWrap[0].serviceSubtaskList ||
+ (rowsWrap[0].sendname ? rowsWrap : []);
+ } else if (res.data && Array.isArray(res.data.serviceSubtaskList)) {
+ list = res.data.serviceSubtaskList;
+ } else if (Array.isArray(res.data)) {
+ list = res.data;
+ }
+
+ return (list || [])
+ .filter(Boolean)
+ .map((row) => this.normalizeCompletedRow(row));
+ },
+
+ normalizeCompletedRow(row) {
+ const item = { ...row };
+ if (item.endtime) {
+ item.endDay = this.daysBetween(item.endtime);
+ }
+ return item;
+ },
+
+ emitCompletedGroups(rows, seq) {
+ if (seq !== this.completedRequestSeq) return;
+ this.$emit("completed-rows-change", {
+ ...this.buildCompletedMeta(),
+ loading: false,
+ total: rows.length,
+ rows,
+ });
+ },
+
+ buildCompletedMeta() {
+ return {
+ dimension: this.queryParams.statisticaltype == 2 ? "dept" : "ward",
+ scope: this.satisfactionScope,
+ dateRange: [...(this.queryParams.dateRange || [])],
+ };
+ },
+
+ // 鎸夊綋鍓嶇粺璁$被鍨嬪垎缁勶細鐥呭尯缁熻 -> 鐥呭尯锛岀瀹ょ粺璁� -> 绉戝
+ groupCompletedRows(rows) {
+ const dimension = this.queryParams.statisticaltype == 2 ? "dept" : "ward";
+ const groupMap = new Map();
+
+ (rows || []).forEach((row) => {
+ const name =
+ dimension === "ward" ? this.wardNameOf(row) : this.deptNameOf(row);
+ const code =
+ dimension === "ward" ? this.wardCodeOf(row) : this.deptCodeOf(row);
+
+ const key = String(code || name || "unknown");
+ if (!groupMap.has(key)) {
+ groupMap.set(key, {
+ key,
+ label: name || (dimension === "ward" ? "鏈垎鐥呭尯" : "鏈垎绉戝"),
+ rows: [],
+ });
+ }
+ groupMap.get(key).rows.push(row);
+ });
+
+ const orderMap = this.buildGroupOrder(dimension);
+ return Array.from(groupMap.values()).sort((a, b) => {
+ const aIndex = orderMap.has(a.key) ? orderMap.get(a.key) : 99999;
+ const bIndex = orderMap.has(b.key) ? orderMap.get(b.key) : 99999;
+ if (aIndex !== bIndex) return aIndex - bIndex;
+ return a.label.localeCompare(b.label, "zh-Hans-CN");
+ });
+ },
+
+ // tab 椤哄簭鎸夐〉闈㈠乏渚х瀹�/鐥呭尯鏉冮檺鍒楄〃鐨勯『搴忥紝淇濊瘉銆屼竴鐥呭尯銆佷簩鐥呭尯鈥︺�嶇殑鑷劧椤哄簭
+ buildGroupOrder(dimension) {
+ const list =
+ dimension === "ward"
+ ? this.$store.getters.belongWards
+ : this.$store.getters.belongDepts;
+ const orderMap = new Map();
+
+ (list || []).forEach((item, index) => {
+ const code = dimension === "ward" ? item.districtCode : item.deptCode;
+ if (code) orderMap.set(String(code), index);
+ });
+
+ return orderMap;
+ },
+
+ wardNameOf(row) {
+ if (!row) return "";
+ const name =
+ this.satisfactionScope === "hospital"
+ ? row.hospitaldistrictname || row.leavehospitaldistrictname
+ : row.leavehospitaldistrictname || row.hospitaldistrictname;
+ return name === "-" ? "" : name;
+ },
+
+ wardCodeOf(row) {
+ if (!row) return "";
+ return this.satisfactionScope === "hospital"
+ ? row.hospitaldistrictcode || row.leavehospitaldistrictcode
+ : row.leavehospitaldistrictcode || row.hospitaldistrictcode;
+ },
+
+ deptNameOf(row) {
+ if (!row) return "";
+ const name =
+ this.satisfactionScope === "hospital"
+ ? row.deptname || row.leaveldeptname
+ : row.leaveldeptname || row.deptname;
+ return name === "-" ? "" : name;
+ },
+
+ deptCodeOf(row) {
+ if (!row) return "";
+ return this.satisfactionScope === "hospital"
+ ? row.hospitaldeptcode || row.deptcode
+ : row.deptcode || row.hospitaldeptcode;
+ },
+
+ // 閲嶇疆鏌ヨ锛堟仮澶嶉粯璁わ細绂婚櫌婊℃剰搴� + 鏈嶅姟绫诲瀷 6锛�
resetQuery() {
- this.satisfactionScope = "hospital";
+ this.satisfactionScope = "leave";
this.queryParams = {
statisticaltype: 1,
leavehospitaldistrictcodes: [],
@@ -867,6 +1246,8 @@
pageSize: 20,
};
this.getList();
+ this.maybeRefreshCompletedGroups();
+ this.maybeRefreshQuestionDetails();
},
// 澶勭悊鍒嗛〉澶у皬鍙樺寲
@@ -910,6 +1291,92 @@
const num = parseFloat(value);
if (isNaN(num)) return "-";
return `${(num * 100).toFixed(2)}%`;
+ },
+
+ // 琛ㄦ牸鍚堣琛�
+ getSummaries(param) {
+ const { columns, data } = param;
+ const sums = [];
+
+ columns.forEach((column, index) => {
+ if (index === 0) {
+ sums[index] = "鍚堣";
+ return;
+ }
+
+ const prop = column.property;
+
+ // 鏁板�煎垪姹傚拰
+ if (
+ [
+ "dischargeCount",
+ "nonFollowUp",
+ "followUpNeeded",
+ "joyAllCount",
+ "joyCount",
+ ].includes(prop)
+ ) {
+ sums[index] = data.reduce(
+ (sum, item) => sum + (Number(item[prop]) || 0),
+ 0
+ );
+ return;
+ }
+
+ // 瀹屾垚姣旂巼锛氭弧鎰忓害濉姤閲� / 婊℃剰搴﹂鐩�婚噺
+ if (prop === "joyTotal") {
+ const totalJoyAllCount = data.reduce(
+ (sum, item) => sum + (Number(item.joyAllCount) || 0),
+ 0
+ );
+ const totalJoyCount = data.reduce(
+ (sum, item) => sum + (Number(item.joyCount) || 0),
+ 0
+ );
+ sums[index] =
+ totalJoyAllCount > 0
+ ? ((totalJoyCount / totalJoyAllCount) * 100).toFixed(2) + "%"
+ : "0.00%";
+ return;
+ }
+
+ // 鐧惧垎姣斿垪锛堥殢璁跨巼/鍙婃椂鐜囷級锛氬彇骞冲潎鍊硷紙0 鍊间篃鍙備笌骞冲潎锛�
+ if (prop === "followUpRate" || prop === "rate") {
+ const percentageValues = data
+ .map((item) => {
+ const value = item[prop];
+ if (
+ value === null ||
+ value === undefined ||
+ value === "" ||
+ value === "-"
+ ) {
+ return null;
+ }
+ if (typeof value === "string" && value.includes("%")) {
+ const num = parseFloat(value.replace("%", "")) / 100;
+ return isNaN(num) ? null : num;
+ }
+ const num = parseFloat(value);
+ return isNaN(num) ? null : num;
+ })
+ .filter((value) => value !== null);
+
+ sums[index] =
+ percentageValues.length > 0
+ ? (
+ (percentageValues.reduce((sum, value) => sum + value, 0) /
+ percentageValues.length) *
+ 100
+ ).toFixed(2) + "%"
+ : "0.00%";
+ return;
+ }
+
+ sums[index] = "";
+ });
+
+ return sums;
},
// 鏌ョ湅鏈強鏃堕殢璁胯鎯�
@@ -974,6 +1441,113 @@
console.error("鑾峰彇婊℃剰搴﹁鎯呭け璐�:", error);
this.$message.error("鑾峰彇璇︽儏澶辫触");
}
+ },
+
+ // 鑾峰彇鎸囧畾鐥呭尯/绉戝鐨勯鐩鎯�
+ async fetchTopicDetail(row) {
+ const params = {
+ configKey: "joyCount",
+ ...this.queryParams,
+ };
+ // 瀵煎嚭闇�瑕佽鐥呭尯/绉戝鐨勫叏閮ㄩ鐩紝瑕嗙洊涓昏〃鍒嗛〉鍙傛暟
+ params.pageNum = 1;
+ params.pageSize = 1000;
+ if (
+ this.queryParams.dateRange &&
+ this.queryParams.dateRange.length === 2
+ ) {
+ params.startTime = this.queryParams.dateRange[0];
+ params.endTime = this.queryParams.dateRange[1];
+ }
+ if (this.queryParams.statisticaltype == 1) {
+ params.leavehospitaldistrictcodes = [row.leavehospitaldistrictcode];
+ } else {
+ params.deptcodes = [row.deptcode];
+ }
+ const response = await getSfStatisticsJoyInfo(params);
+ return response.data || {};
+ },
+
+ // 涓昏〃瀵煎嚭琛屾暟鎹�
+ getMainExportRow(item) {
+ return [
+ this.queryParams.statisticaltype == 1
+ ? item.leavehospitaldistrictname
+ : item.deptname,
+ item.dischargeCount || 0,
+ item.nonFollowUp || 0,
+ item.followUpNeeded || 0,
+ item.followUpRate || "0%",
+ item.rate ? this.formatPercent(item.rate) : "0%",
+ item.joyAllCount || 0,
+ item.joyCount || 0,
+ item.joyTotal ? this.formatPercent(item.joyTotal) : "0%",
+ ];
+ },
+
+ // 璁$畻鏂囨湰鏄剧ず瀹藉害锛堜腑鏂囨寜 2銆佽嫳鏂�/鏁板瓧鎸� 1锛�
+ textWidth(str) {
+ if (!str) return 0;
+ let width = 0;
+ for (const ch of String(str)) {
+ width += ch.charCodeAt(0) > 255 ? 2 : 1;
+ }
+ return width;
+ },
+
+ // 涓芥按甯備腑鍖婚櫌锛氭媺鍙栨墍鏈夌瀹ら鐩槑缁嗭紝鎵佸钩鍖栦负銆岄鐩�夐」銆嶅垪缁撴瀯
+ async buildLishuiTopicColumns() {
+ const topicMap = new Map();
+ const rowQuantities = [];
+
+ for (const item of this.userList) {
+ const topiclist = await this.fetchTopicDetail(item);
+ const qMap = new Map();
+
+ if (topiclist && Object.keys(topiclist).length) {
+ Object.keys(topiclist).forEach((key) => {
+ const topic = topiclist[key];
+ if (!topic || !topic.scriptContent) return;
+
+ const tKey =
+ topic.scriptid != null && topic.scriptid !== ""
+ ? String(topic.scriptid)
+ : topic.scriptContent;
+
+ if (!topicMap.has(tKey)) {
+ topicMap.set(tKey, {
+ key: tKey,
+ scriptContent: topic.scriptContent,
+ options: [],
+ optionSet: new Set(),
+ });
+ }
+
+ const t = topicMap.get(tKey);
+ const topicQ = new Map();
+ (topic.details || []).forEach((detail) => {
+ if (!detail || !detail.optionText) return;
+ if (!t.optionSet.has(detail.optionText)) {
+ t.optionSet.add(detail.optionText);
+ t.options.push(detail.optionText);
+ }
+ topicQ.set(detail.optionText, Number(detail.chosenQuantity) || 0);
+ });
+ qMap.set(tKey, topicQ);
+ });
+ }
+
+ rowQuantities.push(qMap);
+ }
+
+ const topics = Array.from(topicMap.values());
+ // 娌℃湁閫夐」鐨勯鐩粯璁ゅ~鍏呬竴涓┖閫夐」鍒楋紝閬垮厤琛ㄥご/鏁版嵁閿欎綅
+ topics.forEach((t) => {
+ if (!t.options.length) {
+ t.options = [""];
+ }
+ });
+ return { topics, rowQuantities };
},
// 瀵煎嚭鏁版嵁
@@ -1067,7 +1641,11 @@
pattern: "solid",
fgColor: { argb: "FFF5F7FA" },
},
- alignment: { vertical: "middle", horizontal: "center" },
+ alignment: {
+ vertical: "middle",
+ horizontal: "center",
+ wrapText: true,
+ },
border: {
top: { style: "thin", color: { argb: "FFD0D0D0" } },
left: { style: "thin", color: { argb: "FFD0D0D0" } },
@@ -1087,18 +1665,18 @@
},
};
- // 娣诲姞鎬绘爣棰橈紙涓ゅ垪缁村害 + 鍏釜鎸囨爣鍒楋紝鍏� 10 鍒楋級
- worksheet.mergeCells(1, 1, 1, 10);
- const titleCell = worksheet.getCell(1, 1);
- titleCell.value = `婊℃剰搴﹂殢璁跨粺璁¤〃锛�${sheetNameSuffix}锛塦;
- titleCell.style = titleStyle;
- worksheet.getRow(1).height = 35;
+ // 涓芥按甯備腑鍖婚櫌锛氶鍏堟媺鍙栭鐩槑缁嗭紝鎵佸钩鍖栦负銆岄鐩�夐」銆嶅垪
+ let lishuiTopics = [];
+ let lishuiRowQuantities = [];
+ if (isLishuiHospital) {
+ const built = await this.buildLishuiTopicColumns();
+ lishuiTopics = built.topics;
+ lishuiRowQuantities = built.rowQuantities;
+ }
- // 娣诲姞琛ㄥご锛堢瀹ょ粺璁″鍑哄湪闄㈢瀹�+绂婚櫌绉戝锛岀梾鍖虹粺璁″鍑哄湪闄㈢梾鍖�+绂婚櫌鐥呭尯锛�
- const isWardStatistics = this.queryParams.statisticaltype == 1;
- const headers = [
- isWardStatistics ? "鍦ㄩ櫌鐥呭尯" : "鍦ㄩ櫌绉戝",
- isWardStatistics ? "绂婚櫌鐥呭尯" : "绂婚櫌绉戝",
+ // 涓昏〃鍒�
+ const mainHeaders = [
+ this.queryParams.statisticaltype == 1 ? "鍑洪櫌鐥呭尯" : "绉戝",
"鍑洪櫌浜烘",
"鏃犻渶闅忚浜烘",
"搴旈殢璁夸汉娆�",
@@ -1108,51 +1686,161 @@
"婊℃剰搴﹀~鎶ラ噺",
"瀹屾垚姣旂巼",
];
+ const mainColumnCount = mainHeaders.length;
- const headerRow = worksheet.addRow(headers);
- headerRow.eachCell((cell) => {
- cell.style = headerStyle;
- });
- headerRow.height = 25;
+ // 鎬诲垪鏁帮紙涓芥按甯備腑鍖婚櫌鍦ㄦ湯灏捐拷鍔犻鐩�夐」鍒楋級
+ const topicColumnCount = lishuiTopics.reduce(
+ (sum, t) => sum + (t.options.length || 1),
+ 0
+ );
+ const totalColumns = mainColumnCount + topicColumnCount;
- // 娣诲姞鏁版嵁琛�
- this.userList.forEach((item) => {
- const dataRow = worksheet.addRow([
- isWardStatistics
- ? item.hospitaldistrictname || "-"
- : item.hospitaldeptname || "-",
- isWardStatistics
- ? item.leavehospitaldistrictname || "-"
- : item.deptname || "-",
- item.dischargeCount || 0,
- item.nonFollowUp || 0,
- item.followUpNeeded || 0,
- item.followUpRate || "0%",
- item.rate ? this.formatPercent(item.rate) : "0%",
- item.joyAllCount || 0,
- item.joyCount || 0,
- item.joyTotal ? this.formatPercent(item.joyTotal) : "0%",
- ]);
+ // 娣诲姞鎬绘爣棰�
+ worksheet.mergeCells(1, 1, 1, totalColumns);
+ const titleCell = worksheet.getCell(1, 1);
+ titleCell.value = `婊℃剰搴﹂殢璁跨粺璁¤〃锛�${sheetNameSuffix}锛塦;
+ titleCell.style = titleStyle;
+ worksheet.getRow(1).height = 35;
- dataRow.eachCell((cell) => {
- cell.style = cellStyle;
+ if (isLishuiHospital && lishuiTopics.length) {
+ // 璁$畻姣忎釜棰樼洰鐨勯�夐」鍒楀锛堥�夐」鏂囧瓧鑷�傚簲锛岄骞茶繃闀挎椂鎽婂鍒椼�佸繀瑕佹椂鎹㈣锛�
+ const topicColumns = lishuiTopics.map((topic) => {
+ const n = topic.options.length || 1;
+ const baseWidths = topic.options.map((opt) =>
+ opt === "" ? 10 : Math.max(10, this.textWidth(opt) + 4)
+ );
+ const sumWidth = baseWidths.reduce((s, w) => s + w, 0);
+ const topicWidth = this.textWidth(topic.scriptContent) + 4;
+ const groupWidth = Math.max(sumWidth, topicWidth);
+ const extra = (groupWidth - sumWidth) / n;
+ const widths = baseWidths.map((w) => w + extra);
+ const lines = Math.max(1, Math.ceil(topicWidth / groupWidth));
+ return { widths, lines };
});
- dataRow.height = 22;
- });
+ const maxHeaderLines = topicColumns.reduce(
+ (m, t) => Math.max(m, t.lines),
+ 1
+ );
- // 璁剧疆鍒楀
- worksheet.columns = [
- { width: 20 },
- { width: 20 },
- { width: 12 },
- { width: 12 },
- { width: 12 },
- { width: 12 },
- { width: 12 },
- { width: 15 },
- { width: 15 },
- { width: 12 },
- ];
+ // 涓よ琛ㄥご锛氱涓�琛� = 涓昏〃鍒� + 棰樼洰鍚嶏紱绗簩琛� = 閫夐」鍚�
+ const headerRow1 = worksheet.addRow([]);
+ const headerRow2 = worksheet.addRow([]);
+
+ mainHeaders.forEach((h, i) => {
+ const col = i + 1;
+ headerRow1.getCell(col).value = h;
+ headerRow1.getCell(col).style = headerStyle;
+ headerRow2.getCell(col).style = headerStyle;
+ worksheet.mergeCells(
+ headerRow1.number,
+ col,
+ headerRow2.number,
+ col
+ );
+ });
+
+ let colIndex = mainColumnCount + 1;
+ lishuiTopics.forEach((topic) => {
+ const optCount = topic.options.length || 1;
+ for (let k = 0; k < optCount; k++) {
+ headerRow1.getCell(colIndex + k).style = headerStyle;
+ }
+ headerRow1.getCell(colIndex).value = topic.scriptContent;
+ if (optCount > 1) {
+ worksheet.mergeCells(
+ headerRow1.number,
+ colIndex,
+ headerRow1.number,
+ colIndex + optCount - 1
+ );
+ }
+ topic.options.forEach((opt, k) => {
+ headerRow2.getCell(colIndex + k).value = opt;
+ headerRow2.getCell(colIndex + k).style = headerStyle;
+ });
+ colIndex += optCount;
+ });
+
+ // 琛ㄥご楂樺害锛氶骞叉崲琛屾椂鎸夋渶闀块鐩鐣�
+ headerRow1.height = Math.max(30, 15 * maxHeaderLines + 8);
+ headerRow2.height = 25;
+
+ // 鏁版嵁琛�
+ this.userList.forEach((item, idx) => {
+ const row = worksheet.addRow([]);
+ const main = this.getMainExportRow(item);
+ main.forEach((v, i) => {
+ const cell = row.getCell(i + 1);
+ cell.value = v;
+ cell.style = cellStyle;
+ });
+
+ const qMap = lishuiRowQuantities[idx] || new Map();
+ let cIndex = mainColumnCount + 1;
+ for (const topic of lishuiTopics) {
+ const topicQ = qMap.get(topic.key);
+ topic.options.forEach((opt) => {
+ const cell = row.getCell(cIndex);
+ if (opt === "") {
+ // 绌洪�夐」鍗犱綅鍒椾笉濉暟瀛�
+ cell.value = "";
+ } else {
+ const val = topicQ ? topicQ.get(opt) : undefined;
+ cell.value = val === undefined || val === null ? 0 : val;
+ }
+ cell.style = cellStyle;
+ cIndex++;
+ });
+ }
+ row.height = 22;
+ });
+
+ // 鍒楀锛氫富琛ㄥ垪 + 棰樼洰閫夐」鍒�
+ const columns = [
+ { width: 20 },
+ { width: 12 },
+ { width: 12 },
+ { width: 12 },
+ { width: 12 },
+ { width: 12 },
+ { width: 15 },
+ { width: 15 },
+ { width: 12 },
+ ];
+ lishuiTopics.forEach((topic, ti) => {
+ topicColumns[ti].widths.forEach((w) => {
+ columns.push({ width: w });
+ });
+ });
+ worksheet.columns = columns;
+ } else {
+ // 鍏朵粬鍖婚櫌锛氬崟琛岃〃澶�
+ const headerRow = worksheet.addRow(mainHeaders);
+ headerRow.eachCell((cell) => {
+ cell.style = headerStyle;
+ });
+ headerRow.height = 25;
+
+ this.userList.forEach((item) => {
+ const dataRow = worksheet.addRow(this.getMainExportRow(item));
+ dataRow.eachCell((cell) => {
+ cell.style = cellStyle;
+ });
+ dataRow.height = 22;
+ });
+
+ worksheet.columns = [
+ { width: 20 },
+ { width: 12 },
+ { width: 12 },
+ { width: 12 },
+ { width: 12 },
+ { width: 12 },
+ { width: 15 },
+ { width: 15 },
+ { width: 12 },
+ ];
+ }
// 鐢熸垚骞朵笅杞芥枃浠�
const buffer = await workbook.xlsx.writeBuffer();
--
Gitblit v1.9.3