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