| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="orgname != '景宁畲族自治县人民医院'" |
| | | label="成功率" |
| | | align="center" |
| | | width="120" |
| | | key="successRate" |
| | | prop="successRate" |
| | | :render-header="Tooltipcgl" |
| | | > |
| | | <template slot-scope="scope"> |
| | | <span class="success-rate">{{ |
| | |
| | | width="120" |
| | | key="followUpRate" |
| | | prop="followUpRate" |
| | | :render-header="Tooltipsfl" |
| | | /> |
| | | <el-table-column |
| | | v-if="orgname != '丽水市中医院'" |
| | |
| | | width="120" |
| | | key="rate" |
| | | prop="rate" |
| | | :render-header="Tooltipjsl" |
| | | > |
| | | <template slot-scope="scope"> |
| | | <el-button |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="orgname != '丽水市中医院'" |
| | | label="人工" |
| | | align="center" |
| | | key="manual" |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="orgname != '丽水市中医院'" |
| | | label="语音" |
| | | align="center" |
| | | key="voice" |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="orgname != '丽水市中医院'" |
| | | label="短信" |
| | | align="center" |
| | | key="sms" |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="orgname != '丽水市中医院'" |
| | | label="微信" |
| | | align="center" |
| | | key="weChat" |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="orgname != '景宁畲族自治县人民医院'" |
| | | label="成功率" |
| | | align="center" |
| | | width="120" |
| | | key="successRate" |
| | | prop="successRate" |
| | | :render-header="Tooltipcgl" |
| | | > |
| | | <template slot-scope="scope"> |
| | | <span class="success-rate">{{ |
| | |
| | | width="120" |
| | | key="followUpRate" |
| | | prop="followUpRate" |
| | | :render-header="Tooltipsfl" |
| | | /> |
| | | <el-table-column |
| | | v-if="orgname != '丽水市中医院'" |
| | |
| | | width="120" |
| | | key="rate" |
| | | prop="rate" |
| | | :render-header="Tooltipjsl" |
| | | > |
| | | <template slot-scope="scope"> |
| | | <el-button |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="orgname != '丽水市中医院'" |
| | | label="人工" |
| | | align="center" |
| | | key="manual" |
| | |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="orgname != '丽水市中医院'" |
| | | label="语音" |
| | | align="center" |
| | | key="voice" |
| | | prop="voice" |
| | | > |
| | | <el-table-column label="语音" align="center" key="voice" prop="voice"> |
| | | <template slot-scope="scope"> |
| | | <el-button |
| | | size="medium" |
| | |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="orgname != '丽水市中医院'" |
| | | label="短信" |
| | | align="center" |
| | | key="sms" |
| | | prop="sms" |
| | | > |
| | | <el-table-column label="短信" align="center" key="sms" prop="sms"> |
| | | <template slot-scope="scope"> |
| | | <el-button |
| | | size="medium" |
| | |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column |
| | | v-if="orgname != '丽水市中医院'" |
| | | label="微信" |
| | | align="center" |
| | | key="weChat" |
| | |
| | | |
| | | <script> |
| | | import { getSfStatisticsHyperlink } from "@/api/AiCentre/index"; |
| | | import store from "@/store"; |
| | | |
| | | import { getSfStatistics, selectTimelyRate } from "@/api/system/user"; |
| | | import ExcelJS from "exceljs"; |
| | |
| | | expands: [], |
| | | ids: [], |
| | | patientqueryParams: { pn: 1, ps: 10 }, |
| | | tasktypes: store.getters.tasktypes, |
| | | }; |
| | | }, |
| | | methods: { |
| | |
| | | |
| | | delete params.leavehospitaldistrictcodes.all; |
| | | delete params.deptcodes.all; |
| | | params.rateDay = 7; |
| | | params.rateDay = this.orgname == "龙泉市人民医院" ? 21 : 7; |
| | | getSfStatistics(params) |
| | | .then((response) => { |
| | | this.tableData = this.customSort(response.data); |
| | |
| | | }, |
| | | |
| | | customSort(data) { |
| | | const order = [ |
| | | "一", |
| | | "二", |
| | | "三", |
| | | "四", |
| | | "五", |
| | | "六", |
| | | "七", |
| | | "八", |
| | | "九", |
| | | "十", |
| | | "十一", |
| | | "十二", |
| | | "十三", |
| | | "十四", |
| | | "十五", |
| | | "十六", |
| | | "十七", |
| | | "十八", |
| | | "十九", |
| | | "二十", |
| | | "二十一", |
| | | "二十二", |
| | | "二十三", |
| | | "二十四", |
| | | "二十五", |
| | | "二十六", |
| | | "二十七", |
| | | "二十八", |
| | | "二十九", |
| | | "三十", |
| | | "三十一", |
| | | "三十二", |
| | | "三十三", |
| | | "三十四", |
| | | "三十五", |
| | | "三十六", |
| | | "三十七", |
| | | "三十八", |
| | | "三十九", |
| | | "四十", |
| | | "四十一", |
| | | "四十二", |
| | | "四十三", |
| | | "四十四", |
| | | "四十五", |
| | | ]; |
| | | |
| | | return data.sort((a, b) => { |
| | | const getIndex = (name) => { |
| | | if (!name || typeof name !== "string") return -1; |
| | | const chineseMatch = name.match(/^([一二三四五六七八九十]+)/); |
| | | if (chineseMatch && chineseMatch[1]) { |
| | | return order.indexOf(chineseMatch[1]); |
| | | } |
| | | const arabicMatch = name.match(/^(\d+)/); |
| | | if (arabicMatch && arabicMatch[1]) { |
| | | const num = parseInt(arabicMatch[1], 10); |
| | | if (num >= 1 && num <= 45) { |
| | | return num - 1; |
| | | } |
| | | } |
| | | return -1; |
| | | }; |
| | | |
| | | const indexA = getIndex(a.leavehospitaldistrictname); |
| | | const indexB = getIndex(b.leavehospitaldistrictname); |
| | | |
| | | if (indexA === -1 && indexB === -1) { |
| | | return (a.leavehospitaldistrictname || "").localeCompare( |
| | | b.leavehospitaldistrictname || "" |
| | | ); |
| | | } |
| | | if (indexA === -1) return 1; |
| | | if (indexB === -1) return -1; |
| | | return indexA - indexB; |
| | | }); |
| | | return data.sort((a, b) => |
| | | this.compareWardName( |
| | | a.leavehospitaldistrictname, |
| | | b.leavehospitaldistrictname |
| | | ) |
| | | ); |
| | | }, |
| | | |
| | | sortChineseNumber(aRow, bRow) { |
| | | const a = aRow.leavehospitaldistrictname; |
| | | const b = bRow.leavehospitaldistrictname; |
| | | |
| | | const chineseNumMap = { |
| | | 一: 1, |
| | | 二: 2, |
| | | 三: 3, |
| | | 四: 4, |
| | | 五: 5, |
| | | 六: 6, |
| | | 七: 7, |
| | | 八: 8, |
| | | 九: 9, |
| | | 十: 10, |
| | | 十一: 11, |
| | | 十二: 12, |
| | | 十三: 13, |
| | | 十四: 14, |
| | | 十五: 15, |
| | | 十六: 16, |
| | | 十七: 17, |
| | | 十八: 18, |
| | | 十九: 19, |
| | | 二十: 20, |
| | | 二十一: 21, |
| | | 二十二: 22, |
| | | 二十三: 23, |
| | | 二十四: 24, |
| | | 二十五: 25, |
| | | 二十六: 26, |
| | | 二十七: 27, |
| | | 二十八: 28, |
| | | 二十九: 29, |
| | | 三十: 30, |
| | | 三十一: 31, |
| | | 三十二: 32, |
| | | 三十三: 33, |
| | | 三十四: 34, |
| | | 三十五: 35, |
| | | 三十六: 36, |
| | | 三十七: 37, |
| | | 三十八: 38, |
| | | 三十九: 39, |
| | | 四十: 40, |
| | | 四十一: 41, |
| | | 四十二: 42, |
| | | 四十三: 43, |
| | | 四十四: 44, |
| | | 四十五: 45, |
| | | }; |
| | | |
| | | const getNumberFromText = (text) => { |
| | | if (!text || typeof text !== "string") return -1; |
| | | const match = text.match(/^([一二三四五六七八九十]+)/); |
| | | if (match && match[1]) { |
| | | const chineseNum = match[1]; |
| | | return chineseNumMap[chineseNum] !== undefined |
| | | ? chineseNumMap[chineseNum] |
| | | : -1; |
| | | } |
| | | const arabicMatch = text.match(/^(\d+)/); |
| | | if (arabicMatch && arabicMatch[1]) { |
| | | const num = parseInt(arabicMatch[1], 10); |
| | | return num >= 1 && num <= 45 ? num : -1; |
| | | } |
| | | return -1; |
| | | }; |
| | | |
| | | const numA = getNumberFromText(a); |
| | | const numB = getNumberFromText(b); |
| | | |
| | | if (numA === -1 && numB === -1) { |
| | | return (a || "").localeCompare(b || ""); |
| | | } |
| | | if (numA === -1) return 1; |
| | | if (numB === -1) return -1; |
| | | return numA - numB; |
| | | return this.compareWardName( |
| | | aRow.leavehospitaldistrictname, |
| | | bRow.leavehospitaldistrictname |
| | | ); |
| | | }, |
| | | |
| | | getRowKey(row) { |
| | |
| | | |
| | | if (!row.doctorStats) { |
| | | this.loading = true; |
| | | params.rateDay = 7; |
| | | params.rateDay = this.orgname == "龙泉市人民医院" ? 21 : 7; |
| | | |
| | | getSfStatistics(params).then((res) => { |
| | | this.$set(row, "doctorStats", res.data); |
| | |
| | | |
| | | return sums; |
| | | }, |
| | | |
| | | Tooltipcgl(h, { column }) { |
| | | return h( |
| | | "el-tooltip", |
| | | { |
| | | props: { |
| | | content: "随访成功/(需随访-待随访)", |
| | | placement: "top", |
| | | effect: "dark", |
| | | }, |
| | | }, |
| | | [h("span", column.label)] |
| | | ); |
| | | }, |
| | | Tooltipjsl(h, { column }) { |
| | | return h( |
| | | "el-tooltip", |
| | | { |
| | | props: { |
| | | content: |
| | | "(出院时间+任务周期)小于完成时间即为超时;(需随访-超时)/需随访", |
| | | placement: "top", |
| | | effect: "dark", |
| | | }, |
| | | }, |
| | | [h("span", column.label)] |
| | | ); |
| | | }, |
| | | Tooltipsfl(h, { column }) { |
| | | return h( |
| | | "el-tooltip", |
| | | { |
| | | props: { |
| | | content: "(随访成功+首次随访失败)/首次应随访", |
| | | placement: "top", |
| | | effect: "dark", |
| | | }, |
| | | }, |
| | | [h("span", column.label)] |
| | | ); |
| | | }, |
| | | getInnerSummaries(param) { |
| | | const { columns, data } = param; |
| | | const sums = []; |
| | |
| | | return Number.isInteger(num) ? num.toString() : num.toFixed(0); |
| | | }, |
| | | |
| | | // ===== 病区名排序(支持 1-B10 / 2-A2 等 数字-字母数字 格式) ===== |
| | | // 解析病区名,返回排序键 { group, letter, number } |
| | | parseWardKey(name) { |
| | | if (!name || typeof name !== "string") return null; |
| | | const trimmed = name.trim(); |
| | | |
| | | // 格式1:数字-字母数字,如 1-B10、2-A2、1-A11 |
| | | const dashMatch = trimmed.match(/^(\d+)-([A-Za-z]+)(\d+)/); |
| | | if (dashMatch) { |
| | | return { |
| | | group: parseInt(dashMatch[1], 10), |
| | | letter: dashMatch[2].toUpperCase(), |
| | | number: parseInt(dashMatch[3], 10), |
| | | }; |
| | | } |
| | | |
| | | // 格式2:中文数字开头,如 一病区、十一病区、二十一病区 |
| | | const cnMatch = trimmed.match(/^([一二三四五六七八九十]+)/); |
| | | if (cnMatch && cnMatch[1]) { |
| | | const num = this.chineseToNumber(cnMatch[1]); |
| | | if (num > 0) return { group: num, letter: "", number: 0 }; |
| | | } |
| | | |
| | | // 格式3:阿拉伯数字开头,如 1病区、12病区 |
| | | const numMatch = trimmed.match(/^(\d+)/); |
| | | if (numMatch && numMatch[1]) { |
| | | return { group: parseInt(numMatch[1], 10), letter: "", number: 0 }; |
| | | } |
| | | |
| | | return null; |
| | | }, |
| | | |
| | | // 中文数字转阿拉伯数字(支持 一 ~ 九十九) |
| | | chineseToNumber(str) { |
| | | const digits = { |
| | | 一: 1, |
| | | 二: 2, |
| | | 三: 3, |
| | | 四: 4, |
| | | 五: 5, |
| | | 六: 6, |
| | | 七: 7, |
| | | 八: 8, |
| | | 九: 9, |
| | | }; |
| | | if (!str) return -1; |
| | | if (str === "十") return 10; |
| | | if (str.startsWith("十")) return 10 + (digits[str[1]] || 0); |
| | | if (str.includes("十")) { |
| | | const parts = str.split("十"); |
| | | const tens = digits[parts[0]] || 0; |
| | | const ones = digits[parts[1]] || 0; |
| | | return tens * 10 + ones; |
| | | } |
| | | return digits[str] !== undefined ? digits[str] : -1; |
| | | }, |
| | | |
| | | // 病区名比较器:数字段 → 字母段 → 数字段 |
| | | compareWardName(nameA, nameB) { |
| | | const ka = this.parseWardKey(nameA); |
| | | const kb = this.parseWardKey(nameB); |
| | | |
| | | if (!ka && !kb) return (nameA || "").localeCompare(nameB || "", "zh-CN"); |
| | | if (!ka) return 1; |
| | | if (!kb) return -1; |
| | | |
| | | if (ka.group !== kb.group) return ka.group - kb.group; |
| | | if (ka.letter !== kb.letter) return ka.letter.localeCompare(kb.letter); |
| | | return ka.number - kb.number; |
| | | }, |
| | | |
| | | handleSelectionChange(selection) { |
| | | this.ids = selection.map((item) => item.tagid); |
| | | }, |
| | |
| | | let dateRangeString = ""; |
| | | let sheetNameSuffix = ""; |
| | | |
| | | // 判断是否是丽水市中医院 |
| | | const isLishuiHospital = this.orgname == "丽水市中医院"; |
| | | |
| | | if ( |
| | | this.queryParams.dateRange && |
| | | this.queryParams.dateRange.length === 2 |
| | | ) { |
| | | const startDateStr = this.queryParams.dateRange[0]; |
| | | const endDateStr = this.queryParams.dateRange[1]; |
| | | const formatDateForDisplay = (dateTimeStr) => { |
| | | return dateTimeStr.split(" ")[0]; |
| | | }; |
| | | const startDateFormatted = formatDateForDisplay(startDateStr); |
| | | const endDateFormatted = formatDateForDisplay(endDateStr); |
| | | dateRangeString = `${startDateFormatted}至${endDateFormatted}`; |
| | | sheetNameSuffix = `${startDateFormatted}至${endDateFormatted}`; |
| | | |
| | | if (isLishuiHospital) { |
| | | // 丽水市中医院:只显示年月 |
| | | const formatMonthOnly = (dateTimeStr) => { |
| | | const date = new Date(dateTimeStr); |
| | | const year = date.getFullYear(); |
| | | const month = date.getMonth() + 1; |
| | | return `${year}年${month}月`; |
| | | }; |
| | | const startDateFormatted = formatMonthOnly(startDateStr); |
| | | const endDateFormatted = formatMonthOnly(endDateStr); |
| | | dateRangeString = `${startDateFormatted}至${endDateFormatted}`; |
| | | sheetNameSuffix = `${startDateFormatted}至${endDateFormatted}`; |
| | | } else { |
| | | // 其他医院:显示年月日 |
| | | const formatDateForDisplay = (dateTimeStr) => { |
| | | return dateTimeStr.split(" ")[0]; |
| | | }; |
| | | const startDateFormatted = formatDateForDisplay(startDateStr); |
| | | const endDateFormatted = formatDateForDisplay(endDateStr); |
| | | dateRangeString = `${startDateFormatted}至${endDateFormatted}`; |
| | | sheetNameSuffix = `${startDateFormatted}至${endDateFormatted}`; |
| | | } |
| | | } else { |
| | | const now = new Date(); |
| | | const currentMonth = now.getMonth() + 1; |
| | | dateRangeString = `${currentMonth}月`; |
| | | sheetNameSuffix = `${currentMonth}月`; |
| | | const currentYear = now.getFullYear(); |
| | | |
| | | if (isLishuiHospital) { |
| | | // 丽水市中医院:显示年月 |
| | | dateRangeString = `${currentYear}年${currentMonth}月`; |
| | | sheetNameSuffix = `${currentYear}年${currentMonth}月`; |
| | | } else { |
| | | // 其他医院:显示月份 |
| | | dateRangeString = `${currentMonth}月`; |
| | | sheetNameSuffix = `${currentMonth}月`; |
| | | } |
| | | } |
| | | |
| | | const excelName = `首次出院随访统计表_${dateRangeString}.xlsx`; |
| | | const worksheetName = `首次随访统计_${sheetNameSuffix}`; |
| | | // 根据 serviceType 生成随访类型名称 |
| | | let serviceTypeName = "首次出院随访"; // 文件名使用的名称 |
| | | let sheetTypeName = "首次随访"; // 工作表使用的名称(简化版) |
| | | |
| | | if ( |
| | | this.queryParams.serviceType && |
| | | Array.isArray(this.queryParams.serviceType) && |
| | | this.queryParams.serviceType.length > 0 |
| | | ) { |
| | | // 使用 props 中的 options(即 tasktypes) |
| | | if (this.options && Array.isArray(this.options)) { |
| | | const matchedTypes = this.options.filter((task) => |
| | | this.queryParams.serviceType.includes(task.value) |
| | | ); |
| | | console.log(matchedTypes, "matchedTypes"); |
| | | |
| | | if (matchedTypes.length === 1) { |
| | | const label = matchedTypes[0].label; |
| | | serviceTypeName = `首次${label}`; |
| | | sheetTypeName = `首次${label}`; |
| | | } else if (matchedTypes.length > 1) { |
| | | const typeNames = matchedTypes.map((task) => task.label); |
| | | serviceTypeName = `首次${typeNames.join("/")}`; |
| | | // 工作表名简化(取第一个+“等”) |
| | | sheetTypeName = `首次${typeNames[0]}等`; |
| | | } else if (this.queryParams.serviceType.length > 0) { |
| | | // 无匹配时使用原始值 |
| | | const typeStr = this.queryParams.serviceType.join("/"); |
| | | serviceTypeName = `首次${typeStr}`; |
| | | sheetTypeName = "首次随访"; |
| | | } |
| | | } else if (this.queryParams.serviceType.length > 0) { |
| | | const typeStr = this.queryParams.serviceType.join("/"); |
| | | serviceTypeName = `首次${typeStr}`; |
| | | sheetTypeName = "首次随访"; |
| | | } |
| | | } |
| | | |
| | | const excelName = `${serviceTypeName}统计表_${dateRangeString}.xlsx`; |
| | | |
| | | // 清理工作表名称,移除非法字符 |
| | | const cleanSheetName = (name) => { |
| | | // Excel工作表名不能包含的字符: * ? : \ / [ ] |
| | | return name.replace(/[*?:\\/[\]]/g, " "); |
| | | }; |
| | | |
| | | const worksheetName = cleanSheetName( |
| | | `${sheetTypeName}统计_${sheetNameSuffix}` |
| | | ); |
| | | |
| | | if (!this.tableData || this.tableData.length === 0) { |
| | | this.$message.warning("暂无首次随访数据可导出"); |
| | | this.$message.warning(`暂无${serviceTypeName}数据可导出`); |
| | | return false; |
| | | } |
| | | |
| | |
| | | const worksheet = workbook.addWorksheet(worksheetName); |
| | | |
| | | // 构建表格 |
| | | this.buildExportSheet(worksheet, sheetNameSuffix); |
| | | this.buildExportSheet(worksheet, sheetNameSuffix, serviceTypeName); |
| | | |
| | | const buffer = await workbook.xlsx.writeBuffer(); |
| | | const blob = new Blob([buffer], { |
| | |
| | | |
| | | return sums; |
| | | }, |
| | | buildExportSheet(worksheet, sheetNameSuffix) { |
| | | buildExportSheet(worksheet, sheetNameSuffix, serviceTypeName) { |
| | | const titleStyle = { |
| | | font: { |
| | | name: "微软雅黑", |
| | |
| | | right: { style: "thin", color: { argb: "FFD0D0D0" } }, |
| | | }, |
| | | }; |
| | | |
| | | const titleText = `${serviceTypeName}统计表_${sheetNameSuffix}`; |
| | | // 添加标题行 |
| | | worksheet.mergeCells(1, 1, 1, 16); |
| | | const titleCell = worksheet.getCell(1, 1); |
| | | titleCell.value = `首次出院随访统计表_${sheetNameSuffix}`; |
| | | titleCell.value = titleText; // 使用动态标题 |
| | | titleCell.style = titleStyle; |
| | | worksheet.getRow(1).height = 35; |
| | | |
| | |
| | | worksheet.getCell(2, 6).value = "应随访人次"; |
| | | |
| | | worksheet.mergeCells(2, 7, 2, 16); // 从7合并到16(原来是7-15) |
| | | worksheet.getCell(2, 7).value = "首次出院随访"; |
| | | worksheet.getCell(2, 7).value = serviceTypeName; // 或适当截取 |
| | | worksheet.getCell(2, 7).style = headerStyle; |
| | | |
| | | worksheet.getRow(2).height = 28; |
| | |
| | | this.patientqueryParams.serviceTypes = queryParams.serviceType |
| | | ? queryParams.serviceType.join(",") |
| | | : null; |
| | | console.log(2); |
| | | |
| | | return selectTimelyRate(this.patientqueryParams); |
| | | }, |