<template>
|
<div class="medical-panel">
|
<div class="panel-header">
|
<h3>肺脏化验检查</h3>
|
<div class="panel-actions">
|
<el-button
|
v-if="isEditing"
|
type="primary"
|
size="small"
|
@click="addColumn"
|
icon="el-icon-plus"
|
>
|
新增记录列
|
</el-button>
|
<el-tooltip content="刷新表格布局" placement="top">
|
<el-button
|
size="small"
|
@click="forceTableLayout"
|
icon="el-icon-refresh"
|
>
|
刷新布局
|
</el-button>
|
</el-tooltip>
|
</div>
|
</div>
|
|
<el-table
|
:data="tableData"
|
border
|
style="width: 100%"
|
class="medical-table"
|
:key="tableKey"
|
@header-dragend="handleHeaderDragEnd"
|
v-loading="tableLoading"
|
>
|
<el-table-column
|
prop="itemName"
|
label="检测项目"
|
width="240"
|
fixed
|
class-name="leave-alone"
|
>
|
<template #default="scope">
|
<div class="item-name-cell">
|
<span :class="{ 'required-item': scope.row.required }">
|
{{ scope.row.itemName }}
|
</span>
|
<el-tooltip
|
v-if="scope.row.reference"
|
:content="`参考范围: ${scope.row.reference}`"
|
placement="top"
|
>
|
<i class="el-icon-info reference-icon"></i>
|
</el-tooltip>
|
</div>
|
</template>
|
</el-table-column>
|
|
<el-table-column
|
v-for="(col, index) in dynamicColumns"
|
:key="col.key"
|
:label="col.label"
|
:min-width="180"
|
:resizable="isEditing"
|
header-align="center"
|
align="center"
|
>
|
<template #header>
|
<div class="custom-column-header">
|
<div class="header-content" @click.stop="handleEditColumn(index)">
|
<span class="header-label">{{
|
col.label.replace("\n", " ")
|
}}</span>
|
<el-tooltip
|
v-if="col.remark"
|
:content="col.remark"
|
placement="top"
|
>
|
<i class="el-icon-info header-remark-icon"></i>
|
</el-tooltip>
|
</div>
|
<div class="header-actions" v-if="isEditing">
|
<el-tooltip content="编辑时间" placement="top">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-edit"
|
class="header-btn"
|
@click.stop="handleEditColumn(index)"
|
/>
|
</el-tooltip>
|
<el-tooltip content="删除此列" placement="top">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-delete"
|
class="header-btn delete-btn"
|
@click.stop="handleDeleteColumnByIndex(index)"
|
/>
|
</el-tooltip>
|
</div>
|
</div>
|
</template>
|
|
<template #default="scope">
|
<!-- 数值输入类 -->
|
<div v-if="scope.row.type === 'number'" class="cell-content-wrapper">
|
<el-input
|
v-if="isEditing"
|
v-model="scope.row.values[index]"
|
size="small"
|
:placeholder="getPlaceholder(scope.row)"
|
@input="val => handleNumberInput(scope.row, index, val)"
|
@blur="handleValueChange(scope.row, index)"
|
class="value-input"
|
/>
|
<div v-else class="value-display-container">
|
<span class="value-text">{{
|
scope.row.values[index] || "-"
|
}}</span>
|
<span
|
v-if="scope.row.values[index] && scope.row.unit"
|
class="unit-text"
|
>
|
{{ scope.row.unit }}
|
</span>
|
</div>
|
</div>
|
|
<!-- 自动计算类(氧合指数) -->
|
<div
|
v-else-if="scope.row.type === 'calculated'"
|
class="cell-content-wrapper"
|
>
|
<div class="calculated-value">
|
<span class="value-text">{{
|
scope.row.values[index] || "-"
|
}}</span>
|
<span v-if="scope.row.values[index]" class="unit-text">{{
|
scope.row.unit
|
}}</span>
|
</div>
|
</div>
|
|
<!-- 文本描述类 -->
|
<div
|
v-else-if="scope.row.type === 'description'"
|
class="cell-description-wrapper"
|
>
|
<el-input
|
v-if="isEditing"
|
v-model="scope.row.values[index]"
|
type="textarea"
|
:rows="3"
|
size="small"
|
placeholder="请输入文字描述..."
|
@blur="handleValueChange(scope.row, index)"
|
/>
|
<div v-else class="description-display">
|
{{ scope.row.values[index] || "未填写" }}
|
</div>
|
</div>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<!-- 附件区域 -->
|
<!-- 附件区域 -->
|
<div class="attachment-group-section">
|
<div class="attachment-category">
|
<h4 class="category-title">
|
<i class="el-icon-document"></i> 胸片/胸部CT附件
|
</h4>
|
<UploadAttachment
|
ref="chestImgUpload"
|
:file-list="chestImgFileList"
|
:limit="10"
|
:accept="attachmentAccept"
|
:multiple="true"
|
@change="files => handleCategoryAttachmentChange('chestImg', files)"
|
@upload-success="
|
payload => handleCategoryUploadSuccess('chestImg', payload)
|
"
|
@upload-error="
|
payload => handleCategoryUploadError('chestImg', payload)
|
"
|
@remove="file => handleCategoryAttachmentRemove('chestImg', file)"
|
/>
|
|
<!-- 胸片/胸部CT附件列表 -->
|
<div
|
v-if="attachments.chestImg && attachments.chestImg.length > 0"
|
class="attachment-list"
|
>
|
<div class="list-title">
|
已上传附件 ({{ attachments.chestImg.length }})
|
</div>
|
<el-table
|
:data="attachments.chestImg"
|
style="width: 100%"
|
size="small"
|
>
|
<el-table-column label="文件名" min-width="200">
|
<template slot-scope="scope">
|
<i
|
class="el-icon-document"
|
:style="{ color: getFileIconColor(scope.row.fileName) }"
|
></i>
|
<span class="file-name">{{ scope.row.fileName }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="文件类型" width="100">
|
<template slot-scope="scope">
|
<el-tag :type="getFileTagType(scope.row.fileName)" size="small">
|
{{ getFileTypeText(scope.row.fileName) }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column label="上传时间" width="160">
|
<template slot-scope="scope">
|
<span>{{ formatDateTime(scope.row.uploadTime) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="文件大小" width="100">
|
<template slot-scope="scope">
|
<span>{{ formatFileSize(scope.row.fileSize) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" width="266" fixed="right">
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
type="primary"
|
@click="handlePreview(scope.row)"
|
:disabled="!isPreviewable(scope.row.fileName)"
|
>
|
预览
|
</el-button>
|
<el-button
|
v-if="isEditing"
|
size="mini"
|
type="success"
|
@click="handleDownload(scope.row)"
|
>
|
下载
|
</el-button>
|
<el-button
|
v-if="isEditing"
|
size="mini"
|
type="danger"
|
@click="
|
handleRemoveCategoryAttachment('chestImg', scope.$index)
|
"
|
>
|
删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</div>
|
|
<div class="attachment-category">
|
<h4 class="category-title">
|
<i class="el-icon-document"></i> 支气管镜检查附件
|
</h4>
|
<UploadAttachment
|
ref="bronchoscopyUpload"
|
:file-list="bronchoscopyFileList"
|
:limit="10"
|
:accept="attachmentAccept"
|
:multiple="true"
|
@change="
|
files => handleCategoryAttachmentChange('bronchoscopy', files)
|
"
|
@upload-success="
|
payload => handleCategoryUploadSuccess('bronchoscopy', payload)
|
"
|
@upload-error="
|
payload => handleCategoryUploadError('bronchoscopy', payload)
|
"
|
@remove="file => handleCategoryAttachmentRemove('bronchoscopy', file)"
|
/>
|
|
<!-- 支气管镜检查附件列表 -->
|
<div
|
v-if="attachments.bronchoscopy && attachments.bronchoscopy.length > 0"
|
class="attachment-list"
|
>
|
<div class="list-title">
|
已上传附件 ({{ attachments.bronchoscopy.length }})
|
</div>
|
<el-table
|
:data="attachments.bronchoscopy"
|
style="width: 100%"
|
size="small"
|
>
|
<el-table-column label="文件名" min-width="200">
|
<template slot-scope="scope">
|
<i
|
class="el-icon-document"
|
:style="{ color: getFileIconColor(scope.row.fileName) }"
|
></i>
|
<span class="file-name">{{ scope.row.fileName }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="文件类型" width="100">
|
<template slot-scope="scope">
|
<el-tag :type="getFileTagType(scope.row.fileName)" size="small">
|
{{ getFileTypeText(scope.row.fileName) }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column label="上传时间" width="160">
|
<template slot-scope="scope">
|
<span>{{ formatDateTime(scope.row.uploadTime) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="文件大小" width="100">
|
<template slot-scope="scope">
|
<span>{{ formatFileSize(scope.row.fileSize) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" width="266" fixed="right">
|
<template slot-scope="scope">
|
<el-button
|
size="mini"
|
type="primary"
|
@click="handlePreview(scope.row)"
|
:disabled="!isPreviewable(scope.row.fileName)"
|
>
|
预览
|
</el-button>
|
<el-button
|
v-if="isEditing"
|
size="mini"
|
type="success"
|
@click="handleDownload(scope.row)"
|
>
|
下载
|
</el-button>
|
<el-button
|
v-if="isEditing"
|
size="mini"
|
type="danger"
|
@click="
|
handleRemoveCategoryAttachment('bronchoscopy', scope.$index)
|
"
|
>
|
删除
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</div>
|
</div>
|
|
<!-- 统计信息 -->
|
<div v-if="showStatistics" class="statistics-section">
|
<el-card shadow="never">
|
<div class="stats-content">
|
<span class="stats-title">数据统计:</span>
|
<span class="stats-item"
|
>总记录数: {{ dynamicColumns.length }} 个时间点</span
|
>
|
<span class="stats-item">已填写: {{ filledCount }} 项</span>
|
<span class="stats-item">完成度: {{ completionRate }}%</span>
|
</div>
|
</el-card>
|
</div>
|
|
<!-- 列编辑对话框(同 HeartLabPanel) -->
|
<el-dialog
|
:title="`${editingColumnIndex !== null ? '编辑' : '新增'}时间点`"
|
:visible.sync="columnDialogVisible"
|
width="450px"
|
@closed="handleDialogClosed"
|
>
|
<el-form
|
:model="columnForm"
|
label-width="80px"
|
ref="columnForm"
|
:rules="columnRules"
|
>
|
<el-form-item label="日期" prop="date">
|
<el-date-picker
|
v-model="columnForm.date"
|
type="date"
|
placeholder="选择日期"
|
value-format="yyyy-MM-dd"
|
style="width: 100%"
|
:disabled-date="disableFutureDates"
|
/>
|
</el-form-item>
|
<el-form-item label="时间" prop="time">
|
<el-time-picker
|
v-model="columnForm.time"
|
placeholder="选择时间"
|
value-format="HH:mm"
|
style="width: 100%"
|
/>
|
</el-form-item>
|
<el-form-item label="备注" prop="remark">
|
<el-input
|
v-model="columnForm.remark"
|
type="textarea"
|
:rows="2"
|
placeholder="可选填写时间点备注信息"
|
maxlength="100"
|
show-word-limit
|
/>
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="columnDialogVisible = false">取消</el-button>
|
<el-button
|
v-if="editingColumnIndex !== null"
|
type="danger"
|
@click="handleDeleteColumn"
|
>删除</el-button
|
>
|
<el-button
|
type="primary"
|
@click="confirmAddColumn"
|
:loading="saveLoading"
|
>确定</el-button
|
>
|
</span>
|
</el-dialog>
|
|
<!-- 文件预览弹窗 -->
|
<FilePreviewDialog
|
:visible="previewVisible"
|
:file="currentPreviewFile"
|
@close="previewVisible = false"
|
@download="handleDownload"
|
/>
|
</div>
|
</template>
|
|
<script>
|
import UploadAttachment from "@/components/UploadAttachment";
|
import FilePreviewDialog from "@/components/FilePreviewDialog";
|
import dayjs from "dayjs";
|
|
export default {
|
name: "LungLabPanel",
|
components: { UploadAttachment, FilePreviewDialog },
|
props: {
|
isEditing: { type: Boolean, default: false },
|
initialData: { type: Object, default: () => ({}) },
|
showStatistics: { type: Boolean, default: true }
|
},
|
data() {
|
return {
|
tableData: [],
|
dynamicColumns: [],
|
attachments: { chestImg: [], bronchoscopy: [] },
|
chestImgFileList: [],
|
bronchoscopyFileList: [],
|
columnDialogVisible: false,
|
columnForm: { date: "", time: "", remark: "" },
|
editingColumnIndex: null,
|
tableKey: 0,
|
tableLoading: false,
|
saveLoading: false,
|
internalData: {},
|
columnRules: {
|
date: [{ required: true, message: "请选择日期", trigger: "change" }],
|
time: [{ required: true, message: "请选择时间", trigger: "change" }]
|
},
|
previewVisible: false,
|
currentPreviewFile: null,
|
attachmentLimit: 10,
|
attachmentAccept:
|
".pdf,.jpg,.jpeg,.png,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt"
|
};
|
},
|
computed: {
|
filledCount() {
|
let count = 0;
|
this.tableData.forEach(row => {
|
row.values.forEach(v => {
|
if (v && v.toString().trim()) count++;
|
});
|
});
|
return count;
|
},
|
completionRate() {
|
const total = this.tableData.length * this.dynamicColumns.length;
|
return total > 0 ? Math.round((this.filledCount / total) * 100) : 0;
|
}
|
},
|
watch: {
|
initialData: {
|
handler(newData) {
|
if (newData && Object.keys(newData).length > 0) {
|
this.internalData = { ...newData };
|
this.initFromExternalData();
|
}
|
},
|
immediate: true,
|
deep: true
|
},
|
isEditing(newVal) {
|
if (!newVal) this.saveData();
|
this.$nextTick(() => this.forceTableLayout());
|
},
|
dynamicColumns: {
|
handler() {
|
this.$nextTick(() => this.forceTableLayout());
|
},
|
deep: true,
|
immediate: true
|
}
|
},
|
methods: {
|
initFromExternalData() {
|
if (this.internalData.data && this.internalData.columns) {
|
this.tableData = this.internalData.data.map(item => ({
|
...item,
|
values:
|
item.values || new Array(this.internalData.columns.length).fill("")
|
}));
|
this.dynamicColumns = [...this.internalData.columns];
|
} else {
|
this.initTableData();
|
}
|
if (this.internalData.attachments) {
|
this.attachments = {
|
chestImg: this.internalData.attachments.chestImg || [],
|
bronchoscopy: this.internalData.attachments.bronchoscopy || []
|
};
|
this.chestImgFileList = this.attachments.chestImg.map(a => ({
|
uid: a.id || Math.random(),
|
name: a.fileName,
|
url: a.path || a.fileUrl,
|
status: "success"
|
}));
|
this.bronchoscopyFileList = this.attachments.bronchoscopy.map(a => ({
|
uid: a.id || Math.random(),
|
name: a.fileName,
|
url: a.path || a.fileUrl,
|
status: "success"
|
}));
|
}
|
},
|
initTableData() {
|
const items = this.getMedicalItems();
|
if (this.dynamicColumns.length === 0) {
|
this.dynamicColumns = [
|
{
|
label: `${new Date().toISOString().split("T")[0]}\n08:00`,
|
key: "time1",
|
date: new Date().toISOString().split("T")[0],
|
time: "08:00",
|
remark: "初次检测"
|
}
|
];
|
}
|
this.tableData = items.map(item => ({
|
...item,
|
values: new Array(this.dynamicColumns.length).fill("")
|
}));
|
},
|
getMedicalItems() {
|
return [
|
{
|
itemName: "氧分压(PO₂)",
|
unit: "mm/Hg",
|
required: true,
|
reference: "83-108",
|
min: 50,
|
max: 110,
|
type: "number",
|
calcKey: "po2"
|
},
|
{
|
itemName: "二氧化碳分压(PCO₂)",
|
unit: "mm/Hg",
|
required: true,
|
reference: "35-45",
|
min: 25,
|
max: 55,
|
type: "number",
|
calcKey: "pco2"
|
},
|
{
|
itemName: "吸氧浓度(FiO₂)",
|
unit: "%",
|
required: true,
|
reference: "21-100",
|
min: 18,
|
max: 101,
|
type: "number",
|
calcKey: "fio2"
|
},
|
{
|
itemName: "氧合指数(OI)",
|
unit: "",
|
required: false,
|
reference: "≥400",
|
type: "calculated",
|
calcFormula: "po2/fio2"
|
},
|
{
|
itemName: "胸片/胸部CT描述",
|
unit: "",
|
required: true,
|
reference: "",
|
type: "description"
|
},
|
{
|
itemName: "支气管镜检查描述",
|
unit: "",
|
required: true,
|
reference: "",
|
type: "description"
|
}
|
];
|
},
|
// 自动计算氧合指数
|
handleNumberInput(row, colIndex, value) {
|
if (row.calcKey === "po2" || row.calcKey === "fio2") {
|
const po2Row = this.tableData.find(r => r.calcKey === "po2");
|
const fio2Row = this.tableData.find(r => r.calcKey === "fio2");
|
const oiRow = this.tableData.find(r => r.type === "calculated");
|
|
if (po2Row && fio2Row && oiRow) {
|
const po2 = parseFloat(po2Row.values[colIndex]);
|
const fio2 = parseFloat(fio2Row.values[colIndex]);
|
if (!isNaN(po2) && !isNaN(fio2) && fio2 > 0) {
|
const oi = ((po2 / fio2) * 100).toFixed(1);
|
oiRow.values[colIndex] = oi;
|
} else {
|
oiRow.values[colIndex] = "";
|
}
|
}
|
}
|
},
|
saveData() {
|
const dataToEmit = {
|
type: "lung_lab",
|
data: this.tableData,
|
columns: this.dynamicColumns,
|
attachments: this.attachments
|
};
|
this.$emit("data-change", dataToEmit);
|
},
|
getPlaceholder(row) {
|
if (row.type === "description") return "请输入文字描述...";
|
return row.reference ? `参考: ${row.reference}` : "请输入数值";
|
},
|
// 由于篇幅限制,这里只列出关键差异方法
|
addColumn() {
|
this.editingColumnIndex = null;
|
this.columnForm = {
|
date: new Date().toISOString().split("T")[0],
|
time: "08:00",
|
remark: ""
|
};
|
this.columnDialogVisible = true;
|
this.$nextTick(
|
() => this.$refs.columnForm && this.$refs.columnForm.clearValidate()
|
);
|
},
|
handleEditColumn(index) {
|
if (!this.isEditing) return;
|
this.editingColumnIndex = index;
|
const col = this.dynamicColumns[index];
|
this.columnForm = {
|
date: col.date || "",
|
time: col.time || "",
|
remark: col.remark || ""
|
};
|
this.columnDialogVisible = true;
|
this.$nextTick(
|
() => this.$refs.columnForm && this.$refs.columnForm.clearValidate()
|
);
|
},
|
handleDeleteColumnByIndex(index) {
|
this.$confirm(
|
`确定要删除「${this.dynamicColumns[index].label.replace(
|
"\n",
|
" "
|
)}」这个时间点的所有数据吗?`,
|
"删除确认",
|
{
|
confirmButtonText: "确定删除",
|
cancelButtonText: "取消",
|
type: "warning"
|
}
|
)
|
.then(() => {
|
this.dynamicColumns.splice(index, 1);
|
this.tableData.forEach(row => {
|
if (row.values && row.values.length > index)
|
row.values.splice(index, 1);
|
});
|
this.tableKey += 1;
|
this.saveData();
|
this.$message({ type: "success", message: "时间点已删除" });
|
})
|
.catch(() => {});
|
},
|
confirmAddColumn() {
|
this.$refs.columnForm.validate(valid => {
|
if (!valid) {
|
this.$message.warning("请完善时间点信息");
|
return;
|
}
|
this.saveLoading = true;
|
if (this.editingColumnIndex !== null) {
|
const col = this.dynamicColumns[this.editingColumnIndex];
|
col.label = `${this.columnForm.date}\n${this.columnForm.time}`;
|
col.date = this.columnForm.date;
|
col.time = this.columnForm.time;
|
col.remark = this.columnForm.remark;
|
this.$message.success("时间点修改成功");
|
} else {
|
const newCol = {
|
label: `${this.columnForm.date}\n${this.columnForm.time}`,
|
key: `time${Date.now()}`,
|
date: this.columnForm.date,
|
time: this.columnForm.time,
|
remark: this.columnForm.remark
|
};
|
this.dynamicColumns.push(newCol);
|
this.tableData.forEach(row => {
|
if (!row.values) row.values = [];
|
row.values.push("");
|
});
|
this.$message.success("时间点添加成功");
|
}
|
this.columnDialogVisible = false;
|
this.saveLoading = false;
|
this.tableKey += 1;
|
this.saveData();
|
});
|
},
|
handleDeleteColumn() {
|
if (this.editingColumnIndex !== null) {
|
this.$confirm("确定要删除这个时间点吗?", "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
}).then(() => {
|
this.dynamicColumns.splice(this.editingColumnIndex, 1);
|
this.tableData.forEach(row =>
|
row.values.splice(this.editingColumnIndex, 1)
|
);
|
this.columnDialogVisible = false;
|
this.tableKey += 1;
|
this.saveData();
|
this.$message.success("时间点删除成功");
|
});
|
}
|
},
|
handleDialogClosed() {
|
this.editingColumnIndex = null;
|
this.columnForm = { date: "", time: "", remark: "" };
|
this.$refs.columnForm && this.$refs.columnForm.clearValidate();
|
},
|
disableFutureDates(time) {
|
return time.getTime() > Date.now();
|
},
|
handleValueChange(row, columnIndex) {
|
this.saveData();
|
},
|
forceTableLayout() {
|
this.$nextTick(() => {
|
const table = this.$el.querySelector(".el-table");
|
if (table) window.dispatchEvent(new Event("resize"));
|
});
|
},
|
handleHeaderDragEnd() {
|
this.forceTableLayout();
|
},
|
|
// 分类附件处理方法
|
// 修改 handleCategoryAttachmentChange 方法
|
handleCategoryAttachmentChange(category, fileList) {
|
if (category === "chestImg") this.chestImgFileList = fileList;
|
else if (category === "bronchoscopy")
|
this.bronchoscopyFileList = fileList;
|
},
|
|
// 修改 handleCategoryUploadSuccess 方法中的 fileList 赋值部分
|
handleCategoryUploadSuccess(category, { file, fileList, response }) {
|
if (response.code === 200) {
|
const obj = {
|
fileName: file.name,
|
path: response.fileUrl || file.url,
|
fileUrl: response.fileUrl || file.url,
|
fileSize: file.size,
|
uploadTime: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
};
|
if (!this.attachments[category]) this.attachments[category] = [];
|
this.attachments[category].push(obj);
|
if (category === "chestImg") this.chestImgFileList = fileList;
|
else if (category === "bronchoscopy")
|
this.bronchoscopyFileList = fileList;
|
this.saveData();
|
this.$message.success("文件上传成功");
|
}
|
},
|
|
// 修改 handleRemoveCategoryAttachment 方法
|
handleRemoveCategoryAttachment(category, index) {
|
this.attachments[category].splice(index, 1);
|
if (category === "chestImg") this.chestImgFileList.splice(index, 1);
|
else if (category === "bronchoscopy")
|
this.bronchoscopyFileList.splice(index, 1);
|
this.saveData();
|
this.$message.success("附件删除成功");
|
},
|
handleCategoryUploadError(category, { error }) {
|
console.error(`${category}附件上传失败:`, error);
|
this.$message.error("文件上传失败,请重试");
|
},
|
handleCategoryAttachmentRemove(category, file) {
|
if (file.url) {
|
const idx = this.attachments[category].findIndex(
|
a => a.path === file.url || a.fileUrl === file.url
|
);
|
if (idx > -1) {
|
this.attachments[category].splice(idx, 1);
|
this.saveData();
|
this.$message.success("附件删除成功");
|
}
|
}
|
},
|
|
// 文件预览/下载(复用原逻辑)
|
handlePreview(file) {
|
this.currentPreviewFile = {
|
fileName: file.fileName,
|
fileUrl: file.path || file.fileUrl,
|
fileType: this.getFileType(file.fileName)
|
};
|
this.previewVisible = true;
|
},
|
handleDownload(file) {
|
const url = file.path || file.fileUrl;
|
if (url) {
|
const link = document.createElement("a");
|
link.href = url;
|
link.download = file.fileName;
|
document.body.appendChild(link);
|
link.click();
|
document.body.removeChild(link);
|
} else {
|
this.$message.warning("文件路径不存在");
|
}
|
},
|
getFileType(fileName) {
|
if (!fileName) return "other";
|
const ext = fileName
|
.split(".")
|
.pop()
|
.toLowerCase();
|
if (["jpg", "jpeg", "png", "gif", "bmp", "webp"].includes(ext))
|
return "image";
|
if (ext === "pdf") return "pdf";
|
if (["doc", "docx", "xls", "xlsx", "ppt", "pptx"].includes(ext))
|
return "office";
|
return "other";
|
},
|
formatDateTime(dt) {
|
if (!dt) return "";
|
try {
|
const d = new Date(dt);
|
if (isNaN(d.getTime())) return dt;
|
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(
|
2,
|
"0"
|
)}-${String(d.getDate()).padStart(2, "0")} ${String(
|
d.getHours()
|
).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`;
|
} catch {
|
return dt;
|
}
|
},
|
formatFileSize(bytes) {
|
if (!bytes || bytes === 0) return "0 B";
|
const k = 1024;
|
const sizes = ["B", "KB", "MB", "GB"];
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
|
},
|
getFileIconColor(name) {
|
const map = {
|
image: "#67C23A",
|
pdf: "#F56C6C",
|
office: "#409EFF",
|
other: "#909399"
|
};
|
return map[this.getFileType(name)] || "#909399";
|
},
|
getFileTagType(name) {
|
const map = {
|
image: "success",
|
pdf: "danger",
|
office: "primary",
|
other: "info"
|
};
|
return map[this.getFileType(name)] || "info";
|
},
|
getFileTypeText(name) {
|
const map = { image: "图片", pdf: "PDF", office: "文档", other: "其他" };
|
return map[this.getFileType(name)] || "未知";
|
},
|
isPreviewable(fileName) {
|
return ["image", "pdf"].includes(this.getFileType(fileName));
|
},
|
exportData() {
|
return {
|
tableData: this.tableData,
|
columns: this.dynamicColumns,
|
statistics: {
|
filledCount: this.filledCount,
|
completionRate: this.completionRate,
|
totalColumns: this.dynamicColumns.length
|
},
|
exportTime: new Date().toISOString(),
|
attachments: this.attachments
|
};
|
}
|
},
|
mounted() {
|
this.$nextTick(() => {
|
if (Object.keys(this.internalData).length === 0) this.initTableData();
|
this.forceTableLayout();
|
});
|
}
|
};
|
</script>
|
|
<style scoped>
|
/* 复用 BloodRoutinePanel 样式 + HeartLabPanel 附件分组样式 */
|
.medical-panel {
|
padding: 20px;
|
background: #fff;
|
border-radius: 8px;
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
}
|
|
.panel-header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 24px;
|
padding-bottom: 16px;
|
border-bottom: 1px solid #ebeef5;
|
}
|
|
.panel-header h3 {
|
margin: 0;
|
color: #303133;
|
font-size: 20px;
|
font-weight: 600;
|
}
|
|
.panel-actions {
|
display: flex;
|
gap: 12px;
|
align-items: center;
|
}
|
|
.medical-table {
|
margin-bottom: 24px;
|
border-radius: 4px;
|
overflow: hidden;
|
}
|
|
.medical-table ::v-deep .el-table__body-wrapper {
|
overflow-x: auto;
|
}
|
|
.item-name-cell {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
}
|
|
.reference-icon {
|
color: #909399;
|
font-size: 14px;
|
cursor: help;
|
margin-left: 8px;
|
}
|
|
.required-item::before {
|
content: "*";
|
color: #f56c6c;
|
margin-right: 4px;
|
}
|
|
.cell-content-wrapper {
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
gap: 8px;
|
min-height: 32px;
|
}
|
|
.value-input {
|
flex: 1;
|
min-width: 80px;
|
}
|
|
.value-display-container {
|
display: flex;
|
align-items: center;
|
gap: 4px;
|
}
|
|
.value-text {
|
font-weight: 500;
|
color: #303133;
|
max-width: 80px;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
white-space: nowrap;
|
}
|
|
.unit-text {
|
color: #909399;
|
font-size: 12px;
|
flex-shrink: 0;
|
}
|
|
.validation-indicator {
|
flex-shrink: 0;
|
}
|
|
.valid-icon {
|
color: #67c23a;
|
font-size: 14px;
|
}
|
|
.invalid-icon {
|
color: #e6a23c;
|
font-size: 14px;
|
}
|
|
.statistics-section {
|
margin-bottom: 20px;
|
}
|
|
.stats-content {
|
display: flex;
|
gap: 20px;
|
align-items: center;
|
flex-wrap: wrap;
|
}
|
|
.stats-title {
|
font-weight: 600;
|
color: #303133;
|
}
|
|
.stats-item {
|
color: #606266;
|
font-size: 14px;
|
}
|
|
/* 附件上传区域样式优化 */
|
.attachment-section {
|
margin-top: 24px;
|
padding: 20px;
|
border: 1px solid #ebeef5;
|
border-radius: 4px;
|
background: #fafafa;
|
}
|
|
.attachment-header {
|
display: flex;
|
align-items: center;
|
gap: 8px;
|
margin-bottom: 16px;
|
}
|
|
.attachment-title {
|
font-weight: 600;
|
color: #409eff;
|
}
|
|
.attachment-tip {
|
font-size: 12px;
|
color: #909399;
|
}
|
|
.attachment-list {
|
margin-top: 16px;
|
}
|
|
.list-title {
|
font-weight: bold;
|
margin-bottom: 12px;
|
color: #303133;
|
font-size: 14px;
|
}
|
|
.file-name {
|
font-size: 13px;
|
margin-left: 8px;
|
}
|
/* 自定义列头样式 */
|
.custom-column-header {
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
gap: 4px;
|
padding: 4px 0;
|
}
|
|
.header-content {
|
display: flex;
|
align-items: center;
|
gap: 4px;
|
cursor: pointer;
|
transition: color 0.2s;
|
white-space: nowrap;
|
}
|
|
.header-content:hover {
|
color: #409eff;
|
}
|
|
.header-label {
|
font-size: 13px;
|
line-height: 1.4;
|
}
|
|
.header-remark-icon {
|
color: #909399;
|
font-size: 12px;
|
cursor: help;
|
}
|
|
.header-actions {
|
display: flex;
|
gap: 4px;
|
opacity: 0;
|
transition: opacity 0.2s;
|
}
|
|
.custom-column-header:hover .header-actions {
|
opacity: 1;
|
}
|
|
.header-btn {
|
padding: 2px 4px !important;
|
font-size: 14px !important;
|
}
|
|
.header-btn.delete-btn {
|
color: #f56c6c !important;
|
}
|
|
.header-btn.delete-btn:hover {
|
color: #c0392b !important;
|
}
|
|
/* 列头编辑按钮在编辑模式下始终显示 */
|
.is-editing .header-actions {
|
opacity: 1;
|
}
|
/* 响应式设计 */
|
@media (max-width: 768px) {
|
.medical-panel {
|
padding: 12px;
|
}
|
|
.panel-header {
|
flex-direction: column;
|
align-items: flex-start;
|
gap: 12px;
|
}
|
|
.panel-actions {
|
width: 100%;
|
justify-content: flex-end;
|
}
|
|
.stats-content {
|
flex-direction: column;
|
align-items: flex-start;
|
gap: 8px;
|
}
|
|
.cell-content-wrapper {
|
flex-direction: column;
|
gap: 4px;
|
}
|
}
|
.attachment-group-section {
|
margin-top: 24px;
|
padding: 20px;
|
border: 1px solid #ebeef5;
|
border-radius: 4px;
|
background: #fafafa;
|
}
|
.attachment-category {
|
margin-bottom: 20px;
|
}
|
.attachment-category:last-child {
|
margin-bottom: 0;
|
}
|
.category-title {
|
font-size: 15px;
|
font-weight: 600;
|
color: #409eff;
|
margin-bottom: 12px;
|
display: flex;
|
align-items: center;
|
gap: 6px;
|
}
|
.attachment-list-mini {
|
margin-top: 8px;
|
display: flex;
|
flex-wrap: wrap;
|
gap: 8px;
|
}
|
.cell-description-wrapper {
|
width: 100%;
|
}
|
.description-display {
|
white-space: pre-wrap;
|
text-align: left;
|
padding: 4px 8px;
|
background: #f5f7fa;
|
border-radius: 4px;
|
min-height: 60px;
|
max-height: 120px;
|
overflow-y: auto;
|
font-size: 13px;
|
color: #303133;
|
line-height: 1.5;
|
}
|
.calculated-value {
|
background: #f0f9eb;
|
padding: 4px 12px;
|
border-radius: 4px;
|
font-weight: bold;
|
color: #67c23a;
|
}
|
</style>
|