| | |
| | | label-width="100px" |
| | | class="query-form" |
| | | > |
| | | <el-form-item label="满意度类型" prop="satisfactionScope"> |
| | | <el-select |
| | | v-model="satisfactionScope" |
| | | placeholder="默认在院" |
| | | clearable |
| | | style="width: 150px" |
| | | @change="handleSatisfactionScopeChange" |
| | | > |
| | | <el-option label="离院满意度" value="leave" /> |
| | | <el-option label="在院满意度" value="hospital" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="统计类型" prop="statisticaltype"> |
| | | <el-select |
| | | v-model="queryParams.statisticaltype" |
| | |
| | | @selection-change="handleSelectionChange" |
| | | :row-key="getRowKey" |
| | | > |
| | | <!-- 病区列 --> |
| | | <!-- 病区统计:在院病区 + 离院病区 --> |
| | | <el-table-column |
| | | v-if="queryParams.statisticaltype == 1" |
| | | label="出院病区" |
| | | label="在院病区" |
| | | align="center" |
| | | sortable |
| | | key="hospitaldistrictname" |
| | | prop="hospitaldistrictname" |
| | | :show-overflow-tooltip="true" |
| | | :sort-method="sortHospitalWard" |
| | | min-width="120" |
| | | > |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.hospitaldistrictname || "-" }} |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column |
| | | v-if="queryParams.statisticaltype == 1" |
| | | label="离院病区" |
| | | align="center" |
| | | sortable |
| | | key="leavehospitaldistrictname" |
| | | prop="leavehospitaldistrictname" |
| | | :show-overflow-tooltip="true" |
| | | :sort-method="sortChineseNumber" |
| | | :sort-method="sortLeaveWard" |
| | | min-width="120" |
| | | /> |
| | | > |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.leavehospitaldistrictname || "-" }} |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <!-- 科室列 --> |
| | | <!-- 科室统计:在院科室 + 离院科室 --> |
| | | <el-table-column |
| | | v-if="queryParams.statisticaltype == 2" |
| | | label="科室" |
| | | label="在院科室" |
| | | align="center" |
| | | key="hospitaldeptname" |
| | | prop="hospitaldeptname" |
| | | :show-overflow-tooltip="true" |
| | | min-width="120" |
| | | > |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.hospitaldeptname || "-" }} |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column |
| | | v-if="queryParams.statisticaltype == 2" |
| | | label="离院科室" |
| | | align="center" |
| | | key="deptname" |
| | | prop="deptname" |
| | | :show-overflow-tooltip="true" |
| | | min-width="120" |
| | | /> |
| | | > |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.deptname || "-" }} |
| | | </template> |
| | | </el-table-column> |
| | | |
| | | <el-table-column |
| | | label="出院人次" |
| | |
| | | :row-data="currentRow" |
| | | :topicList="topiclist" |
| | | :query-params="queryParams" |
| | | :topType="2" |
| | | @close="topicVisible = false" |
| | | /> |
| | | </el-dialog> |
| | |
| | | } 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"; |
| | | |
| | |
| | | SeedetailsDialog, |
| | | TopicDialog, |
| | | }, |
| | | props: { |
| | | // 是否在顶部生成患者表单 / 问题详情分析 tab(仅满意度统计主页开启) |
| | | showAnalysisTabs: { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | // 满意度类型:leave=离院满意度(按出院病区统计),hospital=在院满意度(按在院病区统计) |
| | | // 默认离院满意度 |
| | | satisfactionScope: "leave", |
| | | |
| | | // 查询参数 |
| | | queryParams: { |
| | | statisticaltype: 1, |
| | | leavehospitaldistrictcodes: ["all"], |
| | | deptcodes: [], |
| | | serviceType: [2], |
| | | // 默认服务类型:6=住院满意度(出入院满意度) |
| | | serviceType: [6], |
| | | dateRange: [], |
| | | pageNum: 1, |
| | | pageSize: 20, |
| | |
| | | flatArraydept: [], |
| | | |
| | | // 服务类型选项 |
| | | options: [], |
| | | options: [ |
| | | { |
| | | value: 6, |
| | | label: "出入院满意度", |
| | | raw: { |
| | | cssClass: "", |
| | | listClass: "", |
| | | }, |
| | | }, |
| | | |
| | | { |
| | | value: 14, |
| | | label: "门诊满意度", |
| | | raw: { |
| | | cssClass: "", |
| | | listClass: "", |
| | | }, |
| | | }, |
| | | ], |
| | | |
| | | // 表格数据 |
| | | userList: [], |
| | |
| | | // 加载状态 |
| | | loading: false, |
| | | orgname: "", |
| | | // 已完成明细请求序号,避免快速切换筛选时旧请求覆盖新结果 |
| | | completedRequestSeq: 0, |
| | | // 问题详情请求序号 |
| | | questionRequestSeq: 0, |
| | | |
| | | // 选中的行 |
| | | ids: [], |
| | |
| | | }; |
| | | }, |
| | | |
| | | computed: { |
| | | // 是否按「在院满意度」口径统计:在院用 hospitaldistrictcodes / hospitaldeptcodes, |
| | | // 离院用 leavehospitaldistrictcodes / leaveldeptcodes |
| | | // 默认在院,所以清空下拉时仍按在院口径处理 |
| | | 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(); |
| | | // 顶部患者表单 / 问题详情分析 tab:默认按当前统计口径加载一次 |
| | | this.maybeRefreshCompletedGroups(); |
| | | this.maybeRefreshQuestionDetails(); |
| | | }, |
| | | |
| | | methods: { |
| | |
| | | |
| | | // 获取科室树 |
| | | 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 |
| | | ); |
| | | |
| | | // 获取科室列表 |
| | | this.flatArraydept = (this.$store.getters.belongDepts || []).map( |
| | |
| | | params.endTime = this.queryParams.dateRange[1]; |
| | | } |
| | | |
| | | // 处理病区/科室选择 |
| | | // 处理病区/科室选择:只保留当前统计类型 + 当前满意度类型对应的字段, |
| | | // 避免在院/离院两套条件同时拼进 SQL |
| | | if (params.statisticaltype == 1) { |
| | | // 病区统计 |
| | | if (params.leavehospitaldistrictcodes.includes("all")) { |
| | | // 如果选择了"全部",则移除"all"值 |
| | | params.leavehospitaldistrictcodes = |
| | | params.leavehospitaldistrictcodes.filter( |
| | | (item) => item !== "all" |
| | | ); |
| | | // 如果需要传所有病区代码,可以从store中获取 |
| | | params.leavehospitaldistrictcodes = ( |
| | | this.$store.getters.belongWards || [] |
| | | ).map((ward) => ward.districtCode); |
| | | let wardCodes = params.leavehospitaldistrictcodes || []; |
| | | if (wardCodes.includes("all")) { |
| | | // 选择"全部"时不加病区限制,查全部病区 |
| | | wardCodes = []; |
| | | } |
| | | delete params.leavehospitaldistrictcodes; |
| | | delete params.hospitaldistrictcodes; |
| | | delete params.deptcodes; |
| | | delete params.leaveldeptcodes; |
| | | delete params.hospitaldeptcodes; |
| | | if (wardCodes.length) { |
| | | if (this.isInHospitalSatisfaction) { |
| | | params.hospitaldistrictcodes = wardCodes; |
| | | } else { |
| | | params.leavehospitaldistrictcodes = wardCodes; |
| | | } |
| | | } |
| | | } else if (params.statisticaltype == 2) { |
| | | // 科室统计 |
| | | if (params.deptcodes.includes("all")) { |
| | | // 如果选择了"全部",则移除"all"值 |
| | | params.deptcodes = params.deptcodes.filter( |
| | | (item) => item !== "all" |
| | | ); |
| | | // 如果需要传所有科室代码,可以从store中获取 |
| | | params.deptcodes = (this.$store.getters.belongDepts || []).map( |
| | | (dept) => dept.deptCode |
| | | ); |
| | | let deptCodes = params.deptcodes || []; |
| | | if (deptCodes.includes("all")) { |
| | | // 选择"全部"时不加科室限制,查全部科室 |
| | | deptCodes = []; |
| | | } else { |
| | | deptCodes = deptCodes.filter((item) => item !== "all"); |
| | | } |
| | | delete params.deptcodes; |
| | | delete params.leaveldeptcodes; |
| | | delete params.hospitaldeptcodes; |
| | | delete params.leavehospitaldistrictcodes; |
| | | delete params.hospitaldistrictcodes; |
| | | if (deptCodes.length) { |
| | | if (this.isInHospitalSatisfaction) { |
| | | params.hospitaldeptcodes = deptCodes; |
| | | } else { |
| | | params.leaveldeptcodes = deptCodes; |
| | | } |
| | | } |
| | | } |
| | | |
| | | const response = await getSfStatisticsJoy(params); |
| | | this.userList = this.customSort(response.data) || []; |
| | | // 科室统计按接口返回顺序,病区统计保持原有的中文序号排序 |
| | | this.userList = |
| | | this.queryParams.statisticaltype == 1 |
| | | ? this.customSort(response.data) || [] |
| | | : response.data || []; |
| | | this.total = response.total || 0; |
| | | } catch (error) { |
| | | console.error("获取统计列表失败:", error); |
| | |
| | | } |
| | | }, |
| | | sortChineseNumber(aRow, bRow) { |
| | | const a = aRow.leavehospitaldistrictname; |
| | | const b = bRow.leavehospitaldistrictname; |
| | | |
| | | return this.compareWardNames(this.getWardName(aRow), this.getWardName(bRow)); |
| | | }, |
| | | sortHospitalWard(aRow, bRow) { |
| | | return this.compareWardNames( |
| | | aRow && aRow.hospitaldistrictname, |
| | | bRow && bRow.hospitaldistrictname |
| | | ); |
| | | }, |
| | | sortLeaveWard(aRow, bRow) { |
| | | return this.compareWardNames( |
| | | aRow && aRow.leavehospitaldistrictname, |
| | | bRow && bRow.leavehospitaldistrictname |
| | | ); |
| | | }, |
| | | // 比较两个病区名称的中文序号;无序号时按字符串比较 |
| | | compareWardNames(a, b) { |
| | | // 中文数字到阿拉伯数字的映射(扩展到45) |
| | | const chineseNumMap = { |
| | | 一: 1, |
| | |
| | | return -1; |
| | | }; |
| | | |
| | | const indexA = getIndex(a.leavehospitaldistrictname); |
| | | const indexB = getIndex(b.leavehospitaldistrictname); |
| | | const indexA = getIndex(this.getWardName(a)); |
| | | const indexB = getIndex(this.getWardName(b)); |
| | | |
| | | // 排序逻辑 |
| | | if (indexA === -1 && indexB === -1) { |
| | | return (a.leavehospitaldistrictname || "").localeCompare( |
| | | b.leavehospitaldistrictname || "" |
| | | ); |
| | | return this.getWardName(a).localeCompare(this.getWardName(b)); |
| | | } |
| | | if (indexA === -1) return 1; |
| | | if (indexB === -1) return -1; |
| | |
| | | } |
| | | 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(); |
| | | }, |
| | | |
| | | /** |
| | | * 顶部「已完成患者明细」tab 数据 |
| | | * 维度沿用下方「统计类型」:病区统计 -> 按病区分组;科室统计 -> 按科室分组 |
| | | * 时间沿用下方「随访时间」,状态固定为已完成 |
| | | */ |
| | | 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 = "leave"; |
| | | this.queryParams = { |
| | | statisticaltype: 1, |
| | | leavehospitaldistrictcodes: [], |
| | | deptcodes: [], |
| | | serviceType: [2], |
| | | serviceType: [6], |
| | | dateRange: [], |
| | | pageNum: 1, |
| | | pageSize: 20, |
| | | }; |
| | | this.getList(); |
| | | this.maybeRefreshCompletedGroups(); |
| | | this.maybeRefreshQuestionDetails(); |
| | | }, |
| | | |
| | | // 处理分页大小变化 |
| | |
| | | this.multiple = !selection.length; |
| | | }, |
| | | |
| | | // 获取行key |
| | | // 获取行key(按当前统计类型取对应维度编码) |
| | | getRowKey(row) { |
| | | return row.statisticaltype === 1 |
| | | ? row.leavehospitaldistrictcode |
| | | : row.deptcode; |
| | | return this.queryParams.statisticaltype == 1 |
| | | ? row.hospitaldistrictcode || row.leavehospitaldistrictcode |
| | | : row.hospitaldeptcode || row.deptcode; |
| | | }, |
| | | |
| | | // 当前满意度类型对应的病区名称(用于排序/导出/详情标题) |
| | | getWardName(row) { |
| | | if (!row) return ""; |
| | | return this.isInHospitalSatisfaction |
| | | ? row.hospitaldistrictname || "" |
| | | : row.leavehospitaldistrictname || ""; |
| | | }, |
| | | |
| | | // 格式化百分比 |
| | |
| | | params.endTime = this.queryParams.dateRange[1]; |
| | | } |
| | | |
| | | // 详情只按当前分组维度过滤,清掉其余维度,避免在院/离院条件互相干扰 |
| | | delete params.deptcodes; |
| | | delete params.leaveldeptcodes; |
| | | delete params.hospitaldeptcodes; |
| | | delete params.leavehospitaldistrictcodes; |
| | | delete params.hospitaldistrictcodes; |
| | | |
| | | if (this.queryParams.statisticaltype == 1) { |
| | | this.topicvalue.name = row.leavehospitaldistrictname; |
| | | params.leavehospitaldistrictcodes = [row.leavehospitaldistrictcode]; |
| | | if (this.isInHospitalSatisfaction) { |
| | | this.topicvalue.name = row.hospitaldistrictname || "-"; |
| | | params.hospitaldistrictcodes = [row.hospitaldistrictcode].filter( |
| | | Boolean |
| | | ); |
| | | } else { |
| | | this.topicvalue.name = row.leavehospitaldistrictname || "-"; |
| | | params.leavehospitaldistrictcodes = [ |
| | | row.leavehospitaldistrictcode, |
| | | ].filter(Boolean); |
| | | } |
| | | } else { |
| | | this.topicvalue.name = row.deptname; |
| | | params.deptcodes = [row.deptcode]; |
| | | if (this.isInHospitalSatisfaction) { |
| | | this.topicvalue.name = row.hospitaldeptname || "-"; |
| | | params.hospitaldeptcodes = [row.hospitaldeptcode].filter(Boolean); |
| | | } else { |
| | | this.topicvalue.name = row.deptname || "-"; |
| | | params.leaveldeptcodes = [row.deptcode].filter(Boolean); |
| | | } |
| | | } |
| | | |
| | | const response = await getSfStatisticsJoyInfo(params); |
| | |
| | | }, |
| | | }; |
| | | |
| | | // 添加总标题 |
| | | worksheet.mergeCells(1, 1, 1, 10); |
| | | const titleCell = worksheet.getCell(1, 1); |
| | | titleCell.value = `满意度随访统计表(${sheetNameSuffix})`; |
| | | titleCell.style = titleStyle; |
| | | worksheet.getRow(1).height = 35; |
| | | |
| | | // 添加表头 |
| | | // 表头按页面列动态生成:科室/病区统计列不同,「及时率」只有景宁院区页面才显示 |
| | | const isWardStatistics = this.queryParams.statisticaltype == 1; |
| | | const showTimelyRate = this.orgname === "景宁畲族自治县人民医院"; |
| | | const headers = [ |
| | | this.queryParams.statisticaltype == 1 ? "出院病区" : "科室", |
| | | isWardStatistics ? "在院病区" : "在院科室", |
| | | isWardStatistics ? "离院病区" : "离院科室", |
| | | "出院人次", |
| | | "无需随访人次", |
| | | "应随访人次", |
| | | "随访率", |
| | | "及时率", |
| | | "满意度题目总量", |
| | | "满意度填报量", |
| | | "完成比率", |
| | | ]; |
| | | if (showTimelyRate) { |
| | | headers.push("及时率"); |
| | | } |
| | | headers.push("满意度题目总量", "满意度填报量", "完成比率"); |
| | | const colCount = headers.length; |
| | | |
| | | // 添加总标题 |
| | | worksheet.mergeCells(1, 1, 1, colCount); |
| | | const titleCell = worksheet.getCell(1, 1); |
| | | titleCell.value = `满意度随访统计表(${sheetNameSuffix})`; |
| | | titleCell.style = titleStyle; |
| | | worksheet.getRow(1).height = 35; |
| | | |
| | | const headerRow = worksheet.addRow(headers); |
| | | headerRow.eachCell((cell) => { |
| | |
| | | }); |
| | | headerRow.height = 25; |
| | | |
| | | // 添加数据行 |
| | | // 添加数据行(空值统一显示“-”,与页面保持一致) |
| | | const dash = (v, formatter) => { |
| | | if (v === null || v === undefined || v === "") return "-"; |
| | | return formatter ? formatter(v) : v; |
| | | }; |
| | | this.userList.forEach((item) => { |
| | | const dataRow = worksheet.addRow([ |
| | | this.queryParams.statisticaltype == 1 |
| | | ? item.leavehospitaldistrictname |
| | | : item.deptname, |
| | | const rowData = [ |
| | | 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%", |
| | | dash(item.followUpRate), |
| | | ]; |
| | | if (showTimelyRate) { |
| | | rowData.push(dash(item.rate, (v) => this.formatPercent(v))); |
| | | } |
| | | rowData.push( |
| | | item.joyAllCount || 0, |
| | | item.joyCount || 0, |
| | | item.joyTotal ? this.formatPercent(item.joyTotal) : "0%", |
| | | ]); |
| | | dash(item.joyTotal, (v) => this.formatPercent(v)) |
| | | ); |
| | | const dataRow = worksheet.addRow(rowData); |
| | | |
| | | 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 }, |
| | | ]; |
| | | // 设置列宽(跟列数一致) |
| | | worksheet.columns = headers.map((h, i) => ({ |
| | | width: i < 2 ? 20 : h.length > 6 ? 15 : 12, |
| | | })); |
| | | |
| | | // 生成并下载文件 |
| | | const buffer = await workbook.xlsx.writeBuffer(); |