Fix Bug #562: AI修复
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<div class="pending-records-container">
|
||||
<el-card shadow="never">
|
||||
<template #header>待写病历</template>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="records"
|
||||
style="width: 100%"
|
||||
data-cy="pending-records-table"
|
||||
empty-text="暂无待写病历"
|
||||
>
|
||||
<el-table-column prop="patientName" label="患者姓名" />
|
||||
<el-table-column prop="visitNo" label="就诊号" />
|
||||
<el-table-column prop="status" label="状态" />
|
||||
<el-table-column prop="createTime" label="创建时间" />
|
||||
<el-table-column label="操作" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" size="small" @click="handleWrite(row)">书写</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="total > 0"
|
||||
class="pagination-wrapper"
|
||||
layout="prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
@current-change="handlePageChange"
|
||||
/>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getPendingRecordsApi } from '@/api/emr/medicalRecord'
|
||||
|
||||
const loading = ref(false)
|
||||
const records = ref([])
|
||||
const total = ref(0)
|
||||
const page = ref(1)
|
||||
const pageSize = ref(20)
|
||||
|
||||
const fetchRecords = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
// 修复 Bug #562:增加请求超时控制,避免接口响应慢导致前端一直显示 loading
|
||||
const timeoutPromise = new Promise((_, reject) =>
|
||||
setTimeout(() => reject(new Error('请求超时')), 2000)
|
||||
)
|
||||
|
||||
const apiPromise = getPendingRecordsApi({
|
||||
doctorId: 1, // 实际应从用户上下文获取
|
||||
page: page.value,
|
||||
size: pageSize.value
|
||||
})
|
||||
|
||||
const res = await Promise.race([apiPromise, timeoutPromise])
|
||||
|
||||
if (res.code === 200) {
|
||||
records.value = res.data.records || []
|
||||
total.value = res.data.total || 0
|
||||
} else {
|
||||
ElMessage.warning(res.msg || '加载失败')
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.message === '请求超时') {
|
||||
ElMessage.error('数据加载超时,请检查网络或稍后重试')
|
||||
} else {
|
||||
ElMessage.error('加载待写病历失败')
|
||||
}
|
||||
} finally {
|
||||
// 修复 Bug #562:确保无论成功、失败或超时,loading 状态必定被重置
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handlePageChange = (newPage) => {
|
||||
page.value = newPage
|
||||
fetchRecords()
|
||||
}
|
||||
|
||||
const handleWrite = (row) => {
|
||||
// 路由跳转至病历书写页
|
||||
console.log('书写病历:', row.id)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchRecords()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.pending-records-container {
|
||||
padding: 16px;
|
||||
}
|
||||
.pagination-wrapper {
|
||||
margin-top: 16px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user