| | |
| | | }, |
| | | }; |
| | | |
| | | // 添加总标题 |
| | | worksheet.mergeCells(1, 1, 1, 10); |
| | | const titleCell = worksheet.getCell(1, 1); |
| | | titleCell.value = `复诊通知统计表(${sheetNameSuffix})`; |
| | | titleCell.style = titleStyle; |
| | | worksheet.getRow(1).height = 35; |
| | | |
| | | // 添加表头 |
| | | // 表头按页面列动态生成:「及时率」只有景宁院区页面才显示 |
| | | const showTimelyRate = this.orgname === "景宁畲族自治县人民医院"; |
| | | const headers = [ |
| | | this.queryParams.statisticaltype == 1 ? "出院病区" : "科室", |
| | | "出院人次", |
| | | "无需随访人次", |
| | | "应随访人次", |
| | | "随访率", |
| | | "及时率", |
| | | "复诊通知题目总量", |
| | | "复诊通知填报量", |
| | | "完成比率", |
| | | ]; |
| | | 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([ |
| | | const rowData = [ |
| | | this.queryParams.statisticaltype == 1 |
| | | ? item.leavehospitaldistrictname |
| | | : item.deptname, |
| | | item.dischargeCount || 0, |
| | | item.nonFollowUp || 0, |
| | | item.followUpNeeded || 0, |
| | | item.followUpRate || "0%", |
| | | item.rate ? this.formatPercent(item.rate) : "0%", |
| | | 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 === 0 ? 20 : h.length > 6 ? 15 : 12, |
| | | })); |
| | | |
| | | // 生成并下载文件 |
| | | const buffer = await workbook.xlsx.writeBuffer(); |