From d6aa663043a23bb37f1c712a19424690c5a2062f Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 03 十一月 2026 09:35:12 +0800
Subject: [PATCH] nhfy@0230
---
src/components/PendingTaskBox/index.vue | 2
src/views/sfstatistics/percentage/components/SecondFollowUp.vue | 2
src/views/sfstatistics/percentage/followupAnalysisMixin.js | 427 ++++++++
dist.zip | 0
src/api/AiCentre/SingleTask.js | 7
src/views/Satisfaction/sfstatistics/components/QuestionChartItem.vue | 360 +++++++
src/views/sfstatistics/percentage/components/FirstFollowUp.vue | 2
src/views/sfstatistics/percentage/components/FollowupPatientTable.vue | 436 ++++++++
src/views/Satisfaction/sfstatistics/components/topicUtils.js | 34
src/utils/request.js | 17
src/views/login.vue | 2
src/views/sfstatistics/percentage/index.vue | 105 ++
src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue | 410 +++++++
src/views/Satisfaction/sfstatistics/components/QuestionChart.vue | 257 +++++
src/views/Satisfaction/sfstatistics/components/QuestionRatioTable.vue | 280 +++++
src/views/Satisfaction/sfstatistics/index.vue | 97 +
src/views/sfstatistics/percentage/satisfactionAnalysisMixin.js | 154 +++
src/views/Satisfaction/sfstatistics/components/CompletedDetail.vue | 416 ++++++++
18 files changed, 2,983 insertions(+), 25 deletions(-)
diff --git a/dist.zip b/dist.zip
index 27108ba..1f2faf6 100644
--- a/dist.zip
+++ b/dist.zip
Binary files differ
diff --git a/src/api/AiCentre/SingleTask.js b/src/api/AiCentre/SingleTask.js
index 89474da..acce770 100644
--- a/src/api/AiCentre/SingleTask.js
+++ b/src/api/AiCentre/SingleTask.js
@@ -1,4 +1,4 @@
-import request from "@/utils/request";
+import request, { downloadBlob } from "@/utils/request";
// 鏌ヨ瀹f暀浠诲姟鍒楄〃
export function gethetasklist(data) {
@@ -143,6 +143,11 @@
data: data,
});
}
+
+// 瀵煎嚭闅忚鎮h�呮槑缁嗭紙鍚庣 Excel锛屽惈鎮h�呰〃鍗�/闂璇︽儏鍗犳瘮绛� sheet锛�
+export function exportPatItem(data) {
+ return downloadBlob("/smartor/serviceSubtask/patItemExport", data);
+}
// 鏈嶅姟杞瀹�/鐥呭尯
export function transferDept(data) {
return request({
diff --git a/src/components/PendingTaskBox/index.vue b/src/components/PendingTaskBox/index.vue
index fa1bfb9..4a5526d 100644
--- a/src/components/PendingTaskBox/index.vue
+++ b/src/components/PendingTaskBox/index.vue
@@ -29,7 +29,7 @@
<path d="M9 14l2 2 4-4" />
</svg>
<span class="ptb-header-title" title="鍑洪櫌婊� 7 澶┿�佷粛寰呴殢璁跨殑鍑洪櫌/闂ㄨ瘖浠诲姟">
- 寰呭鐞嗛殢璁夸换鍔�
+ 寰呭鐞嗛殢璁夸换鍔★紙鍑洪櫌婊�7澶╀粛鏈殢璁匡級
</span>
</div>
<div class="ptb-header-actions">
diff --git a/src/utils/request.js b/src/utils/request.js
index ea1f0f8..67bf73b 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -148,9 +148,22 @@
}
);
+// 閫氱敤璇锋眰 Blob锛堣〃鍗曟牸寮忥級锛岀敤浜庤В鏋愬悗绔鍑虹殑 Excel
+export function downloadBlob(url, params, config) {
+ return service.post(url, params, {
+ transformRequest: [
+ (params) => {
+ return tansParams(params);
+ },
+ ],
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
+ responseType: "arraybuffer",
+ ...config,
+ });
+}
+
// 閫氱敤涓嬭浇鏂规硶
-export function download(url, params, filename, config) {
- downloadLoadingInstance = Loading.service({
+export function download(url, params, filename, config) { downloadLoadingInstance = Loading.service({
text: "姝e湪涓嬭浇鏁版嵁锛岃绋嶅��",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)",
diff --git a/src/views/Satisfaction/sfstatistics/components/CompletedDetail.vue b/src/views/Satisfaction/sfstatistics/components/CompletedDetail.vue
new file mode 100644
index 0000000..a5a6078
--- /dev/null
+++ b/src/views/Satisfaction/sfstatistics/components/CompletedDetail.vue
@@ -0,0 +1,416 @@
+<template>
+ <div class="completed-detail" v-loading="loading">
+ <div class="detail-header">
+ <div class="detail-title">
+ <span>鎮h�呴殢璁夸俊鎭〃鍗�</span>
+ <el-tag type="success" size="mini" disable-transitions>宸插畬鎴�</el-tag>
+ </div>
+ <div class="detail-meta">
+ <span class="meta-item">
+ {{ dimensionLabel }}锛�<b>{{ groupLabel }}</b>
+ </span>
+ <span class="meta-item">瀹屾垚鏃堕棿锛歿{ rangeText }}</span>
+ <span class="meta-item">鍏� <b>{{ total }}</b> 鏉�</span>
+ <el-button
+ type="warning"
+ plain
+ size="mini"
+ icon="el-icon-download"
+ :disabled="!total"
+ @click="exportExcel"
+ >瀵煎嚭</el-button
+ >
+ </div>
+ </div>
+
+ <el-table
+ :data="pagedRows"
+ border
+ empty-text="鏆傛棤宸插畬鎴愭偅鑰呮暟鎹�"
+ :header-cell-style="{
+ background: '#f8f9fa',
+ color: '#333',
+ fontWeight: 600,
+ }"
+ >
+ <el-table-column
+ label="濮撳悕"
+ prop="sendname"
+ width="100"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column label="澶勭悊鐘舵��" width="100" align="center">
+ <template slot-scope="scope">
+ <el-tag type="success" size="small" disable-transitions
+ >宸插畬鎴�</el-tag
+ >
+ </template>
+ </el-table-column>
+ <el-table-column label="澶勭悊鎰忚" prop="suggest" width="120" align="center">
+ <template slot-scope="scope">
+ <dict-tag
+ :options="(dict.type && dict.type.sys_suggest) || []"
+ :value="scope.row.suggest"
+ />
+ </template>
+ </el-table-column>
+ <el-table-column label="闅忚瀹屾垚鏃堕棿" width="170" align="center">
+ <template slot-scope="scope">
+ {{ formatDateTime(scope.row.finishtime) }}
+ </template>
+ </el-table-column>
+ <el-table-column label="鍑洪櫌鏃ユ湡" width="120" align="center">
+ <template slot-scope="scope">
+ {{ formatDate(scope.row.endtime) }}
+ </template>
+ </el-table-column>
+ <el-table-column
+ label="鎺ヨ瘖鍖荤敓"
+ prop="drname"
+ width="100"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column label="鍑洪櫌澶╂暟" width="100" align="center">
+ <template slot-scope="scope">
+ {{ endDayText(scope.row) }}
+ </template>
+ </el-table-column>
+ <el-table-column
+ label="韬唤璇佸彿鐮�"
+ prop="sfzh"
+ width="190"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ label="鑱旂郴鐢佃瘽"
+ prop="phone"
+ width="135"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ label="璐d换鎶ゅ+"
+ prop="nurseName"
+ width="100"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ label="绉戝"
+ width="130"
+ align="center"
+ show-overflow-tooltip
+ >
+ <template slot-scope="scope">
+ {{ deptNameOf(scope.row) }}
+ </template>
+ </el-table-column>
+ <el-table-column
+ label="鐥呭尯"
+ width="140"
+ align="center"
+ show-overflow-tooltip
+ >
+ <template slot-scope="scope">
+ {{ wardNameOf(scope.row) }}
+ </template>
+ </el-table-column>
+ <el-table-column
+ label="澶勭悊浜哄憳"
+ prop="updateBy"
+ width="100"
+ align="center"
+ show-overflow-tooltip
+ />
+ </el-table>
+
+ <div class="pagination-wrap" v-if="total > pageSize">
+ <el-pagination
+ background
+ layout="total, sizes, prev, pager, next"
+ :current-page="pageNum"
+ :page-size="pageSize"
+ :page-sizes="[10, 20, 50, 100]"
+ :total="total"
+ @size-change="handleSizeChange"
+ @current-change="handlePageChange"
+ />
+ </div>
+ </div>
+</template>
+
+<script>
+import ExcelJS from "exceljs";
+import { saveAs } from "file-saver";
+
+export default {
+ name: "CompletedDetail",
+ dicts: ["sys_suggest"],
+ props: {
+ rows: {
+ type: Array,
+ default: () => [],
+ },
+ meta: {
+ type: Object,
+ default: () => ({}),
+ },
+ loading: {
+ type: Boolean,
+ default: false,
+ },
+ },
+ data() {
+ return {
+ pageNum: 1,
+ pageSize: 20,
+ };
+ },
+ computed: {
+ total() {
+ return (this.rows || []).length;
+ },
+ pagedRows() {
+ const start = (this.pageNum - 1) * this.pageSize;
+ return (this.rows || []).slice(start, start + this.pageSize);
+ },
+ dimensionLabel() {
+ return this.meta.dimension === "dept" ? "绉戝" : "鐥呭尯";
+ },
+ groupLabel() {
+ return this.meta.groupLabel || "鍏ㄩ儴";
+ },
+ rangeText() {
+ const range = this.meta.dateRange || [];
+ if (range.length === 2 && range[0] && range[1]) {
+ return `${range[0]} 鑷� ${range[1]}`;
+ }
+ return "鍏ㄩ儴";
+ },
+ },
+ watch: {
+ rows() {
+ this.pageNum = 1;
+ },
+ },
+ methods: {
+ handleSizeChange(size) {
+ this.pageSize = size;
+ this.pageNum = 1;
+ },
+ handlePageChange(page) {
+ this.pageNum = page;
+ },
+ formatDateTime(value) {
+ return value ? this.parseTime(value) : "-";
+ },
+ formatDate(value) {
+ return value ? this.formatTime(value) : "-";
+ },
+ endDayText(row) {
+ if (
+ !row ||
+ row.endDay === null ||
+ row.endDay === undefined ||
+ row.endDay === ""
+ ) {
+ return "-";
+ }
+ return row.endDay + "澶�";
+ },
+ deptNameOf(row) {
+ if (!row) return "-";
+ const name =
+ this.meta.scope === "hospital"
+ ? row.deptname || row.leaveldeptname
+ : row.leaveldeptname || row.deptname;
+ return name || "-";
+ },
+ wardNameOf(row) {
+ if (!row) return "-";
+ const name =
+ this.meta.scope === "hospital"
+ ? row.hospitaldistrictname || row.leavehospitaldistrictname
+ : row.leavehospitaldistrictname || row.hospitaldistrictname;
+ return name || "-";
+ },
+ suggestLabel(value) {
+ const options =
+ (this.dict && this.dict.type && this.dict.type.sys_suggest) || [];
+ const found = options.find((item) => item.value == value);
+ return found ? found.label : value || "";
+ },
+ fileDate() {
+ const now = new Date();
+ const pad = (value) => String(value).padStart(2, "0");
+ return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(
+ now.getDate()
+ )}`;
+ },
+ async exportExcel() {
+ if (!this.total) {
+ this.$message.warning("鏆傛棤鍙鍑虹殑鏁版嵁");
+ return;
+ }
+
+ try {
+ const workbook = new ExcelJS.Workbook();
+ const worksheet = workbook.addWorksheet("鎮h�呴殢璁夸俊鎭〃鍗�");
+ const headers = [
+ "濮撳悕",
+ "澶勭悊鐘舵��",
+ "澶勭悊鎰忚",
+ "闅忚瀹屾垚鏃堕棿",
+ "鍑洪櫌鏃ユ湡",
+ "鎺ヨ瘖鍖荤敓",
+ "鍑洪櫌澶╂暟",
+ "韬唤璇佸彿鐮�",
+ "鑱旂郴鐢佃瘽",
+ "璐d换鎶ゅ+",
+ "绉戝",
+ "鐥呭尯",
+ "澶勭悊浜哄憳",
+ ];
+ const colCount = headers.length;
+ const 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, colCount);
+ const titleCell = worksheet.getCell(1, 1);
+ titleCell.value = "鎮h�呴殢璁夸俊鎭〃鍗�";
+ titleCell.font = { size: 14, bold: true };
+ titleCell.alignment = { horizontal: "center", vertical: "middle" };
+ worksheet.getRow(1).height = 30;
+
+ worksheet.mergeCells(2, 1, 2, colCount);
+ const metaCell = worksheet.getCell(2, 1);
+ metaCell.value = `${this.dimensionLabel}锛�${this.groupLabel} 瀹屾垚鏃堕棿锛�${this.rangeText} 鍏� ${this.total} 鏉;
+ metaCell.alignment = { horizontal: "left", vertical: "middle" };
+ worksheet.getRow(2).height = 22;
+
+ const headerRow = worksheet.addRow(headers);
+ headerRow.height = 24;
+ headerRow.eachCell((cell) => {
+ cell.font = { bold: true };
+ cell.fill = {
+ type: "pattern",
+ pattern: "solid",
+ fgColor: { argb: "FFF5F7FA" },
+ };
+ cell.border = border;
+ cell.alignment = { horizontal: "center", vertical: "middle" };
+ });
+
+ (this.rows || []).forEach((row) => {
+ const dept = this.deptNameOf(row);
+ const ward = this.wardNameOf(row);
+ const dataRow = worksheet.addRow([
+ row.sendname || "",
+ "宸插畬鎴�",
+ this.suggestLabel(row.suggest),
+ row.finishtime ? this.parseTime(row.finishtime) : "",
+ row.endtime ? this.formatTime(row.endtime) : "",
+ row.drname || "",
+ row.endDay === null ||
+ row.endDay === undefined ||
+ row.endDay === ""
+ ? ""
+ : `${row.endDay}澶ー,
+ row.sfzh || "",
+ row.phone || "",
+ row.nurseName || "",
+ dept === "-" ? "" : dept,
+ ward === "-" ? "" : ward,
+ row.updateBy || "",
+ ]);
+ dataRow.height = 22;
+ dataRow.eachCell((cell) => {
+ cell.border = border;
+ cell.alignment = { horizontal: "center", vertical: "middle" };
+ });
+ });
+
+ worksheet.columns = [
+ { width: 12 },
+ { width: 10 },
+ { width: 14 },
+ { width: 20 },
+ { width: 14 },
+ { width: 12 },
+ { width: 10 },
+ { width: 22 },
+ { width: 16 },
+ { width: 12 },
+ { width: 18 },
+ { width: 18 },
+ { width: 12 },
+ ];
+
+ const buffer = await workbook.xlsx.writeBuffer();
+ const blob = new Blob([buffer], {
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ });
+ saveAs(blob, `鎮h�呴殢璁夸俊鎭〃鍗昣${this.fileDate()}.xlsx`);
+ this.$message.success("瀵煎嚭鎴愬姛");
+ } catch (error) {
+ console.error("瀵煎嚭鎮h�呴殢璁夸俊鎭け璐�:", error);
+ this.$message.error("瀵煎嚭澶辫触");
+ }
+ },
+ },
+};
+</script>
+
+<style lang="scss" scoped>
+.completed-detail {
+ padding: 4px 0 8px;
+
+ .detail-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: 12px;
+ margin-bottom: 14px;
+ }
+
+ .detail-title {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 15px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ .detail-meta {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 16px;
+ font-size: 13px;
+ color: #606266;
+
+ b {
+ color: #303133;
+ }
+ }
+
+ .pagination-wrap {
+ display: flex;
+ justify-content: flex-end;
+ margin-top: 14px;
+ }
+
+ ::v-deep .el-table th {
+ background-color: #f8f9fa;
+ }
+}
+</style>
diff --git a/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue b/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
index c299b30..d8687d5 100644
--- a/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
+++ b/src/views/Satisfaction/sfstatistics/components/FollowupStatistics.vue
@@ -389,6 +389,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";
@@ -397,6 +398,13 @@
components: {
SeedetailsDialog,
TopicDialog,
+ },
+ props: {
+ // 鏄惁鍦ㄩ《閮ㄧ敓鎴愭偅鑰呰〃鍗� / 闂璇︽儏鍒嗘瀽 tab锛堜粎婊℃剰搴︾粺璁′富椤靛紑鍚級
+ showAnalysisTabs: {
+ type: Boolean,
+ default: false,
+ },
},
data() {
return {
@@ -458,6 +466,10 @@
// 鍔犺浇鐘舵��
loading: false,
orgname: "",
+ // 宸插畬鎴愭槑缁嗚姹傚簭鍙凤紝閬垮厤蹇�熷垏鎹㈢瓫閫夋椂鏃ц姹傝鐩栨柊缁撴灉
+ completedRequestSeq: 0,
+ // 闂璇︽儏璇锋眰搴忓彿
+ questionRequestSeq: 0,
// 閫変腑鐨勮
ids: [],
@@ -522,12 +534,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.initData();
+ // 椤堕儴鎮h�呰〃鍗� / 闂璇︽儏鍒嗘瀽 tab锛氶粯璁ゆ寜褰撳墠缁熻鍙e緞鍔犺浇涓�娆�
+ this.maybeRefreshCompletedGroups();
+ this.maybeRefreshQuestionDetails();
},
methods: {
@@ -595,41 +616,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;
+ }
}
}
@@ -843,18 +864,371 @@
}
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();
+ },
+
+ /**
+ * 椤堕儴銆屽凡瀹屾垚鎮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锛�
@@ -870,6 +1244,8 @@
pageSize: 20,
};
this.getList();
+ this.maybeRefreshCompletedGroups();
+ this.maybeRefreshQuestionDetails();
},
// 澶勭悊鍒嗛〉澶у皬鍙樺寲
diff --git a/src/views/Satisfaction/sfstatistics/components/QuestionChart.vue b/src/views/Satisfaction/sfstatistics/components/QuestionChart.vue
new file mode 100644
index 0000000..109769d
--- /dev/null
+++ b/src/views/Satisfaction/sfstatistics/components/QuestionChart.vue
@@ -0,0 +1,257 @@
+<template>
+ <div
+ class="question-chart"
+ v-loading="loading"
+ element-loading-text="姝e湪姹囨�婚殢璁块棶鍗烽鐩�..."
+ >
+ <div class="chart-header">
+ <div class="chart-title">
+ {{ view === "pie" ? "闂璇︽儏鍗犳瘮楗煎浘" : "闂璇︽儏鍗犳瘮鍥捐〃" }}
+ </div>
+ <div class="chart-header-right">
+ <div v-if="topics.length" class="chart-meta">
+ 鍏� {{ topics.length }} 閬撻
+ </div>
+ <el-button
+ type="warning"
+ plain
+ size="mini"
+ icon="el-icon-download"
+ :disabled="!topics.length"
+ @click="exportExcel"
+ >瀵煎嚭</el-button
+ >
+ </div>
+ </div>
+
+ <div v-if="!loading && !topics.length" class="chart-empty">
+ <el-empty description="鏆傛棤闂璇︽儏鏁版嵁"></el-empty>
+ </div>
+
+ <div v-else class="chart-grid" :style="gridStyle">
+ <question-chart-item
+ v-for="(topic, index) in topics"
+ :key="topic.scriptid || topic.id || index"
+ :ref="'chartItem-' + index"
+ :topic="topic"
+ :index="index"
+ :view="view"
+ :hide-index="hideIndex"
+ :chart-height="chartHeight"
+ />
+ </div>
+ </div>
+</template>
+
+<script>
+import ExcelJS from "exceljs";
+import { saveAs } from "file-saver";
+import QuestionChartItem from "./QuestionChartItem.vue";
+import { formatPercentage, normalizeTopicList } from "./topicUtils";
+
+export default {
+ name: "QuestionChart",
+ components: {
+ QuestionChartItem,
+ },
+ props: {
+ topicList: {
+ type: [Array, Object],
+ default: () => [],
+ },
+ view: {
+ type: String,
+ default: "pie",
+ },
+ loading: {
+ type: Boolean,
+ default: false,
+ },
+ hideIndex: {
+ type: Boolean,
+ default: false,
+ },
+ columns: {
+ type: Number,
+ default: 0,
+ },
+ chartHeight: {
+ type: Number,
+ default: 230,
+ },
+ },
+ computed: {
+ topics() {
+ return normalizeTopicList(this.topicList);
+ },
+ gridStyle() {
+ if (this.columns === 2) {
+ return { gridTemplateColumns: "repeat(2, minmax(0, 1fr))" };
+ }
+ return {};
+ },
+ },
+ methods: {
+ fileDate() {
+ const now = new Date();
+ const pad = (value) => String(value).padStart(2, "0");
+ return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(
+ now.getDate()
+ )}`;
+ },
+ async exportExcel() {
+ if (!this.topics.length) {
+ this.$message.warning("鏆傛棤鍙鍑虹殑鏁版嵁");
+ return;
+ }
+
+ try {
+ const workbook = new ExcelJS.Workbook();
+ const 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" } },
+ };
+
+ this.topics.forEach((topic, index) => {
+ const worksheet = workbook.addWorksheet(`绗�${index + 1}棰榒);
+
+ worksheet.mergeCells(1, 1, 1, 3);
+ const titleCell = worksheet.getCell(1, 1);
+ titleCell.value = this.hideIndex
+ ? topic.scriptContent || ""
+ : `绗�${index + 1}棰橈細${topic.scriptContent || ""}`;
+ titleCell.font = { size: 12, bold: true };
+ titleCell.alignment = {
+ horizontal: "left",
+ vertical: "middle",
+ wrapText: true,
+ };
+ worksheet.getRow(1).height = 40;
+
+ const headerRow = worksheet.addRow(["閫夐」", "浜烘暟", "鍗犳瘮"]);
+ headerRow.height = 22;
+ headerRow.eachCell((cell) => {
+ cell.font = { bold: true };
+ cell.fill = {
+ type: "pattern",
+ pattern: "solid",
+ fgColor: { argb: "FFF5F7FA" },
+ };
+ cell.border = border;
+ cell.alignment = { horizontal: "center", vertical: "middle" };
+ });
+
+ const details = topic.details || [];
+ const rows = details.length
+ ? details
+ : [{ optionText: "鏆傛棤鏁版嵁", chosenQuantity: 0, chosenPercentage: "" }];
+
+ rows.forEach((detail) => {
+ const dataRow = worksheet.addRow([
+ detail.optionText || "",
+ Number(detail.chosenQuantity) || 0,
+ detail.optionText
+ ? formatPercentage(detail.chosenPercentage)
+ : "-",
+ ]);
+ dataRow.height = 22;
+ dataRow.eachCell((cell) => {
+ cell.border = border;
+ cell.alignment = {
+ horizontal: "center",
+ vertical: "middle",
+ wrapText: true,
+ };
+ });
+ });
+
+ worksheet.columns = [
+ { width: 36 },
+ { width: 12 },
+ { width: 12 },
+ ];
+
+ const chartItem = this.$refs[`chartItem-${index}`];
+ const dataUrl =
+ chartItem && chartItem.getChartDataURL
+ ? chartItem.getChartDataURL()
+ : "";
+
+ if (dataUrl) {
+ const imageId = workbook.addImage({
+ base64: dataUrl.split(",")[1],
+ extension: "png",
+ });
+ worksheet.addImage(imageId, {
+ tl: { col: 0, row: rows.length + 3 },
+ ext: { width: 600, height: 340 },
+ });
+ }
+ });
+
+ const buffer = await workbook.xlsx.writeBuffer();
+ const blob = new Blob([buffer], {
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ });
+ const viewName = this.view === "pie" ? "楗煎浘" : "鍥捐〃";
+ saveAs(blob, `闂璇︽儏鍗犳瘮${viewName}_${this.fileDate()}.xlsx`);
+ this.$message.success("瀵煎嚭鎴愬姛");
+ } catch (error) {
+ console.error("瀵煎嚭闂璇︽儏鍥捐〃澶辫触:", error);
+ this.$message.error("瀵煎嚭澶辫触");
+ }
+ },
+ },
+};
+</script>
+
+<style lang="scss" scoped>
+.question-chart {
+ padding: 4px 0 8px;
+ min-height: 240px;
+
+ .chart-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: 12px;
+ margin-bottom: 14px;
+ }
+
+ .chart-title {
+ font-size: 15px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ .chart-meta {
+ font-size: 13px;
+ color: #909399;
+ }
+
+ .chart-header-right {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ }
+
+ .chart-empty {
+ padding: 40px 0;
+ }
+
+ .chart-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
+ gap: 14px;
+ }
+}
+
+@media (max-width: 1400px) {
+ .question-chart .chart-grid {
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
+ }
+}
+</style>
diff --git a/src/views/Satisfaction/sfstatistics/components/QuestionChartItem.vue b/src/views/Satisfaction/sfstatistics/components/QuestionChartItem.vue
new file mode 100644
index 0000000..4e6835a
--- /dev/null
+++ b/src/views/Satisfaction/sfstatistics/components/QuestionChartItem.vue
@@ -0,0 +1,360 @@
+<template>
+ <div class="chart-item">
+ <div class="chart-item-title" :title="topic.scriptContent">
+ <span v-if="!hideIndex">绗瑊{ index + 1 }}棰橈細</span
+ >{{ topic.scriptContent }}
+ </div>
+
+ <div class="chart-item-body">
+ <div
+ ref="chart"
+ class="chart-item-canvas"
+ :style="{ height: chartHeight + 'px' }"
+ ></div>
+ <div v-if="!hasData" class="chart-item-empty">鏆傛棤閫夐」鏁版嵁</div>
+ </div>
+ </div>
+</template>
+
+<script>
+import * as echarts from "echarts";
+import { percentageOf } from "./topicUtils";
+
+const PIE_COLORS = [
+ "#5B7CFA",
+ "#36B37E",
+ "#FF9D4D",
+ "#FF5C5C",
+ "#8E7CFF",
+ "#00B8D9",
+ "#FFC400",
+ "#6B778C",
+ "#4CAF50",
+ "#F06292",
+];
+
+export default {
+ name: "QuestionChartItem",
+ props: {
+ topic: {
+ type: Object,
+ default: () => ({}),
+ },
+ view: {
+ type: String,
+ default: "pie",
+ },
+ index: {
+ type: Number,
+ default: 0,
+ },
+ hideIndex: {
+ type: Boolean,
+ default: false,
+ },
+ chartHeight: {
+ type: Number,
+ default: 230,
+ },
+ },
+ data() {
+ return {
+ chart: null,
+ };
+ },
+ computed: {
+ rows() {
+ const rows = (this.topic.details || []).map((detail) => ({
+ name: detail.optionText,
+ count: Number(detail.chosenQuantity) || 0,
+ percent: percentageOf(detail.chosenPercentage),
+ }));
+
+ // 鍚庣鏈繑鍥炴瘮渚嬫椂锛岀敤閫夋嫨浜烘暟鍏滃簳璁$畻
+ if (rows.length && rows.every((item) => item.percent === 0)) {
+ const total = rows.reduce((sum, item) => sum + item.count, 0);
+ if (total > 0) {
+ rows.forEach((item) => {
+ item.percent = (item.count / total) * 100;
+ });
+ }
+ }
+
+ return rows;
+ },
+ hasData() {
+ return this.rows.length > 0;
+ },
+ },
+ watch: {
+ topic: {
+ deep: true,
+ handler() {
+ this.$nextTick(this.renderChart);
+ },
+ },
+ view() {
+ this.$nextTick(this.renderChart);
+ },
+ },
+ mounted() {
+ this.$nextTick(this.renderChart);
+ window.addEventListener("resize", this.resizeChart);
+ },
+ beforeDestroy() {
+ window.removeEventListener("resize", this.resizeChart);
+ if (this.chart) {
+ this.chart.dispose();
+ this.chart = null;
+ }
+ },
+ methods: {
+ renderChart() {
+ const el = this.$refs.chart;
+ if (!el) return;
+
+ if (!this.chart) {
+ this.chart = echarts.init(el);
+ }
+
+ if (!this.hasData) {
+ this.chart.clear();
+ return;
+ }
+
+ if (this.view === "pie") {
+ const totalCount = this.rows.reduce(
+ (sum, item) => sum + item.count,
+ 0
+ );
+ if (totalCount === 0) {
+ this.chart.clear();
+ this.chart.setOption(
+ {
+ title: {
+ text: "鏆傛棤浣滅瓟",
+ left: "center",
+ top: "middle",
+ textStyle: {
+ color: "#909399",
+ fontSize: 12,
+ fontWeight: "normal",
+ },
+ },
+ legend: {
+ type: "scroll",
+ bottom: 0,
+ icon: "circle",
+ itemWidth: 7,
+ itemHeight: 7,
+ data: this.rows.map((item) => item.name),
+ textStyle: { color: "#909399", fontSize: 10 },
+ },
+ series: [
+ {
+ type: "pie",
+ radius: ["32%", "62%"],
+ center: ["50%", "42%"],
+ silent: true,
+ label: { show: false },
+ data: this.rows.map((item) => ({
+ name: item.name,
+ value: 1,
+ itemStyle: { color: "#ebeef5" },
+ })),
+ },
+ ],
+ },
+ true
+ );
+ this.chart.resize();
+ return;
+ }
+ }
+
+ const option =
+ this.view === "pie"
+ ? this.buildPieOption()
+ : this.buildBarOption();
+
+ this.chart.setOption(option, true);
+ this.chart.resize();
+ },
+
+ buildBarOption() {
+ const rows = this.rows;
+ const labels = rows.map((item) => item.name);
+
+ return {
+ tooltip: {
+ trigger: "axis",
+ axisPointer: { type: "shadow" },
+ formatter: (params) => {
+ const item = rows[params[0].dataIndex];
+ return `${item.name}<br/>鍗犳瘮锛�${item.percent.toFixed(
+ 2
+ )}%<br/>浜烘暟锛�${item.count}`;
+ },
+ },
+ grid: { left: 40, right: 12, top: 18, bottom: 58 },
+ xAxis: {
+ type: "category",
+ data: labels,
+ axisTick: { alignWithLabel: true },
+ axisLabel: {
+ interval: 0,
+ rotate: labels.length > 5 ? 30 : 0,
+ color: "#606266",
+ fontSize: 10,
+ formatter: (value) =>
+ value.length > 7 ? `${value.slice(0, 7)}鈥 : value,
+ },
+ },
+ yAxis: {
+ type: "value",
+ max: 100,
+ axisLabel: { formatter: "{value}%", color: "#909399", fontSize: 10 },
+ splitLine: { lineStyle: { color: "#ebeef5" } },
+ },
+ series: [
+ {
+ type: "bar",
+ data: rows.map((item) => Number(item.percent.toFixed(2))),
+ barMaxWidth: 34,
+ itemStyle: {
+ color: "#5B7CFA",
+ borderRadius: [3, 3, 0, 0],
+ },
+ label: {
+ show: true,
+ position: "top",
+ color: "#606266",
+ fontSize: 10,
+ formatter: (params) => `${params.value}%`,
+ },
+ },
+ ],
+ };
+ },
+
+ buildPieOption() {
+ const rows = this.rows;
+
+ return {
+ color: PIE_COLORS,
+ tooltip: {
+ trigger: "item",
+ formatter: (params) => {
+ const item = rows[params.dataIndex];
+ return `${item.name}<br/>鍗犳瘮锛�${item.percent.toFixed(
+ 2
+ )}%<br/>浜烘暟锛�${item.count}`;
+ },
+ },
+ legend: {
+ type: "scroll",
+ bottom: 0,
+ icon: "circle",
+ itemWidth: 7,
+ itemHeight: 7,
+ textStyle: { color: "#606266", fontSize: 10 },
+ },
+ series: [
+ {
+ type: "pie",
+ radius: ["32%", "62%"],
+ center: ["50%", "42%"],
+ avoidLabelOverlap: true,
+ minAngle: 2,
+ itemStyle: {
+ borderColor: "#fff",
+ borderWidth: 2,
+ },
+ label: {
+ color: "#606266",
+ fontSize: 10,
+ formatter: (params) => {
+ const item = rows[params.dataIndex];
+ return `${item.percent.toFixed(1)}%\n(${item.count})`;
+ },
+ },
+ labelLine: {
+ length: 8,
+ length2: 6,
+ },
+ data: rows.map((item) => ({
+ name: item.name,
+ value: Number(item.percent.toFixed(2)),
+ })),
+ },
+ ],
+ };
+ },
+
+ resizeChart() {
+ if (this.chart) {
+ this.chart.resize();
+ }
+ },
+
+ getChartDataURL() {
+ if (!this.chart) return "";
+ return this.chart.getDataURL({
+ type: "png",
+ pixelRatio: 2,
+ backgroundColor: "#fff",
+ });
+ },
+ },
+};
+</script>
+
+<style lang="scss" scoped>
+.chart-item {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ padding: 10px 12px 8px;
+ background: #fff;
+ border: 1px solid #ebeef5;
+ border-radius: 6px;
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
+
+ .chart-item-title {
+ min-height: 38px;
+ margin-bottom: 4px;
+ font-size: 12px;
+ font-weight: 600;
+ line-height: 19px;
+ color: #303133;
+ display: -webkit-box;
+ -webkit-line-clamp: 2;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+ }
+
+ .chart-item-body {
+ position: relative;
+ width: 100%;
+ }
+
+ .chart-item-canvas {
+ width: 100%;
+ height: 230px;
+ }
+
+ .chart-item-empty {
+ position: absolute;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: #fff;
+ color: #909399;
+ font-size: 13px;
+ }
+}
+</style>
diff --git a/src/views/Satisfaction/sfstatistics/components/QuestionRatioTable.vue b/src/views/Satisfaction/sfstatistics/components/QuestionRatioTable.vue
new file mode 100644
index 0000000..6c7271d
--- /dev/null
+++ b/src/views/Satisfaction/sfstatistics/components/QuestionRatioTable.vue
@@ -0,0 +1,280 @@
+<template>
+ <div
+ class="question-ratio"
+ v-loading="loading"
+ element-loading-text="姝e湪姹囨�婚殢璁块棶鍗烽鐩�..."
+ >
+ <div class="ratio-header">
+ <div class="ratio-title">闂璇︽儏鍗犳瘮</div>
+ <div class="ratio-header-right">
+ <span class="ratio-meta">鍏� {{ topics.length }} 閬撻</span>
+ <el-button
+ type="warning"
+ plain
+ size="mini"
+ icon="el-icon-download"
+ :disabled="!topics.length"
+ @click="exportExcel"
+ >瀵煎嚭</el-button
+ >
+ </div>
+ </div>
+
+ <div
+ v-if="!loading && !topics.length"
+ class="ratio-empty"
+ >
+ <el-empty description="鏆傛棤闂璇︽儏鏁版嵁"></el-empty>
+ </div>
+
+ <div v-else class="ratio-list">
+ <div
+ v-for="(topic, index) in topics"
+ :key="topic.scriptid || topic.id || index"
+ class="ratio-question"
+ >
+ <div class="ratio-question-title">
+ <span>
+ <span v-if="!hideIndex">绗瑊{ index + 1 }}棰橈細</span
+ >{{ topic.scriptContent }}
+ </span>
+ <span v-if="!hideType" class="ratio-type"
+ >[{{ typeLabel(topic) }}]</span
+ >
+ </div>
+ <el-table :data="topic.details" border size="small">
+ <el-table-column
+ prop="optionText"
+ label="闂閫夐」"
+ min-width="240"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ prop="chosenQuantity"
+ label="閫夋嫨浜烘暟"
+ width="120"
+ align="center"
+ >
+ <template slot-scope="scope">
+ {{ scope.row.chosenQuantity || 0 }}
+ </template>
+ </el-table-column>
+ <el-table-column label="鍗犳瘮" width="120" align="center">
+ <template slot-scope="scope">
+ {{ formatPercentage(scope.row.chosenPercentage) }}
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
+ </div>
+ </div>
+</template>
+
+<script>
+import ExcelJS from "exceljs";
+import { saveAs } from "file-saver";
+import {
+ formatPercentage,
+ normalizeTopicList,
+ topicTypeLabel,
+} from "./topicUtils";
+
+export default {
+ name: "QuestionRatioTable",
+ props: {
+ topicList: {
+ type: [Array, Object],
+ default: () => [],
+ },
+ loading: {
+ type: Boolean,
+ default: false,
+ },
+ hideIndex: {
+ type: Boolean,
+ default: false,
+ },
+ hideType: {
+ type: Boolean,
+ default: false,
+ },
+ },
+ computed: {
+ topics() {
+ return normalizeTopicList(this.topicList);
+ },
+ },
+ methods: {
+ formatPercentage,
+ typeLabel: topicTypeLabel,
+ fileDate() {
+ const now = new Date();
+ const pad = (value) => String(value).padStart(2, "0");
+ return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(
+ now.getDate()
+ )}`;
+ },
+ async exportExcel() {
+ if (!this.topics.length) {
+ this.$message.warning("鏆傛棤鍙鍑虹殑鏁版嵁");
+ return;
+ }
+
+ try {
+ const workbook = new ExcelJS.Workbook();
+ const worksheet = workbook.addWorksheet("闂璇︽儏鍗犳瘮");
+ const headers = ["棰樼洰", "棰樺瀷", "闂閫夐」", "閫夋嫨浜烘暟", "鍗犳瘮"];
+ const colCount = headers.length;
+ const 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, colCount);
+ const titleCell = worksheet.getCell(1, 1);
+ titleCell.value = "闂璇︽儏鍗犳瘮";
+ titleCell.font = { size: 14, bold: true };
+ titleCell.alignment = { horizontal: "center", vertical: "middle" };
+ worksheet.getRow(1).height = 30;
+
+ worksheet.mergeCells(2, 1, 2, colCount);
+ const metaCell = worksheet.getCell(2, 1);
+ metaCell.value = `鍏� ${this.topics.length} 閬撻`;
+ metaCell.alignment = { horizontal: "left", vertical: "middle" };
+ worksheet.getRow(2).height = 22;
+
+ const headerRow = worksheet.addRow(headers);
+ headerRow.height = 24;
+ headerRow.eachCell((cell) => {
+ cell.font = { bold: true };
+ cell.fill = {
+ type: "pattern",
+ pattern: "solid",
+ fgColor: { argb: "FFF5F7FA" },
+ };
+ cell.border = border;
+ cell.alignment = { horizontal: "center", vertical: "middle" };
+ });
+
+ this.topics.forEach((topic) => {
+ const details = topic.details || [];
+ const rows = details.length
+ ? details
+ : [{ optionText: "", chosenQuantity: 0, chosenPercentage: "" }];
+
+ rows.forEach((detail) => {
+ const dataRow = worksheet.addRow([
+ topic.scriptContent || "",
+ this.hideType ? "鍗犳瘮缁熻" : this.typeLabel(topic),
+ detail.optionText || "",
+ Number(detail.chosenQuantity) || 0,
+ detail.optionText
+ ? this.formatPercentage(detail.chosenPercentage)
+ : "-",
+ ]);
+ dataRow.height = 22;
+ dataRow.eachCell((cell) => {
+ cell.border = border;
+ cell.alignment = {
+ horizontal: "center",
+ vertical: "middle",
+ wrapText: true,
+ };
+ });
+ });
+ });
+
+ worksheet.columns = [
+ { width: 50 },
+ { width: 10 },
+ { width: 30 },
+ { width: 12 },
+ { width: 12 },
+ ];
+
+ const buffer = await workbook.xlsx.writeBuffer();
+ const blob = new Blob([buffer], {
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ });
+ saveAs(blob, `闂璇︽儏鍗犳瘮_${this.fileDate()}.xlsx`);
+ this.$message.success("瀵煎嚭鎴愬姛");
+ } catch (error) {
+ console.error("瀵煎嚭闂璇︽儏鍗犳瘮澶辫触:", error);
+ this.$message.error("瀵煎嚭澶辫触");
+ }
+ },
+ },
+};
+</script>
+
+<style lang="scss" scoped>
+.question-ratio {
+ padding: 4px 0 8px;
+ min-height: 240px;
+
+ .ratio-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 14px;
+ }
+
+ .ratio-title {
+ font-size: 15px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ .ratio-meta {
+ font-size: 13px;
+ color: #909399;
+ }
+
+ .ratio-header-right {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ }
+
+ .ratio-empty {
+ padding: 40px 0;
+ }
+
+ .ratio-list {
+ max-height: 62vh;
+ overflow-y: auto;
+ padding-right: 6px;
+ }
+
+ .ratio-question {
+ margin-bottom: 18px;
+
+ &:last-child {
+ margin-bottom: 0;
+ }
+ }
+
+ .ratio-question-title {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 8px;
+ margin-bottom: 8px;
+ font-size: 14px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ .ratio-type {
+ font-size: 12px;
+ font-weight: 400;
+ color: #909399;
+ }
+
+ ::v-deep .el-table th {
+ background-color: #f8f9fa;
+ }
+}
+</style>
diff --git a/src/views/Satisfaction/sfstatistics/components/topicUtils.js b/src/views/Satisfaction/sfstatistics/components/topicUtils.js
new file mode 100644
index 0000000..418d8fa
--- /dev/null
+++ b/src/views/Satisfaction/sfstatistics/components/topicUtils.js
@@ -0,0 +1,34 @@
+// 婊℃剰搴﹂棶棰樿鎯呭伐鍏凤細鎺ュ彛杩斿洖鍙兘鏄暟缁勶紝涔熷彲鑳芥槸浠� scriptid 涓� key 鐨勫璞�
+export function normalizeTopicList(data) {
+ if (!data) return [];
+ const list = Array.isArray(data) ? data : Object.values(data);
+ return list
+ .filter((topic) => topic && topic.scriptContent)
+ .map((topic) => ({
+ ...topic,
+ details: (Array.isArray(topic.details) ? topic.details : []).filter(
+ (detail) => detail && detail.optionText
+ ),
+ }));
+}
+
+export function hasPercentage(value) {
+ return value !== null && value !== undefined && value !== "";
+}
+
+// 鍚庣姣斾緥閫氬父鏄� 0~1 鐨勫皬鏁帮紝杩欓噷鍏煎鐩存帴杩斿洖 0~100 鐨勬儏鍐�
+export function percentageOf(value) {
+ if (!hasPercentage(value)) return 0;
+ const num = Number(value);
+ if (!isFinite(num)) return 0;
+ return num > 0 && num <= 1 ? num * 100 : num;
+}
+
+export function formatPercentage(value) {
+ if (!hasPercentage(value)) return "-";
+ return `${percentageOf(value).toFixed(2)}%`;
+}
+
+export function topicTypeLabel(topic) {
+ return topic && topic.scriptType == 1 ? "鍗曢�夐" : "澶氶�夐";
+}
diff --git a/src/views/Satisfaction/sfstatistics/index.vue b/src/views/Satisfaction/sfstatistics/index.vue
index a6a22f1..119f4e8 100644
--- a/src/views/Satisfaction/sfstatistics/index.vue
+++ b/src/views/Satisfaction/sfstatistics/index.vue
@@ -3,7 +3,13 @@
<div class="statistics-main">
<el-tabs v-model="activeTab" @tab-click="handleTabChange">
<el-tab-pane label="婊℃剰搴﹂殢璁跨粺璁�" name="followup">
- <followup-statistics v-if="activeTab === 'followup'" ref="followupRef" />
+ <!-- 淇濇寔鎸傝浇锛屽垏鍒板垎鏋� tab 鍐嶅洖鏉ユ椂绛涢�夋潯浠朵笉涓㈠け -->
+ <followup-statistics
+ ref="followupRef"
+ show-analysis-tabs
+ @completed-rows-change="handleCompletedRowsChange"
+ @question-details-change="handleQuestionDetailsChange"
+ />
</el-tab-pane>
<el-tab-pane label="婊℃剰搴︽槑缁嗙粺璁�" name="satisfaction">
<satisfaction-statistics v-if="activeTab === 'satisfaction'" ref="satisfactionRef" />
@@ -14,6 +20,38 @@
<el-tab-pane label="鍚勯」缁熻琛�" name="chartsPanel">
<charts-panel v-if="activeTab === 'chartsPanel'" />
</el-tab-pane>
+ <!-- 婊℃剰搴﹀垎鏋愶細鎮h�呰〃鍗� + 闂璇︽儏鍗犳瘮锛堣〃/鏌辩姸鍥�/楗煎浘锛� -->
+ <el-tab-pane label="鎮h�呴殢璁夸俊鎭〃鍗�" name="analysisForm">
+ <completed-detail
+ v-if="activeTab === 'analysisForm'"
+ :rows="completedRows"
+ :meta="detailMeta"
+ :loading="completedLoading"
+ />
+ </el-tab-pane>
+ <el-tab-pane label="闂璇︽儏鍗犳瘮" name="analysisRatio">
+ <question-ratio-table
+ v-if="activeTab === 'analysisRatio'"
+ :topic-list="topicList"
+ :loading="topicLoading"
+ />
+ </el-tab-pane>
+ <el-tab-pane label="闂璇︽儏鍗犳瘮鍥捐〃" name="analysisBar">
+ <question-chart
+ v-if="activeTab === 'analysisBar'"
+ view="bar"
+ :topic-list="topicList"
+ :loading="topicLoading"
+ />
+ </el-tab-pane>
+ <el-tab-pane label="闂璇︽儏鍗犳瘮楗煎浘" name="analysisPie">
+ <question-chart
+ v-if="activeTab === 'analysisPie'"
+ view="pie"
+ :topic-list="topicList"
+ :loading="topicLoading"
+ />
+ </el-tab-pane>
</el-tabs>
</div>
</template>
@@ -23,6 +61,9 @@
import SatisfactionStatistics from "./components/SatisfactionStatistics.vue";
import DataOverview from "./components/DataOverview.vue";
import ChartsPanel from "./components/ChartsPanel.vue";
+import CompletedDetail from "./components/CompletedDetail.vue";
+import QuestionRatioTable from "./components/QuestionRatioTable.vue";
+import QuestionChart from "./components/QuestionChart.vue";
export default {
name: "Satisfaction",
@@ -31,16 +72,70 @@
SatisfactionStatistics,
DataOverview,
ChartsPanel,
+ CompletedDetail,
+ QuestionRatioTable,
+ QuestionChart,
},
data() {
return {
activeTab: "followup",
+ // 鎮h�呴殢璁夸俊鎭〃鍗�
+ completedRows: [],
+ completedLoading: false,
+ completedMeta: {
+ dimension: "ward",
+ scope: "leave",
+ dateRange: [],
+ total: 0,
+ },
+ // 闂璇︽儏鍗犳瘮锛堣〃/鍥�/楗煎浘鍏辩敤锛�
+ topicList: [],
+ topicLoading: false,
};
+ },
+ computed: {
+ detailMeta() {
+ return {
+ ...this.completedMeta,
+ groupLabel: "鍏ㄩ儴",
+ };
+ },
},
methods: {
handleTabChange(tab) {
console.log("鍒囨崲鍒�:", tab.name);
},
+ // 鎮h�呴殢璁夸俊鎭〃鍗�
+ handleCompletedRowsChange(payload) {
+ if (!payload) return;
+
+ this.completedLoading = !!payload.loading;
+
+ if (payload.dimension) {
+ this.completedMeta = {
+ dimension: payload.dimension === "dept" ? "dept" : "ward",
+ scope: payload.scope === "hospital" ? "hospital" : "leave",
+ dateRange: Array.isArray(payload.dateRange)
+ ? payload.dateRange
+ : [],
+ total: payload.total || 0,
+ };
+ }
+
+ if (Array.isArray(payload.rows)) {
+ this.completedRows = payload.rows;
+ }
+ },
+ // 闂璇︽儏鍗犳瘮
+ handleQuestionDetailsChange(payload) {
+ if (!payload) return;
+
+ this.topicLoading = !!payload.loading;
+
+ if (payload.list !== undefined) {
+ this.topicList = payload.list || [];
+ }
+ },
},
};
</script>
diff --git a/src/views/login.vue b/src/views/login.vue
index c166a26..cc50c59 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -200,7 +200,7 @@
return label.includes("鍗楀崕") && label.includes("闄勪竴");
});
if (hasNanhua) {
- this.loginForm.password = "nhfy@0230";
+ this.loginForm.password = "Nhfy@023299.*";
}
},
getCookie() {
diff --git a/src/views/sfstatistics/percentage/components/FirstFollowUp.vue b/src/views/sfstatistics/percentage/components/FirstFollowUp.vue
index adabf9f..6274151 100644
--- a/src/views/sfstatistics/percentage/components/FirstFollowUp.vue
+++ b/src/views/sfstatistics/percentage/components/FirstFollowUp.vue
@@ -1005,7 +1005,7 @@
delete params.leavehospitaldistrictcodes.all;
delete params.deptcodes.all;
params.rateDay = this.orgname == "榫欐硥甯備汉姘戝尰闄�" ? 21 : 7;
- getSfStatistics(params)
+ return getSfStatistics(params)
.then((response) => {
this.tableData = this.customSort(response.data);
})
diff --git a/src/views/sfstatistics/percentage/components/FollowupPatientTable.vue b/src/views/sfstatistics/percentage/components/FollowupPatientTable.vue
new file mode 100644
index 0000000..6786fb5
--- /dev/null
+++ b/src/views/sfstatistics/percentage/components/FollowupPatientTable.vue
@@ -0,0 +1,436 @@
+<template>
+ <div class="followup-patient" v-loading="loading">
+ <div class="patient-header">
+ <div class="patient-title">
+ <span>鎮h�呴殢璁夸俊鎭〃鍗�</span>
+ <el-tag type="success" size="mini" disable-transitions
+ >宸插畬鎴�</el-tag
+ >
+ <el-tag type="info" size="mini" disable-transitions>{{
+ visitLabel
+ }}</el-tag>
+ </div>
+ <div class="patient-header-right">
+ <span class="patient-meta">
+ {{ meta.dateRangeText || "鍑洪櫌鏃堕棿锛氬叏閮�" }}銆�鍏�
+ <b>{{ total }}</b> 鏉�
+ </span>
+ <el-button
+ type="warning"
+ plain
+ size="mini"
+ icon="el-icon-download"
+ :disabled="!total"
+ @click="exportExcel"
+ >瀵煎嚭</el-button
+ >
+ </div>
+ </div>
+
+ <el-table
+ :data="pagedRows"
+ border
+ size="small"
+ empty-text="鏆傛棤闅忚鎮h�呮暟鎹�"
+ :header-cell-style="{
+ background: '#f8f9fa',
+ color: '#333',
+ fontWeight: 600,
+ }"
+ >
+ <el-table-column
+ prop="sendname"
+ label="濮撳悕"
+ width="100"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ prop="telcode"
+ label="鑱旂郴鐢佃瘽"
+ width="115"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ prop="taskName"
+ label="浠诲姟鍚嶇О"
+ width="170"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column label="浠诲姟鐘舵��" width="110" align="center">
+ <template slot-scope="scope">
+ <el-tag
+ :type="stateTagType(scope.row.sendstate)"
+ size="small"
+ disable-transitions
+ >{{ stateText(scope.row.sendstate) }}</el-tag
+ >
+ </template>
+ </el-table-column>
+ <el-table-column label="浠诲姟鎵ц鏂瑰紡" width="150" align="center">
+ <template slot-scope="scope">
+ {{ preachformText(scope.row.preachform) }}
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="visitTime"
+ label="搴旈殢璁挎椂闂�"
+ width="165"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column label="闅忚瀹屾垚鏃堕棿" width="165" align="center">
+ <template slot-scope="scope">
+ {{ dateTime(scope.row.finishtime) }}
+ </template>
+ </el-table-column>
+ <el-table-column label="鍑洪櫌鏃ユ湡" width="120" align="center">
+ <template slot-scope="scope">
+ {{ dateOnly(scope.row.endtime) }}
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="nurseName"
+ label="璐d换鎶ゅ+"
+ width="100"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ prop="drname"
+ label="涓绘不鍖荤敓"
+ width="100"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column label="缁撴灉鐘舵��" width="120" align="center">
+ <template slot-scope="scope">
+ <dict-tag
+ :options="(dict.type && dict.type.sys_yujing) || []"
+ :value="scope.row.excep"
+ />
+ </template>
+ </el-table-column>
+ <el-table-column label="澶勭悊鎰忚" width="120" align="center">
+ <template slot-scope="scope">
+ <dict-tag
+ :options="(dict.type && dict.type.sys_suggest) || []"
+ :value="scope.row.suggest"
+ />
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="templatename"
+ label="鏈嶅姟妯℃澘"
+ width="170"
+ align="center"
+ show-overflow-tooltip
+ />
+ <el-table-column
+ prop="remark"
+ label="鏈嶅姟璁板綍"
+ width="180"
+ align="center"
+ show-overflow-tooltip
+ />
+ </el-table>
+
+ <div class="patient-pagination" v-if="total > pageSize">
+ <el-pagination
+ background
+ layout="total, sizes, prev, pager, next"
+ :current-page="pageNum"
+ :page-size="pageSize"
+ :page-sizes="[10, 20, 50, 100]"
+ :total="total"
+ @size-change="handleSizeChange"
+ @current-change="handlePageChange"
+ />
+ </div>
+ </div>
+</template>
+
+<script>
+import ExcelJS from "exceljs";
+import { saveAs } from "file-saver";
+
+export default {
+ name: "FollowupPatientTable",
+ dicts: ["sys_yujing", "sys_suggest"],
+ props: {
+ rows: {
+ type: Array,
+ default: () => [],
+ },
+ loading: {
+ type: Boolean,
+ default: false,
+ },
+ meta: {
+ type: Object,
+ default: () => ({}),
+ },
+ },
+ data() {
+ return {
+ pageNum: 1,
+ pageSize: 20,
+ };
+ },
+ computed: {
+ total() {
+ return (this.rows || []).length;
+ },
+ pagedRows() {
+ const start = (this.pageNum - 1) * this.pageSize;
+ return (this.rows || []).slice(start, start + this.pageSize);
+ },
+ visitLabel() {
+ return this.meta.visitCount === 2 ? "鍐嶆闅忚" : "棣栨闅忚";
+ },
+ },
+ watch: {
+ rows() {
+ this.pageNum = 1;
+ },
+ },
+ methods: {
+ handleSizeChange(size) {
+ this.pageSize = size;
+ this.pageNum = 1;
+ },
+ handlePageChange(page) {
+ this.pageNum = page;
+ },
+ dateTime(value) {
+ return value ? this.parseTime(value) : "";
+ },
+ dateOnly(value) {
+ return value ? this.formatTime(value) : "";
+ },
+ stateTagType(state) {
+ const map = {
+ 1: "primary",
+ 2: "primary",
+ 3: "success",
+ 4: "info",
+ 5: "danger",
+ 6: "success",
+ 7: "danger",
+ };
+ return map[state] || "info";
+ },
+ stateText(state) {
+ const map = {
+ 1: "琛ㄥ崟宸查鍙�",
+ 2: "寰呴殢璁�",
+ 3: "琛ㄥ崟宸插彂閫�",
+ 4: "涓嶆墽琛�",
+ 5: "鍙戦�佸け璐�",
+ 6: "宸插畬鎴�",
+ 7: "瓒呮椂",
+ };
+ return map[state] || "鏈煡鐘舵��";
+ },
+ preachformText(value) {
+ if (!value) return "";
+ const values = Array.isArray(value)
+ ? value
+ : String(value).split(",");
+ const options = this.$store.getters.checkboxlist || [];
+
+ return values
+ .map((val) => {
+ const found = options.find((item) => item.value == val);
+ return found ? found.label : val;
+ })
+ .filter(Boolean)
+ .join("銆�");
+ },
+ dictLabel(type, value) {
+ const options = (this.dict && this.dict.type && this.dict.type[type]) || [];
+ const found = options.find((item) => item.value == value);
+ return found ? found.label : value || "";
+ },
+ fileDate() {
+ const now = new Date();
+ const pad = (val) => String(val).padStart(2, "0");
+ return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(
+ now.getDate()
+ )}`;
+ },
+ async exportExcel() {
+ if (!this.total) {
+ this.$message.warning("鏆傛棤鍙鍑虹殑鏁版嵁");
+ return;
+ }
+
+ try {
+ const workbook = new ExcelJS.Workbook();
+ const worksheet = workbook.addWorksheet("鎮h�呴殢璁夸俊鎭〃鍗�");
+ const headers = [
+ "濮撳悕",
+ "鑱旂郴鐢佃瘽",
+ "浠诲姟鍚嶇О",
+ "浠诲姟鐘舵��",
+ "浠诲姟鎵ц鏂瑰紡",
+ "搴旈殢璁挎椂闂�",
+ "闅忚瀹屾垚鏃堕棿",
+ "鍑洪櫌鏃ユ湡",
+ "璐d换鎶ゅ+",
+ "涓绘不鍖荤敓",
+ "缁撴灉鐘舵��",
+ "澶勭悊鎰忚",
+ "鏈嶅姟妯℃澘",
+ "鏈嶅姟璁板綍",
+ ];
+ const colCount = headers.length;
+ const 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, colCount);
+ const titleCell = worksheet.getCell(1, 1);
+ titleCell.value = `鎮h�呴殢璁夸俊鎭〃鍗曪紙${this.visitLabel}锛塦;
+ titleCell.font = { size: 14, bold: true };
+ titleCell.alignment = { horizontal: "center", vertical: "middle" };
+ worksheet.getRow(1).height = 30;
+
+ worksheet.mergeCells(2, 1, 2, colCount);
+ const metaCell = worksheet.getCell(2, 1);
+ metaCell.value = `鏃堕棿锛�${
+ this.meta.dateRangeText || "鍏ㄩ儴"
+ } 鍏� ${this.total} 鏉;
+ metaCell.alignment = { horizontal: "left", vertical: "middle" };
+ worksheet.getRow(2).height = 22;
+
+ const headerRow = worksheet.addRow(headers);
+ headerRow.height = 24;
+ headerRow.eachCell((cell) => {
+ cell.font = { bold: true };
+ cell.fill = {
+ type: "pattern",
+ pattern: "solid",
+ fgColor: { argb: "FFF5F7FA" },
+ };
+ cell.border = border;
+ cell.alignment = { horizontal: "center", vertical: "middle" };
+ });
+
+ (this.rows || []).forEach((row) => {
+ const dataRow = worksheet.addRow([
+ row.sendname || "",
+ row.telcode || "",
+ row.taskName || "",
+ this.stateText(row.sendstate),
+ this.preachformText(row.preachform),
+ row.visitTime || "",
+ row.finishtime ? this.parseTime(row.finishtime) : "",
+ row.endtime ? this.formatTime(row.endtime) : "",
+ row.nurseName || "",
+ row.drname || "",
+ this.dictLabel("sys_yujing", row.excep),
+ this.dictLabel("sys_suggest", row.suggest),
+ row.templatename || "",
+ row.remark || "",
+ ]);
+ dataRow.height = 22;
+ dataRow.eachCell((cell) => {
+ cell.border = border;
+ cell.alignment = {
+ horizontal: "center",
+ vertical: "middle",
+ wrapText: true,
+ };
+ });
+ });
+
+ worksheet.columns = [
+ { width: 12 },
+ { width: 15 },
+ { width: 28 },
+ { width: 12 },
+ { width: 20 },
+ { width: 20 },
+ { width: 20 },
+ { width: 14 },
+ { width: 12 },
+ { width: 12 },
+ { width: 12 },
+ { width: 12 },
+ { width: 28 },
+ { width: 30 },
+ ];
+
+ const buffer = await workbook.xlsx.writeBuffer();
+ const blob = new Blob([buffer], {
+ type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ });
+ saveAs(
+ blob,
+ `鎮h�呴殢璁夸俊鎭〃鍗昣${this.visitLabel}_${this.fileDate()}.xlsx`
+ );
+ this.$message.success("瀵煎嚭鎴愬姛");
+ } catch (error) {
+ console.error("瀵煎嚭鎮h�呴殢璁夸俊鎭〃鍗曞け璐�:", error);
+ this.$message.error("瀵煎嚭澶辫触");
+ }
+ },
+ },
+};
+</script>
+
+<style lang="scss" scoped>
+.followup-patient {
+ padding: 4px 0 8px;
+ min-height: 240px;
+
+ .patient-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: 12px;
+ margin-bottom: 12px;
+ }
+
+ .patient-title {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 15px;
+ font-weight: 600;
+ color: #303133;
+ }
+
+ .patient-header-right {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ }
+
+ .patient-meta {
+ font-size: 13px;
+ color: #606266;
+
+ b {
+ color: #303133;
+ }
+ }
+
+ .patient-pagination {
+ display: flex;
+ justify-content: flex-end;
+ margin-top: 14px;
+ }
+
+ ::v-deep .el-table th {
+ background-color: #f8f9fa;
+ }
+}
+</style>
diff --git a/src/views/sfstatistics/percentage/components/SecondFollowUp.vue b/src/views/sfstatistics/percentage/components/SecondFollowUp.vue
index f49c5f4..0cf51b5 100644
--- a/src/views/sfstatistics/percentage/components/SecondFollowUp.vue
+++ b/src/views/sfstatistics/percentage/components/SecondFollowUp.vue
@@ -929,7 +929,7 @@
delete params.deptcodes.all;
params.rateDay = this.orgname == "榫欐硥甯備汉姘戝尰闄�" ? 21 : 7;
- getSfStatistics(params)
+ return getSfStatistics(params)
.then((response) => {
this.tableData = this.customSort(response.data);
})
diff --git a/src/views/sfstatistics/percentage/followupAnalysisMixin.js b/src/views/sfstatistics/percentage/followupAnalysisMixin.js
new file mode 100644
index 0000000..94b46f8
--- /dev/null
+++ b/src/views/sfstatistics/percentage/followupAnalysisMixin.js
@@ -0,0 +1,427 @@
+import ExcelJS from "exceljs";
+import { getSfStatisticsHyperlink } from "@/api/AiCentre/satisfactionse";
+import { exportPatItem } from "@/api/AiCentre/SingleTask";
+
+// 鍑洪櫌闅忚鍒嗘瀽锛氬凡瀹屾垚鎮h�呮槑缁� + 鍚庣瀵煎嚭 Excel 涓殑銆岄棶棰樿鎯呭崰姣斻�嶉鐩粺璁�
+export default {
+ data() {
+ return {
+ analysisVisitCount: 1,
+ analysisLoaded: false,
+ followupRows: [],
+ followupRowsLoading: false,
+ followupRowsPromise: null,
+ followupTopics: [],
+ followupTopicLoading: false,
+ followupQuestionLoaded: false,
+ followupQuestionLoading: false,
+ followupQuestionSeq: 0,
+ followupRowsSeq: 0,
+ followupExportTaskName: "",
+ followupPatientMeta: {
+ visitCount: 1,
+ total: 0,
+ dateRangeText: "",
+ },
+ };
+ },
+ computed: {
+ followupTaskName() {
+ if (this.followupExportTaskName) {
+ return this.followupExportTaskName;
+ }
+ const names = [
+ ...new Set(
+ (this.followupRows || [])
+ .map((row) => row.taskName)
+ .filter(Boolean)
+ ),
+ ];
+ if (!names.length) return "";
+ if (names.length === 1) return names[0];
+ return `${names[0]} 绛�${names.length}涓换鍔;
+ },
+ },
+ created() {
+ this.loadFollowupAnalysis();
+ },
+ methods: {
+ setAnalysisVisitCount(count) {
+ if (this.analysisVisitCount === count) return;
+ this.analysisVisitCount = count;
+ this.analysisLoaded = false;
+ this.loadFollowupAnalysis(true);
+ },
+
+ loadFollowupAnalysis(force = false) {
+ if (this.analysisLoaded && !force) return Promise.resolve();
+ this.analysisLoaded = true;
+ this.resetFollowupQuestions();
+ this.followupExportTaskName = "";
+ return this.fetchFollowupPatients();
+ },
+
+ resetFollowupQuestions() {
+ this.followupQuestionSeq += 1;
+ this.followupTopics = [];
+ this.followupQuestionLoaded = false;
+ this.followupQuestionLoading = false;
+ this.followupTopicLoading = false;
+ },
+
+ ensureFollowupQuestionStats() {
+ if (this.followupQuestionLoaded || this.followupQuestionLoading) return;
+ this.loadFollowupQuestionStats();
+ },
+
+ // 鐩存帴瑙f瀽鍚庣瀵煎嚭 Excel 鐨勩�岄棶棰樿鎯呭崰姣斻�峴heet锛屼繚璇佸拰瀵煎嚭鏂囦欢瀹屽叏涓�鑷�
+ loadFollowupQuestionStats() {
+ if (this.followupQuestionLoading || this.followupQuestionLoaded) return;
+
+ this.followupQuestionLoading = true;
+ this.followupTopicLoading = true;
+ const seq = ++this.followupQuestionSeq;
+ const params = this.buildQuestionExportParams();
+
+ exportPatItem(params)
+ .then(async (data) => {
+ if (seq !== this.followupQuestionSeq) return;
+
+ const buffer =
+ data && typeof data.arrayBuffer === "function"
+ ? await data.arrayBuffer()
+ : data;
+ const workbook = new ExcelJS.Workbook();
+ await workbook.xlsx.load(buffer);
+
+ if (seq !== this.followupQuestionSeq) return;
+
+ const result = this.parseQuestionSheet(workbook);
+ this.followupTopics = result.topics;
+ this.followupExportTaskName = result.taskName;
+ this.followupQuestionLoaded = true;
+ })
+ .catch((error) => {
+ if (seq !== this.followupQuestionSeq) return;
+ console.error("瑙f瀽闅忚瀵煎嚭 Excel 棰樼洰澶辫触:", error);
+ this.followupTopics = [];
+ })
+ .finally(() => {
+ if (seq !== this.followupQuestionSeq) return;
+ this.followupQuestionLoading = false;
+ this.followupTopicLoading = false;
+ });
+ },
+
+ buildQuestionExportParams() {
+ const base = this.analysisBaseParams();
+ const range = this.queryParams.dateRangecy || [];
+ const dateOnly = (value) => {
+ if (!value) return undefined;
+ if (typeof value === "string") return value.slice(0, 10);
+ return this.parseTime(value, "{y}-{m}-{d}");
+ };
+ const serviceType = Array.isArray(this.queryParams.serviceType)
+ ? this.queryParams.serviceType[0]
+ : this.queryParams.serviceType;
+
+ return {
+ sendstateView: 2,
+ sort: 1,
+ serviceType: serviceType || 2,
+ searchscope: 3,
+ visitCount: this.analysisVisitCount,
+ leaveldeptcodes: base.depts,
+ leavehospitaldistrictcodes: base.wards,
+ deptOrDistrict: 2,
+ startOutHospTime: dateOnly(range[0]),
+ endOutHospTime: dateOnly(range[1]),
+ };
+ },
+
+ parseQuestionSheet(workbook) {
+ const sheet =
+ workbook.getWorksheet("闂璇︽儏鍗犳瘮") ||
+ (workbook.worksheets || []).find(
+ (item) => item && String(item.name).includes("闂璇︽儏鍗犳瘮")
+ ) ||
+ (workbook.worksheets || [])[1];
+
+ if (!sheet) {
+ return { topics: [], taskName: "" };
+ }
+
+ let headerRowNumber = 1;
+ const scanLimit = Math.min(20, sheet.rowCount || 0);
+ for (let rowNumber = 1; rowNumber <= scanLimit; rowNumber++) {
+ const firstText = this.cellText(
+ sheet.getRow(rowNumber).getCell(1)
+ );
+ if (firstText.includes("闂鍐呭")) {
+ headerRowNumber = rowNumber;
+ break;
+ }
+ }
+
+ const headerRow = sheet.getRow(headerRowNumber);
+ const header = {};
+ for (let column = 1; column <= (headerRow.cellCount || 0); column++) {
+ const name = this.cellText(headerRow.getCell(column));
+ if (name) header[name] = column;
+ }
+
+ const questionColumn = header["闂鍐呭"] || 1;
+ const optionColumn = header["閫夐」缁撴灉"] || header["閫夐」"] || 2;
+ const countColumn = header["鏁伴噺"] || 3;
+ const taskColumn = header["浠诲姟鍚嶇О"] || 7;
+
+ const questionMap = new Map();
+ const taskNames = new Set();
+
+ for (
+ let rowNumber = headerRowNumber + 1;
+ rowNumber <= (sheet.rowCount || 0);
+ rowNumber++
+ ) {
+ const row = sheet.getRow(rowNumber);
+ const question = this.cellText(row.getCell(questionColumn));
+ if (!question) continue;
+ if (question.includes("鍚堣") || question.includes("鎬昏")) continue;
+
+ const option = this.cellText(row.getCell(optionColumn));
+ const count = Number(this.cellText(row.getCell(countColumn))) || 0;
+ const taskName = taskColumn
+ ? this.cellText(row.getCell(taskColumn))
+ : "";
+ if (taskName) taskNames.add(taskName);
+
+ if (!questionMap.has(question)) {
+ questionMap.set(question, {
+ scriptid: question,
+ scriptContent: question,
+ scriptType: 1,
+ optionOrder: [],
+ optionMap: new Map(),
+ });
+ }
+ const topic = questionMap.get(question);
+ if (option && !topic.optionMap.has(option)) {
+ topic.optionMap.set(option, { optionText: option, count: 0 });
+ topic.optionOrder.push(option);
+ }
+ if (option) {
+ topic.optionMap.get(option).count += count;
+ }
+ }
+
+ const topics = Array.from(questionMap.values())
+ .map((topic) => {
+ const total = topic.optionOrder.reduce(
+ (sum, option) =>
+ sum + (topic.optionMap.get(option).count || 0),
+ 0
+ );
+ return {
+ scriptid: topic.scriptid,
+ scriptContent: topic.scriptContent,
+ scriptType: topic.scriptType,
+ details: topic.optionOrder.map((option) => {
+ const item = topic.optionMap.get(option);
+ return {
+ optionText: option,
+ chosenQuantity: item.count,
+ chosenPercentage: total ? item.count / total : 0,
+ };
+ }),
+ };
+ })
+ .filter((topic) => topic.details.length > 0);
+
+ const names = Array.from(taskNames);
+ const taskName = names.length
+ ? names.length === 1
+ ? names[0]
+ : `${names[0]} 绛�${names.length}涓换鍔
+ : "";
+
+ return { topics, taskName };
+ },
+
+ cellText(cell) {
+ if (!cell) return "";
+ const value = cell.value;
+ if (value === null || value === undefined) return "";
+
+ if (typeof value === "object") {
+ if (Array.isArray(value.richText)) {
+ return value.richText
+ .map((item) => item.text || "")
+ .join("")
+ .trim();
+ }
+ if (value.text !== undefined) {
+ return String(value.text).trim();
+ }
+ if (value.result !== undefined) {
+ return String(value.result).trim();
+ }
+ if (value instanceof Date) {
+ return this.parseTime(value);
+ }
+ }
+
+ return String(value).trim();
+ },
+
+ analysisBaseParams() {
+ const query = this.queryParams || {};
+ const stat = query.statisticaltype;
+ const wards = this.pickAnalysisCodes(
+ query.leavehospitaldistrictcodes,
+ this.$store.getters.belongWards,
+ "districtCode"
+ );
+ const depts = this.pickAnalysisCodes(
+ query.deptcodes,
+ this.$store.getters.belongDepts,
+ "deptCode"
+ );
+ const parseDate = (value) => (value ? this.parseTime(value) : undefined);
+
+ return {
+ stat,
+ wards,
+ depts,
+ serviceType: query.serviceType,
+ startTime:
+ query.startTime || parseDate((query.dateRange || [])[0]),
+ endTime: query.endTime || parseDate((query.dateRange || [])[1]),
+ hospitalStartTime:
+ query.hospitalStartTime ||
+ parseDate((query.dateRangecy || [])[0]),
+ hospitalEndTime:
+ query.hospitalEndTime || parseDate((query.dateRangecy || [])[1]),
+ };
+ },
+
+ pickAnalysisCodes(selected, allList, codeKey) {
+ const raw = selected || [];
+ if (!raw.length || raw.includes("all")) {
+ return (allList || []).map((item) => item[codeKey]).filter(Boolean);
+ }
+ return raw.filter((code) => code && code !== "all");
+ },
+
+ fetchFollowupPatients() {
+ const base = this.analysisBaseParams();
+ const infoKey =
+ this.analysisVisitCount === 2
+ ? "followUpSuccessAgainInfo"
+ : "followUpSuccessInfo";
+
+ this.followupRowsLoading = true;
+ const seq = ++this.followupRowsSeq;
+ const params = {
+ hyperLinkInfoType: infoKey,
+ serviceType: base.serviceType,
+ hospitalStartTime: base.hospitalStartTime,
+ hospitalEndTime: base.hospitalEndTime,
+ statisticaltype: base.stat,
+ leavehospitaldistrictcodes: base.stat === 1 ? base.wards : [],
+ deptcodes: base.stat === 2 ? base.depts : [],
+ };
+
+ const request = getSfStatisticsHyperlink(params);
+ this.followupRowsPromise = request;
+
+ return request
+ .then((response) => {
+ if (seq !== this.followupRowsSeq) return;
+ const rows = Array.isArray(response.data)
+ ? response.data
+ : [];
+ const filtered = this.filterFollowupRows(rows);
+ this.followupRows = filtered;
+ this.followupPatientMeta = {
+ visitCount: this.analysisVisitCount,
+ total: filtered.length,
+ dateRangeText: this.analysisDateRangeText(),
+ };
+ })
+ .catch((error) => {
+ if (seq !== this.followupRowsSeq) return;
+ console.error("鑾峰彇鍑洪櫌闅忚鎮h�呮槑缁嗗け璐�:", error);
+ this.followupRows = [];
+ this.followupPatientMeta = {
+ visitCount: this.analysisVisitCount,
+ total: 0,
+ dateRangeText: this.analysisDateRangeText(),
+ };
+ })
+ .finally(() => {
+ if (seq !== this.followupRowsSeq) return;
+ this.followupRowsLoading = false;
+ });
+ },
+
+ filterFollowupRows(rows) {
+ const dischargeRange = this.queryParams.dateRangecy || [];
+
+ return (rows || []).filter((row) => {
+ // 鍙繚鐣欏凡瀹屾垚鐨勪换鍔�
+ if (row.sendstate != 6) {
+ return false;
+ }
+ if (
+ dischargeRange.length === 2 &&
+ dischargeRange[0] &&
+ dischargeRange[1] &&
+ !this.inDateRange(row.endtime, dischargeRange)
+ ) {
+ return false;
+ }
+ return true;
+ });
+ },
+
+ inDateRange(value, range) {
+ if (!value) return false;
+
+ const toTime = (val) => {
+ if (!val) return NaN;
+ const date = new Date(String(val).replace(/-/g, "/"));
+ return date.getTime();
+ };
+
+ const time = toTime(value);
+ if (isNaN(time)) return false;
+
+ const start = toTime(range[0]);
+ let end = toTime(range[1]);
+ if (isNaN(start) || isNaN(end)) return true;
+
+ // 鏃ユ湡鑼冨洿鍙埌澶╂椂锛岀粨鏉熸棩鏈熸寜褰撳ぉ 23:59:59 澶勭悊
+ if (String(range[1]).length <= 10) {
+ end += 24 * 60 * 60 * 1000 - 1;
+ }
+
+ return time >= start && time <= end;
+ },
+
+ analysisDateRangeText() {
+ const discharge = this.formatDateRange(this.queryParams.dateRangecy);
+ return `鍑洪櫌鏃堕棿锛�${discharge}`;
+ },
+
+ formatDateRange(range) {
+ const list = range || [];
+ if (list.length === 2 && list[0] && list[1]) {
+ return `${String(list[0]).slice(0, 10)} 鑷� ${String(list[1]).slice(
+ 0,
+ 10
+ )}`;
+ }
+ return "鍏ㄩ儴";
+ },
+ },
+};
diff --git a/src/views/sfstatistics/percentage/index.vue b/src/views/sfstatistics/percentage/index.vue
index 9171a12..83946c0 100644
--- a/src/views/sfstatistics/percentage/index.vue
+++ b/src/views/sfstatistics/percentage/index.vue
@@ -172,6 +172,63 @@
/>
</el-tab-pane>
+ <!-- 鍑洪櫌闅忚鍒嗘瀽锛氭偅鑰呰〃鍗� + 闅忚闂嵎棰樼洰鍗犳瘮锛堣〃/鏌辩姸鍥�/楗煎浘锛� -->
+ <el-tab-pane label="鎮h�呴殢璁夸俊鎭〃鍗�" name="followupForm">
+ <div v-if="followupTaskName" class="analysis-task-title">
+ 浠诲姟鍚嶇О锛歿{ followupTaskName }}
+ </div>
+ <followup-patient-table
+ v-if="activeTab === 'followupForm'"
+ ref="followupFormRef"
+ :rows="followupRows"
+ :meta="followupPatientMeta"
+ :loading="followupRowsLoading"
+ />
+ </el-tab-pane>
+ <el-tab-pane label="闂璇︽儏鍗犳瘮" name="followupRatio">
+ <div v-if="followupTaskName" class="analysis-task-title">
+ 浠诲姟鍚嶇О锛歿{ followupTaskName }}
+ </div>
+ <question-ratio-table
+ v-if="activeTab === 'followupRatio'"
+ ref="followupRatioRef"
+ hide-index
+ hide-type
+ :topic-list="followupTopics"
+ :loading="followupTopicLoading"
+ />
+ </el-tab-pane>
+ <el-tab-pane label="闂璇︽儏鍗犳瘮鍥捐〃" name="followupBar">
+ <div v-if="followupTaskName" class="analysis-task-title">
+ 浠诲姟鍚嶇О锛歿{ followupTaskName }}
+ </div>
+ <question-chart
+ v-if="activeTab === 'followupBar'"
+ ref="followupBarRef"
+ view="bar"
+ hide-index
+ :columns="2"
+ :chart-height="320"
+ :topic-list="followupTopics"
+ :loading="followupTopicLoading"
+ />
+ </el-tab-pane>
+ <el-tab-pane label="闂璇︽儏鍗犳瘮楗煎浘" name="followupPie">
+ <div v-if="followupTaskName" class="analysis-task-title">
+ 浠诲姟鍚嶇О锛歿{ followupTaskName }}
+ </div>
+ <question-chart
+ v-if="activeTab === 'followupPie'"
+ ref="followupPieRef"
+ view="pie"
+ hide-index
+ :columns="2"
+ :chart-height="320"
+ :topic-list="followupTopics"
+ :loading="followupTopicLoading"
+ />
+ </el-tab-pane>
+
<el-tab-pane
label="寤剁画鎶ょ悊缁熻"
name="continued"
@@ -230,10 +287,15 @@
import DetailDialog from "./components/DetailDialog.vue";
import TimelyRateDialog from "./components/TimelyRateDialog.vue";
import CombinedFollowUp from "./components/CombinedFollowUp.vue";
+import FollowupPatientTable from "./components/FollowupPatientTable.vue";
+import QuestionRatioTable from "@/views/Satisfaction/sfstatistics/components/QuestionRatioTable.vue";
+import QuestionChart from "@/views/Satisfaction/sfstatistics/components/QuestionChart.vue";
+import followupAnalysisMixin from "./followupAnalysisMixin";
import { getSfStatisticsHyperlink } from "@/api/AiCentre/index";
export default {
name: "Percentage",
+ mixins: [followupAnalysisMixin],
components: {
FirstFollowUp,
SecondFollowUp,
@@ -242,6 +304,9 @@
DetailDialog,
TimelyRateDialog,
CombinedFollowUp,
+ FollowupPatientTable,
+ QuestionRatioTable,
+ QuestionChart,
},
data() {
return {
@@ -386,6 +451,17 @@
},
handleTabClick(tab) {
this.activeTab = tab.name;
+ if (tab.name === "first") {
+ this.setAnalysisVisitCount(1);
+ } else if (tab.name === "second") {
+ this.setAnalysisVisitCount(2);
+ } else if (tab.name === "followupForm") {
+ this.loadFollowupAnalysis();
+ } else if (
+ ["followupRatio", "followupBar", "followupPie"].includes(tab.name)
+ ) {
+ this.ensureFollowupQuestionStats();
+ }
this.loadCurrentTabData();
},
@@ -427,6 +503,16 @@
}
this.loadCurrentTabData();
+ const promise = this.loadFollowupAnalysis(true);
+ if (
+ ["followupRatio", "followupBar", "followupPie"].includes(
+ this.activeTab
+ )
+ ) {
+ if (promise && typeof promise.then === "function") {
+ promise.then(() => this.loadFollowupQuestionStats());
+ }
+ }
},
resetQuery() {
@@ -448,6 +534,18 @@
break;
case "combined":
await this.$refs.combinedFollowUp.exportTable();
+ break;
+ case "followupForm":
+ await this.$refs.followupFormRef.exportExcel();
+ break;
+ case "followupRatio":
+ await this.$refs.followupRatioRef.exportExcel();
+ break;
+ case "followupBar":
+ await this.$refs.followupBarRef.exportExcel();
+ break;
+ case "followupPie":
+ await this.$refs.followupPieRef.exportExcel();
break;
}
},
@@ -576,6 +674,13 @@
border: 1px solid #dcdfe6;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12), 0 0 6px 0 rgba(0, 0, 0, 0.04);
+ .analysis-task-title {
+ margin-bottom: 10px;
+ font-size: 14px;
+ font-weight: 600;
+ color: #303133;
+ }
+
.search-section {
margin-bottom: 20px;
}
diff --git a/src/views/sfstatistics/percentage/satisfactionAnalysisMixin.js b/src/views/sfstatistics/percentage/satisfactionAnalysisMixin.js
new file mode 100644
index 0000000..d78153d
--- /dev/null
+++ b/src/views/sfstatistics/percentage/satisfactionAnalysisMixin.js
@@ -0,0 +1,154 @@
+import { getTaskservelist } from "@/api/AiCentre/SingleTask";
+import { getSfStatisticsJoyInfo } from "@/api/system/user";
+
+// 闅忚缁熻椤靛鐢ㄧ殑婊℃剰搴﹀垎鏋愭暟鎹紙涓庢弧鎰忓害缁熻椤甸粯璁ゅ彛寰勪竴鑷达細绂婚櫌銆佺梾鍖恒�佹湇鍔$被鍨� 6锛�
+export default {
+ data() {
+ return {
+ satisfactionRows: [],
+ satisfactionRowsLoading: false,
+ satisfactionTopics: [],
+ satisfactionTopicsLoading: false,
+ satisfactionMeta: {
+ dimension: "ward",
+ scope: "leave",
+ dateRange: [],
+ total: 0,
+ },
+ satisfactionLoaded: false,
+ };
+ },
+ computed: {
+ satisfactionDetailMeta() {
+ return {
+ ...this.satisfactionMeta,
+ groupLabel: "鍏ㄩ儴",
+ };
+ },
+ },
+ created() {
+ this.loadSatisfactionAnalysis();
+ },
+ methods: {
+ loadSatisfactionAnalysis(force = false) {
+ if (this.satisfactionLoaded && !force) return;
+ this.satisfactionLoaded = true;
+ this.fetchSatisfactionRows();
+ this.fetchSatisfactionTopics();
+ },
+
+ analysisScope() {
+ const depts = (this.$store.getters.belongDepts || [])
+ .map((dept) => dept.deptCode)
+ .filter(Boolean);
+ const wards = (this.$store.getters.belongWards || [])
+ .map((ward) => ward.districtCode)
+ .filter(Boolean);
+ return { depts, wards };
+ },
+
+ fetchSatisfactionRows() {
+ const { depts, wards } = this.analysisScope();
+ if (!depts.length && !wards.length) {
+ this.satisfactionRows = [];
+ this.satisfactionMeta = {
+ ...this.satisfactionMeta,
+ total: 0,
+ };
+ return;
+ }
+
+ this.satisfactionRowsLoading = true;
+ const payload = {
+ pageNum: null,
+ pageSize: null,
+ sendstate: null,
+ sendstateView: 2,
+ sort: 2,
+ serviceType: 6,
+ searchscope: 3,
+ visitCount: 1,
+ scopetype: [],
+ deptOrDistrict: depts.length && wards.length ? 2 : 1,
+ leaveldeptcodes: depts,
+ leavehospitaldistrictcodes: wards,
+ };
+
+ getTaskservelist(payload)
+ .then((response) => {
+ const rows = this.pickSatisfactionRows(response);
+ this.satisfactionRows = rows;
+ this.satisfactionMeta = {
+ dimension: "ward",
+ scope: "leave",
+ dateRange: [],
+ total: rows.length,
+ };
+ })
+ .catch((error) => {
+ console.error("闅忚缁熻椤佃幏鍙栨弧鎰忓害鎮h�呮槑缁嗗け璐�:", error);
+ this.satisfactionRows = [];
+ })
+ .finally(() => {
+ this.satisfactionRowsLoading = false;
+ });
+ },
+
+ fetchSatisfactionTopics() {
+ const { wards } = this.analysisScope();
+ if (!wards.length) {
+ this.satisfactionTopics = [];
+ return;
+ }
+
+ this.satisfactionTopicsLoading = true;
+ const payload = {
+ configKey: "joyCount",
+ statisticaltype: 1,
+ serviceType: [6],
+ pageNum: 1,
+ pageSize: 999,
+ leavehospitaldistrictcodes: wards,
+ };
+
+ getSfStatisticsJoyInfo(payload)
+ .then((response) => {
+ this.satisfactionTopics = response.data || [];
+ })
+ .catch((error) => {
+ console.error("闅忚缁熻椤佃幏鍙栨弧鎰忓害闂璇︽儏澶辫触:", error);
+ this.satisfactionTopics = [];
+ })
+ .finally(() => {
+ this.satisfactionTopicsLoading = false;
+ });
+ },
+
+ pickSatisfactionRows(response) {
+ if (!response) return [];
+
+ const rowsWrap = response.rows || (response.data && response.data.rows);
+ let list = [];
+
+ if (Array.isArray(rowsWrap) && rowsWrap[0]) {
+ list =
+ rowsWrap[0].serviceSubtaskList ||
+ (rowsWrap[0].sendname ? rowsWrap : []);
+ } else if (Array.isArray(response.data)) {
+ list = response.data;
+ }
+
+ return (list || [])
+ .filter(Boolean)
+ .map((row) => this.normalizeSatisfactionRow(row));
+ },
+
+ normalizeSatisfactionRow(row) {
+ const item = { ...row };
+ if (item.endtime) {
+ item.endDay = this.daysBetween(item.endtime);
+ }
+ return item;
+ },
+ },
+};
--
Gitblit v1.9.3