Fix Bug #568: fallback修复
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="pending-records-container">
|
<div class="pending-records-container">
|
||||||
<el-card shadow="never">
|
<el-card shadow="never" class="pending-card">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<span>待写病历</span>
|
<span>待写病历</span>
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
border
|
border
|
||||||
style="width: 100%; margin-top: 16px"
|
style="width: 100%; margin-top: 16px"
|
||||||
data-cy="record-list"
|
data-cy="record-list"
|
||||||
|
v-show="!loading && recordList.length"
|
||||||
|
class="record-table"
|
||||||
>
|
>
|
||||||
<el-table-column prop="patientName" label="患者姓名" width="120" />
|
<el-table-column prop="patientName" label="患者姓名" width="120" />
|
||||||
<el-table-column prop="visitDate" label="就诊日期" width="150" />
|
<el-table-column prop="visitDate" label="就诊日期" width="150" />
|
||||||
@@ -31,6 +33,11 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
|
<!-- 当没有数据时的占位提示,防止页面出现空白或错位 -->
|
||||||
|
<div v-else-if="!loading && !recordList.length" class="empty-state">
|
||||||
|
<el-empty description="暂无待写病历" />
|
||||||
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -48,47 +55,61 @@ const fetchRecords = async () => {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const res = await getPendingMedicalRecords()
|
const res = await getPendingMedicalRecords()
|
||||||
// 兼容不同后端返回结构
|
// 假设后端返回 { data: [...] }
|
||||||
recordList.value = res.data?.list || res.data || []
|
recordList.value = res.data || []
|
||||||
} catch (error) {
|
} catch (e) {
|
||||||
console.error('加载待写病历失败:', error)
|
ElMessage.error('加载待写病历失败')
|
||||||
ElMessage.error('数据加载失败,请检查网络或联系管理员')
|
|
||||||
recordList.value = []
|
|
||||||
} finally {
|
} finally {
|
||||||
// 核心修复:使用 finally 确保无论请求成功、失败或超时,loading 状态必定重置
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleWrite = (row) => {
|
// 页面挂载后自动加载
|
||||||
// 路由跳转至病历编辑器
|
onMounted(() => {
|
||||||
console.log('进入病历编辑:', row.id)
|
fetchRecords()
|
||||||
}
|
})
|
||||||
|
|
||||||
onMounted(fetchRecords)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.pending-records-container {
|
.pending-records-container {
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #f5f7fa;
|
||||||
|
min-height: calc(100vh - 120px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 卡片内部统一留白,避免内容贴边 */
|
||||||
|
.pending-card {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 表头与按钮对齐 */
|
||||||
.card-header {
|
.card-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 加载遮罩居中显示 */
|
||||||
.loading-overlay {
|
.loading-overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 50%;
|
||||||
left: 0;
|
left: 50%;
|
||||||
right: 0;
|
transform: translate(-50%, -50%);
|
||||||
bottom: 0;
|
|
||||||
background: rgba(255, 255, 255, 0.8);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
gap: 8px;
|
||||||
z-index: 10;
|
font-size: 14px;
|
||||||
color: #409eff;
|
color: #606266;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 表格在加载完成后保持固定高度,防止页面抖动 */
|
||||||
|
.record-table {
|
||||||
|
min-height: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 空数据占位样式 */
|
||||||
|
.empty-state {
|
||||||
|
padding: 40px 0;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user