From bbbc478129f72b26e2ec4a2e981ed8698a96880c Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 22 十月 2026 00:28:18 +0800
Subject: [PATCH] 当service_type=6时,需要根据传入的入院还是离院病区(病区)去后端查询
---
src/views/Satisfaction/sfstatistics/components/DataOverview.vue | 86 +++++++++++++++++++++++++++++++++++++------
1 files changed, 74 insertions(+), 12 deletions(-)
diff --git a/src/views/Satisfaction/sfstatistics/components/DataOverview.vue b/src/views/Satisfaction/sfstatistics/components/DataOverview.vue
index 2cfa325..f189c1f 100644
--- a/src/views/Satisfaction/sfstatistics/components/DataOverview.vue
+++ b/src/views/Satisfaction/sfstatistics/components/DataOverview.vue
@@ -3,6 +3,19 @@
<!-- 椤堕儴绛涢�夛細鏃堕棿鑼冨洿 + 绉戝/鐥呭尯锛屾帶鍒舵湰椤垫墍鏈夋暟鎹� -->
<el-card shadow="never" class="overview-card filter-card">
<el-form inline class="filter-form">
+ <el-form-item label="婊℃剰搴︾被鍨�">
+ <el-select
+ v-model="satisfactionScope"
+ size="small"
+ style="width: 140px"
+ clearable
+ placeholder="榛樿绂婚櫌"
+ @change="fetchData"
+ >
+ <el-option label="绂婚櫌婊℃剰搴�" value="leave" />
+ <el-option label="鍦ㄩ櫌婊℃剰搴�" value="hospital" />
+ </el-select>
+ </el-form-item>
<el-form-item label="鍑洪櫌鏃ユ湡">
<el-date-picker
v-model="queryParams.dateRange"
@@ -445,8 +458,13 @@
const details = pickDetails(item);
let node = map.get(title);
if (!node) {
- node = { title, type: "", options: new Map() };
+ node = { title, type: "", options: new Map(), avgScore: null };
map.set(title, node);
+ }
+ // 缁煎悎寰楀垎锛氬悗绔繑鍥炵殑棰樼洰绾� avgScore锛堜笌棰樼洰鍚岀骇锛�
+ if (node.avgScore == null) {
+ const rawAvg = Number(item && item.avgScore);
+ node.avgScore = isNaN(rawAvg) ? null : rawAvg;
}
details.forEach((d) => {
@@ -480,7 +498,7 @@
return Array.from(map.values()).map((n) => {
const options = Array.from(n.options.values());
- const item = { title: n.title, type: n.type, options };
+ const item = { title: n.title, type: n.type, options, avgScore: n.avgScore };
// 澶氶�夐锛氱敤鍚勯�夐」鏁伴噺涔嬪拰浣滀负濉姤鎬婚噺锛堟帴鍙f湭鍗曠嫭鎻愪緵浜烘锛�
if (n.type === "multiple")
item.total = options.reduce((s, o) => s + o.count, 0);
@@ -492,11 +510,14 @@
name: "DataOverview",
data() {
return {
+ // 婊℃剰搴︾被鍨嬶細leave=绂婚櫌婊℃剰搴︼紙绂婚櫌绉戝/鐥呭尯锛夛紝hospital=鍦ㄩ櫌婊℃剰搴︼紙鍦ㄩ櫌绉戝/鐥呭尯锛�
+ satisfactionScope: "leave",
// 椤堕儴鍏ㄥ眬绛涢��
queryParams: {
dateRange: [],
deptCodes: [], // 绉戝缂栫爜闆嗗悎 => leaveldeptcodes
- wardCodes: [], // 鍑洪櫌鐥呭尯缂栫爜闆嗗悎 => leavehospitaldistrictcodes锛堟帴鍙e繀濉級
+ // 鐥呭尯缂栫爜闆嗗悎锛氫綇闄㈡弧鎰忓害鎸夊湪闄㈢梾鍖�(hospitaldistrictcodes)锛屽叾浣欐寜鍑洪櫌鐥呭尯(leavehospitaldistrictcodes)
+ wardCodes: [],
serviceTypeList: [], // 鏈嶅姟绫诲瀷澶氶�夛紝鎻愪氦鏃剁敤閫楀彿鎷兼帴
deptOrDistrict: "1", // 绉戝/鐥呭尯缁勫悎鏂瑰紡锛岄粯璁� 1锛氱闄㈢梾鍖� and 绂婚櫌绉戝
statMode: "ward", // 缁熻缁村害锛歸ard=鎸夌梾鍖虹粺璁� dept=鎸夌瀹ょ粺璁�
@@ -549,6 +570,11 @@
defaultWardCodes() {
return Array.from(new Set(this.wardOptions.map((w) => w.value)));
},
+ // 鏄惁鎸夈�屽湪闄㈡弧鎰忓害銆嶅彛寰勬煡璇細鍦ㄩ櫌婊℃剰搴︾敤 deptcodes/hospitaldistrictcodes锛�
+ // 绂婚櫌婊℃剰搴︼紙浠ュ強娓呯┖涓嬫媺鏃剁殑榛樿鍙e緞锛夌敤 leaveldeptcodes/leavehospitaldistrictcodes
+ isInHospitalSatisfaction() {
+ return this.satisfactionScope === "hospital";
+ },
// 鏈�夌瀹ゆ椂鐨勯粯璁ゆ煡璇㈣寖鍥达細鍏ㄩ儴绉戝缂栫爜
defaultDeptCodes() {
return Array.from(new Set(this.deptOptions.map((d) => d.value)));
@@ -595,7 +621,8 @@
veryBadRate: this.rateOf(veryBad.count, total),
naCount: na.count,
naRate: this.rateOf(na.count, total),
- score: this.scoreOfItems(items),
+ total,
+ score: this.formatScore(q.avgScore),
};
});
@@ -609,6 +636,17 @@
});
});
const total = sum.reduce((s, it) => s + it.count, 0);
+ // 鎬昏缁煎悎寰楀垎锛氭寜鍚勯濉姤閲忓姞鏉冨钩鍧囧悇棰� avgScore
+ let totalScoreNum = 0;
+ let totalScoreDen = 0;
+ this.satisfactionQuestions.forEach((q, i) => {
+ const avg = Number(q.avgScore);
+ const qTotal = rows[i] ? rows[i].total : 0;
+ if (!isNaN(avg) && qTotal) {
+ totalScoreNum += avg * qTotal;
+ totalScoreDen += qTotal;
+ }
+ });
rows.push({
category: "鎬昏",
veryGoodCount: sum[0].count,
@@ -623,7 +661,7 @@
veryBadRate: this.rateOf(sum[4].count, total),
naCount: sum[5].count,
naRate: this.rateOf(sum[5].count, total),
- score: this.scoreOfItems(sum),
+ score: totalScoreDen ? (totalScoreNum / totalScoreDen).toFixed(2) : "0.00",
});
return rows;
},
@@ -772,6 +810,11 @@
if (!denominator) return "0.00";
return (numerator / denominator).toFixed(2);
},
+ // 缁煎悎寰楀垎灞曠ず锛氱洿鎺ヤ娇鐢ㄥ悗绔� avgScore锛屾牸寮忓寲涓轰袱浣嶅皬鏁�
+ formatScore(val) {
+ const n = Number(val);
+ return isNaN(n) ? "0.00" : n.toFixed(2);
+ },
defaultRange() {
const end = new Date();
const start = new Date();
@@ -806,8 +849,10 @@
return;
}
- // 鐥呭尯 => leavehospitaldistrictcodes锛岀瀹� => leaveldeptcodes
- // 绉戝/鐥呭尯浜掓枼锛氭寜鐥呭尯鍙紶 leavehospitaldistrictcodes锛屾寜绉戝鍙紶 leaveldeptcodes
+ // 绉戝/鐥呭尯鏉′欢闅忋�屾弧鎰忓害绫诲瀷銆嶅垏鎹細
+ // 鍦ㄩ櫌婊℃剰搴� => deptcodes / hospitaldistrictcodes锛堝湪闄㈢瀹ゃ�佸湪闄㈢梾鍖猴級
+ // 绂婚櫌婊℃剰搴� => leaveldeptcodes / leavehospitaldistrictcodes锛堢闄㈢瀹ゃ�佺闄㈢梾鍖猴級
+ // 绉戝/鐥呭尯浜掓枼锛氭寜鐥呭尯鍙紶鐥呭尯缂栫爜锛屾寜绉戝鍙紶绉戝缂栫爜
const wards = this.queryParams.wardCodes || [];
const depts = this.queryParams.deptCodes || [];
@@ -817,13 +862,23 @@
endFinishTime: range[1],
};
if (this.queryParams.statMode === "dept") {
- payload.leaveldeptcodes = depts.length
+ const deptCodes = depts.length
? Array.from(new Set(depts))
: this.defaultDeptCodes;
+ if (this.isInHospitalSatisfaction) {
+ payload.deptcodes = deptCodes;
+ } else {
+ payload.leaveldeptcodes = deptCodes;
+ }
} else {
- payload.leavehospitaldistrictcodes = wards.length
+ const wardCodes = wards.length
? Array.from(new Set(wards))
: this.defaultWardCodes;
+ if (this.isInHospitalSatisfaction) {
+ payload.hospitaldistrictcodes = wardCodes;
+ } else {
+ payload.leavehospitaldistrictcodes = wardCodes;
+ }
}
// 鏈嶅姟绫诲瀷澶氶�夛細閫楀彿鍒嗛殧锛堟帴鍙e瓧娈典负 serviceType 瀛楃涓诧級
const serviceTypes = this.queryParams.serviceTypeList || [];
@@ -870,10 +925,17 @@
endFinishTime: range[1],
};
try {
- // 鎸夌瀹ょ粺璁★紙leaveldeptcodes 浼樺厛锛変笌鎸夌梾鍖虹粺璁★紙leavehospitaldistrictcodes锛夊悇鏌ヤ竴娆�
+ // 鎸夌瀹ょ粺璁°�佹寜鐥呭尯缁熻鍚勬煡涓�娆★紝鏉′欢闅忋�屾弧鎰忓害绫诲瀷銆嶅垏鎹細
+ // 鍦ㄩ櫌婊℃剰搴� => deptcodes / hospitaldistrictcodes锛涚闄㈡弧鎰忓害 => leaveldeptcodes / leavehospitaldistrictcodes
+ const deptParam = this.isInHospitalSatisfaction
+ ? { deptcodes: this.defaultDeptCodes }
+ : { leaveldeptcodes: this.defaultDeptCodes };
+ const wardParam = this.isInHospitalSatisfaction
+ ? { hospitaldistrictcodes: this.defaultWardCodes }
+ : { leavehospitaldistrictcodes: this.defaultWardCodes };
const [deptRes, wardRes] = await Promise.all([
- statQuestionOptionByKsOrBq({ ...base, leaveldeptcodes: this.defaultDeptCodes }),
- statQuestionOptionByKsOrBq({ ...base, leavehospitaldistrictcodes: this.defaultWardCodes }),
+ statQuestionOptionByKsOrBq({ ...base, ...deptParam }),
+ statQuestionOptionByKsOrBq({ ...base, ...wardParam }),
]);
// 鎺掓煡鐢細鎵撳嵃鎺ュ彛鍘熷杩斿洖锛屼究浜庢牳瀵逛袱绾у祵濂� Map 缁撴瀯锛堢‘璁ゆ棤璇悗鍙垹闄わ級
console.log(
--
Gitblit v1.9.3