<template>
|
<div class="completed-detail" v-loading="loading">
|
<div class="detail-header">
|
<div class="detail-title">
|
<span>患者随访信息表单</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="责任护士"
|
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("患者随访信息表单");
|
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.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, `患者随访信息表单_${this.fileDate()}.xlsx`);
|
this.$message.success("导出成功");
|
} catch (error) {
|
console.error("导出患者随访信息失败:", 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>
|