From 45680b99ccdfb0d323088c57c237e0bc714a8e0b Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期五, 13 三月 2026 09:21:32 +0800
Subject: [PATCH] 青岛opo维护
---
src/views/business/maintain/components/LiverKidneyPanel.vue | 570 +++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 431 insertions(+), 139 deletions(-)
diff --git a/src/views/business/maintain/components/LiverKidneyPanel.vue b/src/views/business/maintain/components/LiverKidneyPanel.vue
index a485fed..6a1ac0c 100644
--- a/src/views/business/maintain/components/LiverKidneyPanel.vue
+++ b/src/views/business/maintain/components/LiverKidneyPanel.vue
@@ -30,7 +30,7 @@
class-name="leave-alone"
>
<template #default="scope">
- <span :class="{'required-item': scope.row.required}">
+ <span :class="{ 'required-item': scope.row.required }">
{{ scope.row.itemName }}
</span>
</template>
@@ -54,8 +54,11 @@
class="value-input"
/>
<span v-else class="value-display">
- {{ scope.row.values[index] || '-' }}
- <span v-if="scope.row.values[index] && scope.row.unit" class="unit">
+ {{ scope.row.values[index] || "-" }}
+ <span
+ v-if="scope.row.values[index] && scope.row.unit"
+ class="unit"
+ >
{{ scope.row.unit }}
</span>
</span>
@@ -65,23 +68,91 @@
</div>
</template>
</el-table-column>
-
-
</el-table>
- <!-- 闄勪欢涓婁紶鍖哄煙 -->
+ <!-- 闄勪欢涓婁紶鍖哄煙浼樺寲 -->
<div class="attachment-section">
- <div class="attachment-title">
+ <div class="attachment-header">
<i class="el-icon-paperclip"></i>
- 闄勪欢涓婁紶
- <span class="attachment-tip">鏀寔涓婁紶妫�楠屾姤鍛婂崟绛夋枃浠�</span>
+ <span class="attachment-title">闄勪欢涓婁紶</span>
+ <span class="attachment-tip"
+ >鏀寔涓婁紶妫�楠屾姤鍛婂崟绛夋枃浠� (鏈�澶歿{ attachmentLimit }}涓�)</span
+ >
</div>
- <upload-attachment
- :file-list="attachments"
+
+ <!-- 浣跨敤 UploadAttachment 缁勪欢 -->
+ <UploadAttachment
+ ref="uploadAttachment"
+ :file-list="attachmentFileList"
+ :limit="attachmentLimit"
+ :accept="attachmentAccept"
+ :multiple="true"
@change="handleAttachmentChange"
- :limit="10"
- :accept="'.pdf,.jpg,.jpeg,.png,.doc,.docx'"
+ @upload-success="handleUploadSuccess"
+ @upload-error="handleUploadError"
+ @remove="handleAttachmentRemove"
/>
+
+ <!-- 闄勪欢鍒楄〃灞曠ず -->
+ <div class="attachment-list" v-if="attachments && attachments.length > 0">
+ <div class="list-title">宸蹭笂浼犻檮浠� ({{ attachments.length }})</div>
+ <el-table :data="attachments" 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="handleRemoveAttachment(scope.$index)"
+ >
+ 鍒犻櫎
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
</div>
<!-- 鍒楃紪杈戝璇濇 -->
@@ -95,7 +166,9 @@
<el-form-item
label="鏃ユ湡"
prop="date"
- :rules="[{ required: true, message: '璇烽�夋嫨鏃ユ湡', trigger: 'change' }]"
+ :rules="[
+ { required: true, message: '璇烽�夋嫨鏃ユ湡', trigger: 'change' }
+ ]"
>
<el-date-picker
v-model="columnForm.date"
@@ -108,7 +181,9 @@
<el-form-item
label="鏃堕棿"
prop="time"
- :rules="[{ required: true, message: '璇烽�夋嫨鏃堕棿', trigger: 'change' }]"
+ :rules="[
+ { required: true, message: '璇烽�夋嫨鏃堕棿', trigger: 'change' }
+ ]"
>
<el-time-picker
v-model="columnForm.time"
@@ -123,16 +198,27 @@
<el-button type="primary" @click="confirmAddColumn">纭畾</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: 'LiverKidneyPanel',
+ name: "LiverKidneyPanel",
components: {
UploadAttachment,
+ FilePreviewDialog
},
props: {
isEditing: {
@@ -140,151 +226,167 @@
default: false
},
initialData: {
- type: Array,
- default: () => []
+ type: Object,
+ default: () => ({})
}
},
data() {
return {
tableData: [],
- dynamicColumns: [
- {
- label: '2024-12-27\n08:00',
- key: 'time1',
- date: '2024-12-27',
- time: '08:00'
- },
- {
- label: '2024-12-27\n14:00',
- key: 'time2',
- date: '2024-12-27',
- time: '14:00'
- }
- ],
+ dynamicColumns: [],
attachments: [],
columnDialogVisible: false,
columnForm: {
- date: '',
- time: ''
+ date: "",
+ time: ""
},
- tableKey: 0 // 鐢ㄤ簬寮哄埗閲嶆柊娓叉煋琛ㄦ牸
+ tableKey: 0,
+ internalData: {},
+
+ // 棰勮鐩稿叧
+ previewVisible: false,
+ currentPreviewFile: null,
+
+ // 闄勪欢鐩稿叧閰嶇疆
+ attachmentLimit: 10,
+ attachmentAccept:
+ ".pdf,.jpg,.jpeg,.png,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt",
+ attachmentFileList: []
};
},
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.$emit('data-change', {
- type: 'liver_kidney',
- data: this.tableData,
- columns: this.dynamicColumns,
- attachments: this.attachments
- });
+ this.saveData();
}
- // 缂栬緫妯″紡鍒囨崲鏃堕噸鏂拌绠楀垪瀹�
this.$nextTick(() => {
this.forceTableLayout();
});
},
dynamicColumns: {
handler() {
- // 鍒楀彉鍖栨椂閲嶆柊璁$畻甯冨眬
this.$nextTick(() => {
this.forceTableLayout();
});
},
deep: true
+ },
+ // 鐩戝惉闄勪欢鏁版嵁鍙樺寲
+ attachments: {
+ handler(newAttachments) {
+ this.attachmentFileList = newAttachments.map(item => ({
+ uid: item.id || Math.random(),
+ name: item.fileName,
+ fileSize: item.fileSize,
+ url: item.path || item.fileUrl,
+ uploadTime: item.uploadTime,
+ status: "success"
+ }));
+ },
+ deep: 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 = [...this.internalData.attachments];
+ }
+ },
+
+ // 鍒濆鍖栭粯璁よ〃鏍兼暟鎹�
initTableData() {
const medicalItems = [
{
- itemName: '琛�閽�',
- unit: 'mmol/L',
+ itemName: "琛�閽�",
+ unit: "mmol/L",
required: true,
- reference: '135-145'
+ reference: "135-145"
},
{
- itemName: '琛�閽�',
- unit: 'mmol/L',
+ itemName: "琛�閽�",
+ unit: "mmol/L",
required: true,
- reference: '3.5-5.5'
+ reference: "3.5-5.5"
},
+ { itemName: "BUN", unit: "mg/dL", required: true, reference: "<20" },
+ { itemName: "鑲岄厫", unit: "渭mol/L", required: true, reference: "<100" },
{
- itemName: 'BUN',
- unit: 'mg/dL',
+ itemName: "鎬昏儐绾㈢礌",
+ unit: "渭mol/L",
required: true,
- reference: '<20'
+ reference: "<21"
},
- {
- itemName: '鑲岄厫',
- unit: '渭mol/L',
- required: true,
- reference: '<100'
- },
- {
- itemName: '鎬昏儐绾㈢礌',
- unit: '渭mol/L',
- required: true,
- reference: '<21'
- },
- {
- itemName: 'ALT',
- unit: 'U/L',
- required: true,
- reference: '<50'
- },
- {
- itemName: 'AST',
- unit: 'U/L',
- required: true,
- reference: '<40'
- },
- {
- itemName: 'GGT',
- unit: 'U/L',
- required: true,
- reference: '<57'
- },
- {
- itemName: 'ALP',
- unit: 'U/L',
- required: true,
- reference: '<120'
- },
- {
- itemName: 'PT',
- unit: '绉�',
- required: true,
- reference: '9.4-12.5'
- },
- {
- itemName: 'INR',
- unit: '',
- required: true,
- reference: '0.85-1.15'
- }
+ { itemName: "ALT", unit: "U/L", required: true, reference: "<50" },
+ { itemName: "AST", unit: "U/L", required: true, reference: "<40" },
+ { itemName: "GGT", unit: "U/L", required: true, reference: "<57" },
+ { itemName: "ALP", unit: "U/L", required: true, reference: "<120" },
+ { itemName: "PT", unit: "绉�", required: true, reference: "9.4-12.5" },
+ { itemName: "INR", unit: "", required: true, reference: "0.85-1.15" }
];
+
+ 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"
+ }
+ ];
+ }
this.tableData = medicalItems.map(item => ({
...item,
- values: new Array(this.dynamicColumns.length).fill('')
+ values: new Array(this.dynamicColumns.length).fill("")
}));
+ },
+
+ // 淇濆瓨鏁版嵁鍒扮埗缁勪欢
+ saveData() {
+ const dataToEmit = {
+ type: "liver_kidney",
+ data: this.tableData,
+ columns: this.dynamicColumns,
+ attachments: this.attachments
+ };
+ this.$emit("data-change", dataToEmit);
},
addColumn() {
this.columnForm = {
- date: new Date().toISOString().split('T')[0],
- time: '08:00'
+ date: new Date().toISOString().split("T")[0],
+ time: "08:00"
};
this.columnDialogVisible = true;
},
confirmAddColumn() {
- this.$refs.columnForm.validate((valid) => {
+ this.$refs.columnForm.validate(valid => {
if (!valid) {
- this.$message.warning('璇峰畬鍠勬椂闂寸偣淇℃伅');
+ this.$message.warning("璇峰畬鍠勬椂闂寸偣淇℃伅");
return;
}
@@ -300,59 +402,222 @@
// 涓烘墍鏈夎鏂板涓�涓┖鍊�
this.tableData.forEach(row => {
- row.values.push('');
+ if (!row.values) {
+ row.values = [];
+ }
+ row.values.push("");
});
this.columnDialogVisible = false;
- this.$message.success('鏃堕棿鐐规坊鍔犳垚鍔�');
-
- // 寮哄埗琛ㄦ牸閲嶆柊娓叉煋
+ this.$message.success("鏃堕棿鐐规坊鍔犳垚鍔�");
this.tableKey += 1;
+ this.saveData();
});
},
handleDialogClosed() {
- this.columnForm = {
- date: '',
- time: ''
- };
+ this.columnForm = { date: "", time: "" };
this.$refs.columnForm && this.$refs.columnForm.clearValidate();
},
handleValueChange(row, columnIndex) {
- this.$emit('data-change', {
- type: 'liver_kidney',
- data: this.tableData,
- columns: this.dynamicColumns
- });
+ this.saveData();
},
+ /** 闄勪欢鍙樺寲澶勭悊 */
handleAttachmentChange(fileList) {
- this.attachments = fileList;
- this.$emit('attachment-change', {
- type: 'liver_kidney',
- attachments: fileList
- });
+ this.attachmentFileList = fileList;
},
- // 寮哄埗琛ㄦ牸閲嶆柊甯冨眬[1,3](@ref)
+ /** 闄勪欢绉婚櫎澶勭悊 */
+ handleAttachmentRemove(file) {
+ if (file.url) {
+ const index = this.attachments.findIndex(
+ item => item.path === file.url || item.fileUrl === file.url
+ );
+ if (index > -1) {
+ this.attachments.splice(index, 1);
+ this.saveData();
+ this.$message.success("闄勪欢鍒犻櫎鎴愬姛");
+ }
+ }
+ },
+
+ /** 涓婁紶鎴愬姛澶勭悊 */
+ handleUploadSuccess({ file, fileList, response }) {
+ if (response.code === 200) {
+ const attachmentObj = {
+ fileName: file.name,
+ path: response.fileUrl || file.url,
+ fileUrl: response.fileUrl || file.url,
+ fileType: this.getFileExtension(file.name),
+ fileSize: file.size,
+ uploadTime: dayjs().format("YYYY-MM-DD HH:mm:ss")
+ };
+
+ // 纭繚 attachments 鏄暟缁�
+ if (!Array.isArray(this.attachments)) {
+ this.attachments = [];
+ }
+
+ this.attachments.push(attachmentObj);
+ this.attachmentFileList = fileList;
+ this.saveData();
+ this.$message.success("鏂囦欢涓婁紶鎴愬姛");
+ }
+ },
+
+ /** 涓婁紶閿欒澶勭悊 */
+ handleUploadError({ file, fileList, error }) {
+ console.error("闄勪欢涓婁紶澶辫触:", error);
+ this.$message.error("鏂囦欢涓婁紶澶辫触锛岃閲嶈瘯");
+ },
+
+ /** 鎵嬪姩鍒犻櫎闄勪欢 */
+ handleRemoveAttachment(index) {
+ this.attachments.splice(index, 1);
+ this.attachmentFileList.splice(index, 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 fileUrl = file.path || file.fileUrl;
+ const fileName = file.fileName;
+
+ if (fileUrl) {
+ const link = document.createElement("a");
+ link.href = fileUrl;
+ link.download = fileName;
+ link.style.display = "none";
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ this.$message.success("寮�濮嬩笅杞芥枃浠�");
+ } else {
+ this.$message.warning("鏂囦欢璺緞涓嶅瓨鍦紝鏃犳硶涓嬭浇");
+ }
+ },
+
+ /** 鑾峰彇鏂囦欢绫诲瀷 */
+ getFileType(fileName) {
+ if (!fileName) return "other";
+ const extension = fileName
+ .split(".")
+ .pop()
+ .toLowerCase();
+ const imageTypes = ["jpg", "jpeg", "png", "gif", "bmp", "webp"];
+ const pdfTypes = ["pdf"];
+ const officeTypes = ["doc", "docx", "xls", "xlsx", "ppt", "pptx"];
+ if (imageTypes.includes(extension)) return "image";
+ if (pdfTypes.includes(extension)) return "pdf";
+ if (officeTypes.includes(extension)) return "office";
+ return "other";
+ },
+
+ /** 鑾峰彇鏂囦欢鍥炬爣棰滆壊 */
+ getFileIconColor(fileName) {
+ const type = this.getFileType(fileName);
+ const colorMap = {
+ image: "#67C23A",
+ pdf: "#F56C6C",
+ office: "#409EFF",
+ other: "#909399"
+ };
+ return colorMap[type] || "#909399";
+ },
+
+ /** 鑾峰彇鏂囦欢鏍囩绫诲瀷 */
+ getFileTagType(fileName) {
+ const type = this.getFileType(fileName);
+ const typeMap = {
+ image: "success",
+ pdf: "danger",
+ office: "primary",
+ other: "info"
+ };
+ return typeMap[type] || "info";
+ },
+
+ /** 鑾峰彇鏂囦欢绫诲瀷鏂囨湰 */
+ getFileTypeText(fileName) {
+ const type = this.getFileType(fileName);
+ const textMap = {
+ image: "鍥剧墖",
+ pdf: "PDF",
+ office: "鏂囨。",
+ other: "鍏朵粬"
+ };
+ return textMap[type] || "鏈煡";
+ },
+
+ /** 妫�鏌ユ槸鍚﹀彲棰勮 */
+ isPreviewable(fileName) {
+ const type = this.getFileType(fileName);
+ return ["image", "pdf"].includes(type);
+ },
+
+ /** 鑾峰彇鏂囦欢鎵╁睍鍚� */
+ getFileExtension(filename) {
+ return filename
+ .split(".")
+ .pop()
+ .toLowerCase();
+ },
+
+ /** 鏍煎紡鍖栨枃浠跺ぇ灏� */
+ 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];
+ },
+
+ /** 鏃ユ湡鏃堕棿鏍煎紡鍖� */
+ formatDateTime(dateTime) {
+ if (!dateTime) return "";
+ try {
+ const date = new Date(dateTime);
+ if (isNaN(date.getTime())) return dateTime;
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, "0");
+ const day = String(date.getDate()).padStart(2, "0");
+ const hours = String(date.getHours()).padStart(2, "0");
+ const minutes = String(date.getMinutes()).padStart(2, "0");
+ return `${year}-${month}-${day} ${hours}:${minutes}`;
+ } catch (error) {
+ return dateTime;
+ }
+ },
+
forceTableLayout() {
this.$nextTick(() => {
- const table = this.$el.querySelector('.el-table');
- if (table && table.querySelector('colgroup')) {
- // 瑙﹀彂琛ㄦ牸閲嶆柊璁$畻甯冨眬
+ const table = this.$el.querySelector(".el-table");
+ if (table && table.querySelector("colgroup")) {
this.$nextTick(() => {
- window.dispatchEvent(new Event('resize'));
+ window.dispatchEvent(new Event("resize"));
});
}
});
},
handleHeaderDragEnd() {
- // 鍒楀鎷栨嫿缁撴潫鍚庨噸鏂拌绠楀竷灞�
this.forceTableLayout();
},
+ // 鎻愪緵鏁版嵁瀵煎嚭鏂规硶渚涚埗缁勪欢璋冪敤
exportData() {
return {
tableData: this.tableData,
@@ -363,9 +628,10 @@
}
},
mounted() {
- this.initTableData();
- // 鍒濆娓叉煋鍚庤绠楀垪瀹�
this.$nextTick(() => {
+ if (Object.keys(this.internalData).length === 0) {
+ this.initTableData();
+ }
this.forceTableLayout();
});
}
@@ -441,6 +707,7 @@
margin-right: 4px;
}
+/* 闄勪欢涓婁紶鍖哄煙鏍峰紡浼樺寲 */
.attachment-section {
margin-top: 30px;
padding: 20px;
@@ -449,22 +716,43 @@
background: #fafafa;
}
-.attachment-title {
- font-weight: bold;
- margin-bottom: 15px;
- color: #409eff;
+.attachment-header {
display: flex;
align-items: center;
+ margin-bottom: 16px;
+ padding-bottom: 8px;
+ border-bottom: 1px solid #ebeef5;
+}
+
+.attachment-title {
+ font-weight: bold;
+ margin: 0 8px;
+ color: #303133;
}
.attachment-tip {
font-size: 12px;
color: #909399;
- margin-left: 10px;
- font-weight: normal;
+ margin-left: auto;
}
-/* 鍝嶅簲寮忚璁� */
+.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;
+}
+
+/* 鍝嶅簲寮忚皟鏁� */
@media (max-width: 768px) {
.medical-panel {
padding: 10px;
@@ -488,5 +776,9 @@
margin-left: 0;
margin-top: 4px;
}
+
+ .attachment-section {
+ padding: 10px;
+ }
}
</style>
--
Gitblit v1.9.3