From 4c7a56862118f67765c614b3a1627a3189069814 Mon Sep 17 00:00:00 2001 From: Flow <958079825@qq.com> Date: Mon, 11 Aug 2025 14:55:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BF=83=E7=94=B5=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E7=AB=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/analysis/ECG_workstation.vue | 258 ++++++++++++++++--------- 1 file changed, 165 insertions(+), 93 deletions(-) diff --git a/src/views/analysis/ECG_workstation.vue b/src/views/analysis/ECG_workstation.vue index 0a29f3a..38d0198 100644 --- a/src/views/analysis/ECG_workstation.vue +++ b/src/views/analysis/ECG_workstation.vue @@ -137,23 +137,17 @@ > - - ({} as ProfileVO) //当前登录人信息 @@ -955,16 +949,30 @@ const formatDate = (date: Date | string) => { }) } -/** 格式化佩戴时间显示 */ -const formatWearTime = (date: Date | string) => { - if (!date) return '未设置' - const d = new Date(date) - const year = d.getFullYear() - const month = String(d.getMonth() + 1).padStart(2, '0') - const day = String(d.getDate()).padStart(2, '0') - const hour = String(d.getHours()).padStart(2, '0') - const minute = String(d.getMinutes()).padStart(2, '0') - const second = String(d.getSeconds()).padStart(2, '0') +// 时间格式化函数 +const formatMeasureTime = (time: any) => { + if (!time) return '' + + let date: Date + + // 如果是时间戳(数字),先转换为Date对象 + if (typeof time === 'number') { + // 判断是否为毫秒时间戳 + const timestamp = time.toString().length === 13 ? time : time * 1000 + date = new Date(timestamp) + } else { + // 如果是字符串或已经是Date对象,直接转换 + date = new Date(time) + } + + // 格式化为 YYYY-MM-DD HH:mm:ss 格式 + const year = date.getFullYear() + const month = String(date.getMonth() + 1).padStart(2, '0') + const day = String(date.getDate()).padStart(2, '0') + const hour = String(date.getHours()).padStart(2, '0') + const minute = String(date.getMinutes()).padStart(2, '0') + const second = String(date.getSeconds()).padStart(2, '0') + return `${year}-${month}-${day} ${hour}:${minute}:${second}` } @@ -1019,7 +1027,7 @@ const handleAnalysis = async (row) => { try { // 验证佩戴时间是否已设置 if (!row.wearstarttime) { - ElMessage.warning('请先设置佩戴开始时间后再进行分析') + ElMessage.warning('请先设置佩戴时间后再进行分析') return } @@ -1029,7 +1037,7 @@ const handleAnalysis = async (row) => { patientName: encodeURIComponent(row.name), // URL编码患者姓名 gender: row.gender === '1' ? '男' : row.gender === '2' ? '女' : '未知', age: row.age?.toString() || '', - examTime: row.wearstarttime ? formatWearTime(row.wearstarttime) : '', + examTime: row.wearstarttime ? formatMeasureTime(row.wearstarttime) : '', hospitalName: row.orgname || '', department: '内科' // 默认值,可以根据实际需求调整 } @@ -1560,53 +1568,42 @@ const handlePatientCancel = () => { console.log('取消选择患者') } -/** 开始编辑佩戴时间 */ -const startEditWearTime = ( - row: EcgworkstationVO & { isEditingWearTime?: boolean; tempWearTime?: any } -) => { - row.isEditingWearTime = true - row.tempWearTime = row.wearstarttime +// 佩戴时间编辑相关方法 +const editMeasureTime = (row: any, index: number) => { + // 保存原始值,用于取消时恢复 + row.originalMeasureTime = row.wearstarttime + row.editingMeasureTime = true } -/** 确认佩戴时间修改 */ -const confirmWearTimeChange = async ( - row: EcgworkstationVO & { isEditingWearTime?: boolean; tempWearTime?: any } -) => { +const saveMeasureTime = async (row: any, index: number) => { try { - if (!row.tempWearTime) { - ElMessage.warning('请选择佩戴时间') - return - } - - // 使用时间戳,避免时区和格式问题 - let formattedTime = row.tempWearTime - if (row.tempWearTime) { - // 转换为时间戳(毫秒) - formattedTime = new Date(row.tempWearTime).getTime() - } + // 将佩戴时间转换为时间戳 + const measureTimeTimestamp = row.wearstarttime ? new Date(row.wearstarttime).getTime() : null // 调用API更新佩戴时间 - await ecgdataApi.updatewearstarttime({ - id: row.id, - wearstarttime: formattedTime - }) + const updateData = { ...row, wearstarttime: measureTimeTimestamp } + await EcgworkstationApi.updateEcgworkstation(updateData) - row.wearstarttime = row.tempWearTime - row.isEditingWearTime = false - ElMessage.success('佩戴时间更新成功') - getList() + row.editingMeasureTime = false + delete row.originalMeasureTime + ElMessage.success(`已更新佩戴时间`) } catch (error) { console.error('更新佩戴时间失败:', error) - ElMessage.error('更新佩戴时间失败') + ElMessage.error('更新佩戴时间失败,请重试') + // 恢复原始值 + if (row.originalMeasureTime !== undefined) { + row.wearstarttime = row.originalMeasureTime + } } } -/** 取消佩戴时间修改 */ -const cancelWearTimeChange = ( - row: EcgworkstationVO & { isEditingWearTime?: boolean; tempWearTime?: any } -) => { - row.isEditingWearTime = false - row.tempWearTime = null +const cancelEditMeasureTime = (row: any, index: number) => { + // 恢复原始值 + if (row.originalMeasureTime !== undefined) { + row.wearstarttime = row.originalMeasureTime + } + row.editingMeasureTime = false + delete row.originalMeasureTime } /** 初始化 */ @@ -1944,30 +1941,6 @@ onMounted(async () => { color: #606266; } } - - .edit-button-wrapper { - display: flex; - align-items: center; - - .edit-btn { - width: 20px; - height: 20px; - padding: 0; - background: transparent; - border: none; - color: #909399; - transition: all 0.3s ease; - - &:hover { - color: #409eff; - transform: scale(1.1); - } - - .ep-edit { - font-size: 12px; - } - } - } } .wear-time-editor { @@ -2584,4 +2557,103 @@ onMounted(async () => { text-align: center; } } + +// 佩戴时间编辑样式 +.wear-time-display { + display: flex; + align-items: center; + justify-content: space-between; + gap: 8px; + padding: 4px; + border-radius: 6px; + transition: all 0.3s ease; + + .time-content { + flex: 1; + display: flex; + align-items: center; + justify-content: center; + + .time-text { + font-size: 12px; + color: #606266; + } + } + + .edit-button-wrapper { + display: flex; + align-items: center; + + .edit-btn { + width: 20px; + height: 20px; + padding: 0; + background: transparent; + border: none; + color: #909399; + transition: all 0.3s ease; + + &:hover { + color: #409eff; + transform: scale(1.1); + } + + .ep-edit { + font-size: 12px; + } + } + } +} + +.wear-time-editor { + display: flex; + align-items: center; + gap: 8px; + + .edit-actions { + display: flex; + gap: 4px; + + .confirm-btn { + width: 24px; + height: 24px; + padding: 0; + background: linear-gradient(135deg, #67c23a, #85ce61); + border: none; + + &:hover { + background: linear-gradient(135deg, #5daf34, #73c25a); + transform: scale(1.05); + } + + .ep-check { + font-size: 10px; + } + } + + .cancel-btn { + width: 24px; + height: 24px; + padding: 0; + background: linear-gradient(135deg, #f56c6c, #f78989); + border: none; + + &:hover { + background: linear-gradient(135deg, #e45656, #f56c6c); + transform: scale(1.05); + } + + .ep-close { + font-size: 10px; + } + } + } +} + +// 隐藏时间选择器的tooltip +:deep(.no-tooltip) { + .el-tooltip__popper { + display: none !important; + } +}