修改历史档案方法
This commit is contained in:
parent
f07af4cd61
commit
9339f28e9b
@ -13,7 +13,7 @@ api.interceptors.request.use(
|
||||
if (window.electronAPI) {
|
||||
config.baseURL = window.electronAPI.getBackendUrl()
|
||||
} else {
|
||||
config.baseURL = 'http://localhost:5000'
|
||||
config.baseURL = 'http://192.168.1.173:5000'
|
||||
}
|
||||
|
||||
// 只为需要发送数据的请求设置Content-Type
|
||||
@ -601,13 +601,28 @@ export const downloadFile = (url, filename) => {
|
||||
window.URL.revokeObjectURL(downloadUrl)
|
||||
})
|
||||
}
|
||||
//
|
||||
export const historyAPI = {
|
||||
// 获取检测会话历史
|
||||
sessionsPage(params) {
|
||||
return api.get('/api/history/sessions', { params })
|
||||
},
|
||||
// 获取检测数据历史
|
||||
detectionDelById(id) {
|
||||
return api.delete(`/api/detection/data/${id}`, {})
|
||||
},
|
||||
// 获取检测会话历史
|
||||
sessionById(id) {
|
||||
return api.get(`/api/history/sessions/${id}`)
|
||||
},
|
||||
}
|
||||
|
||||
// 获取后端URL的函数
|
||||
export const getBackendUrl = () => {
|
||||
if (window.electronAPI) {
|
||||
return window.electronAPI.getBackendUrl()
|
||||
} else {
|
||||
return 'http://localhost:5000'
|
||||
return 'http://192.168.1.173:5000'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,37 +21,41 @@
|
||||
<!-- 患者基本信息 -->
|
||||
<div v-for="(item, index) in profileInfo" :key="index" class="content-info">
|
||||
<div class="content-left">
|
||||
<el-checkbox v-model="item.checked" label="" />
|
||||
<!-- <el-checkbox v-model="item.checked" label="" /> -->
|
||||
<div class="content-left-text1">{{ index + 1 }}</div>
|
||||
<div class="content-left-text2">2025/04/01 14:35</div>
|
||||
<div class="content-left-text3">初次就诊</div>
|
||||
<div class="content-left-text2">{{ item.created_at }}</div>
|
||||
<div class="content-left-text3" v-if="index==0">最近会诊</div>
|
||||
<div class="content-left-text3" v-else>{{ calculateExactDaysDifference(item.created_at) }}</div>
|
||||
<!-- <el-button type="danger" style="margin-top: 20px;" @click="deleteClick(item,index)">删除</el-button> -->
|
||||
|
||||
</div>
|
||||
<div class="content-center">
|
||||
|
||||
<video ref="videoPlayerRef" :src=" BACKEND_URL+'/' + item.screen_video_path" controls width="100%" height="100%">
|
||||
您的浏览器不支持视频播放
|
||||
</video>
|
||||
</div>
|
||||
<div class="content-right">
|
||||
<div class="content-right-top">
|
||||
<div class="content-right-top-title">
|
||||
<div class="content-right-top-text">诊断信息:</div>
|
||||
<div style="display: flex;align-items: center;">
|
||||
<div class="content-right-top-text2">未处理</div>
|
||||
<div style="margin-left: 10px;" @click="editClick">
|
||||
<img src="@/assets/svg/edit.svg" alt="">
|
||||
</div>
|
||||
<div class="content-right-top-text2" v-if="item.status != 'completed'">未处理</div>
|
||||
<div class="content-right-top-text3" v-if="item.status == 'completed'">已处理</div>
|
||||
<img v-if="item.status != 'completed'" src="@/assets/svg/edit.svg" alt="" style="margin-left: 10px;cursor: pointer;" @click="editClick(item,index)">
|
||||
</div>
|
||||
</div>
|
||||
<div class="content-right-top-content">
|
||||
<el-form :model="diagnosticForm" label-width="50px">
|
||||
<el-form :model="item" label-width="50px">
|
||||
<el-form-item label="记录">
|
||||
<el-input v-model="diagnosticForm.diagnosis_info" disabled :rows="6" type="textarea"
|
||||
<el-input v-model="item.diagnosis_info" disabled :rows="6" type="textarea"
|
||||
placeholder="请输入" />
|
||||
</el-form-item>
|
||||
<el-form-item label="处理">
|
||||
<el-input v-model="diagnosticForm.treatment_info" disabled :rows="6" type="textarea"
|
||||
<el-input v-model="item.treatment_info" disabled :rows="6" type="textarea"
|
||||
placeholder="请输入" />
|
||||
</el-form-item>
|
||||
<el-form-item label="建议">
|
||||
<el-input v-model="diagnosticForm.suggestion_info" disabled :rows="6" type="textarea"
|
||||
<el-input v-model="item.suggestion_info" disabled :rows="6" type="textarea"
|
||||
placeholder="请输入" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@ -324,9 +328,10 @@
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { patientAPI, detectionAPI } from '../services/api.js'
|
||||
import { patientAPI, detectionAPI,historyAPI } from '../services/api.js'
|
||||
import Header from '@/views/Header.vue'
|
||||
|
||||
import { getBackendUrl } from '../services/api.js'
|
||||
const BACKEND_URL = getBackendUrl()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
@ -359,6 +364,57 @@ const diagnosticForm = ref({
|
||||
treatment_info: '',
|
||||
suggestion_info: ''
|
||||
})
|
||||
|
||||
|
||||
const calculateExactDaysDifference = (date2) => {
|
||||
// 解析日期字符串
|
||||
const parseDate = (dateStr) => {
|
||||
if (!dateStr) return new Date();
|
||||
const parts = dateStr.split(' ');
|
||||
const datePart = parts[0].split('-');
|
||||
const timePart = parts[1].split(':');
|
||||
|
||||
return new Date(
|
||||
parseInt(datePart[0]), // 年
|
||||
parseInt(datePart[1]) - 1, // 月 (0-indexed)
|
||||
parseInt(datePart[2]), // 日
|
||||
parseInt(timePart[0]), // 小时
|
||||
parseInt(timePart[1]), // 分钟
|
||||
parseInt(timePart[2]) // 秒
|
||||
);
|
||||
};
|
||||
|
||||
const d1 = new Date();
|
||||
const d2 = parseDate(date2);
|
||||
|
||||
// 计算时间差(毫秒)
|
||||
const timeDiff = Math.abs(d1.getTime() - d2.getTime());
|
||||
|
||||
// 转换为天数
|
||||
const daysDiff = Math.floor(timeDiff / (1000 * 3600 * 24));
|
||||
return daysDiff + "天";
|
||||
}
|
||||
|
||||
const sessionsInit = async () => {
|
||||
try {
|
||||
let params ={
|
||||
patient_id: route.params.id
|
||||
}
|
||||
// 导出报告逻辑
|
||||
const response = await historyAPI.sessionsPage(params)
|
||||
if (response.success) {
|
||||
response.data.sessions.forEach(element => {
|
||||
element.list = [{}]
|
||||
});
|
||||
profileInfo.value = response.data.sessions
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('获取失败')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const handleClose = () => {
|
||||
dialogVisible.value = false
|
||||
@ -598,7 +654,15 @@ const loadDetectionRecords = async () => {
|
||||
}
|
||||
}
|
||||
//修改诊断信息
|
||||
function editClick() {
|
||||
function editClick(row,index) {
|
||||
diagnosticForm.value = {
|
||||
id: row.id,
|
||||
diagnosis_info: row.diagnosis_info,
|
||||
treatment_info: row.treatment_info,
|
||||
suggestion_info: row.suggestion_info,
|
||||
status: row.status,
|
||||
index: index
|
||||
}
|
||||
dialogVisible.value = true
|
||||
}
|
||||
//数据详情
|
||||
@ -607,52 +671,148 @@ function patientdetails() {
|
||||
}
|
||||
async function handleDiagnosticInfo(status) {
|
||||
try {
|
||||
// // 检查是否有活跃的会话ID
|
||||
// if (!patientInfo.value.sessionId) {
|
||||
// throw new Error('缺少会话Id')
|
||||
// }
|
||||
// // 调用后端API采集检测数据
|
||||
// const response = await fetch(`${BACKEND_URL}/api/detection/${patientInfo.value.sessionId}/save-info`, {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json'
|
||||
// },
|
||||
// body: JSON.stringify({
|
||||
// diagnosis_info:diagnosticForm.diagnosis_info,
|
||||
// treatment_info:diagnosticForm.treatment_info,
|
||||
// suggestion_info:diagnosticForm.suggestion_info,
|
||||
// status:status,
|
||||
// session_id:patientInfo.value.sessionId,
|
||||
// })
|
||||
// })
|
||||
// if (!response.ok) {
|
||||
// throw new Error(`HTTP ${response.status}: ${response.statusText}`)
|
||||
// }
|
||||
// 检查是否有活跃的会话ID
|
||||
if (!diagnosticForm.value.id) {
|
||||
throw new Error('缺少会话Id')
|
||||
}
|
||||
// 调用后端API采集检测数据
|
||||
const response = await fetch(`${BACKEND_URL}/api/detection/${diagnosticForm.value.id}/save-info`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
diagnosis_info:diagnosticForm.value.diagnosis_info,
|
||||
treatment_info:diagnosticForm.value.treatment_info,
|
||||
suggestion_info:diagnosticForm.value.suggestion_info,
|
||||
status:status,
|
||||
id:diagnosticForm.value.id,
|
||||
})
|
||||
})
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`)
|
||||
}
|
||||
|
||||
// const result = await response.json()
|
||||
// if (result.success) {
|
||||
// // 显示成功消息
|
||||
// ElMessage.success({
|
||||
// message: status + '诊断信息成功',
|
||||
// duration: 5000
|
||||
// })
|
||||
// patientInfo.value.sessionId = null
|
||||
// } else {
|
||||
// throw new Error(result.message || '诊断信息失败')
|
||||
// }
|
||||
const result = await response.json()
|
||||
if (result.success) {
|
||||
profileInfo.value[diagnosticForm.value.index].diagnosis_info = diagnosticForm.value.diagnosis_info
|
||||
profileInfo.value[diagnosticForm.value.index].treatment_info = diagnosticForm.value.treatment_info
|
||||
profileInfo.value[diagnosticForm.value.index].suggestion_info = diagnosticForm.value.suggestion_info
|
||||
profileInfo.value[diagnosticForm.value.index].status = status
|
||||
ElMessage.success({
|
||||
message: '诊断信息成功',
|
||||
duration: 5000
|
||||
})
|
||||
dialogVisible.value =false
|
||||
} else {
|
||||
throw new Error(result.message || '诊断信息失败')
|
||||
}
|
||||
} catch (error) {
|
||||
// ElMessage.error({
|
||||
// message: errorMessage,
|
||||
// duration: 5000
|
||||
// })
|
||||
// patientInfo.value.sessionId = null
|
||||
ElMessage.error({
|
||||
message: errorMessage,
|
||||
duration: 5000
|
||||
})
|
||||
} finally {
|
||||
// patientInfo.value.sessionId = null
|
||||
}
|
||||
}
|
||||
|
||||
// 暂停视频
|
||||
const pauseVideo = (index) => {
|
||||
if (videoPlayerRef.value) {
|
||||
videoPlayerRef.value[index].pause()
|
||||
}
|
||||
}
|
||||
|
||||
// 播放视频
|
||||
const playNewVideo = () => {
|
||||
if (videoPlayerRef.value) {
|
||||
videoPlayerRef.value[index].play()
|
||||
}
|
||||
}
|
||||
|
||||
const deleteClick = async (row) => {
|
||||
|
||||
ElMessageBox.confirm(
|
||||
'确定义删除此条数据?',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
).then(() => {
|
||||
historyAPI.detectionDelById(row.id).then((response)=>{
|
||||
console.log(response.data)
|
||||
}).catch(()=>{
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// try {
|
||||
// // 检查是否有活跃的会话ID
|
||||
// if (!row.id) {
|
||||
// throw new Error('缺少会话Id');
|
||||
// }
|
||||
|
||||
// // 显示确认对话框
|
||||
// await ElMessageBox.confirm(
|
||||
// '确定要删除此条数据?',
|
||||
// '警告',
|
||||
// {
|
||||
// confirmButtonText: '确定',
|
||||
// cancelButtonText: '取消',
|
||||
// type: 'warning',
|
||||
// }
|
||||
// );
|
||||
|
||||
// // 调用后端API删除数据
|
||||
// const response = await fetch(`${BACKEND_URL}/api/detection/data/${row.id}`, {
|
||||
// method: 'DELETE',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json'
|
||||
// },
|
||||
// });
|
||||
|
||||
// if (!response.ok) {
|
||||
// throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
// }
|
||||
|
||||
// const result = await response.json();
|
||||
// if (result.success) {
|
||||
// ElMessage.success({
|
||||
// message: '删除成功',
|
||||
// duration: 5000
|
||||
// });
|
||||
// } else {
|
||||
// throw new Error(result.message || '删除失败');
|
||||
// }
|
||||
// } catch (error) {
|
||||
// // 如果是用户取消操作,不显示错误
|
||||
// if (error === 'cancel' || error === 'close') {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// ElMessage.error({
|
||||
// message: error.message || '删除过程中发生错误',
|
||||
// duration: 5000
|
||||
// });
|
||||
// }
|
||||
}
|
||||
// // 其他控制方法
|
||||
// const togglePlayPause = () => {
|
||||
// if (videoPlayerRef.value) {
|
||||
// if (videoPlayerRef.value.paused) {
|
||||
// videoPlayerRef.value.play()
|
||||
// } else {
|
||||
// videoPlayerRef.value.pause()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 生命周期
|
||||
onMounted(() => {
|
||||
loadPatientInfo()
|
||||
sessionsInit()
|
||||
// loadDetectionRecords()
|
||||
})
|
||||
</script>
|
||||
@ -734,7 +894,19 @@ onMounted(() => {
|
||||
color: #E6A23C;
|
||||
text-align: center;
|
||||
border-radius: 5px;
|
||||
border: 1px solid rgba(230, 162, 60, 0.3);
|
||||
}
|
||||
.content-right-top-text3 {
|
||||
width: 62px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
background: rgba(103, 194, 58, 0.1);
|
||||
color: rgb(103, 194, 58);
|
||||
text-align: center;
|
||||
border-radius: 5px;
|
||||
border: 1px solid rgba(103, 194, 58, 0.3);
|
||||
}
|
||||
|
||||
|
||||
.content-right-top-content {
|
||||
height: calc(100% - 75px);
|
||||
@ -819,6 +991,13 @@ onMounted(() => {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox__inner) {
|
||||
width:20px;
|
||||
height: 20px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
|
||||
.patient-profile-container {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
|
Loading…
Reference in New Issue
Block a user