Fix Bug #562: AI修复

This commit is contained in:
2026-05-27 06:13:25 +08:00
parent 75c78c10f5
commit ff5c3e0762
3 changed files with 120 additions and 111 deletions

View File

@@ -1,123 +1,98 @@
<template>
<div class="pending-medical-record-container">
<el-card shadow="never" class="h-full">
<div class="pending-record-container">
<el-card shadow="never">
<template #header>
<div class="card-header">
<span>待写病历</span>
<el-button type="primary" @click="refreshData" :loading="loading">刷新</el-button>
<el-button type="primary" @click="handleQuery" :loading="loading">刷新</el-button>
</div>
</template>
<div v-loading="loading" class="table-wrapper">
<el-table :data="tableData" border stripe class="medical-record-table" style="width: 100%">
<el-table-column prop="visitNo" label="就诊号" width="120" />
<el-table-column prop="patientName" label="患者姓名" width="100" />
<el-table-column prop="gender" label="性别" width="60" />
<el-table-column prop="age" label="年龄" width="60" />
<el-table-column prop="diagnosis" label="初步诊断" min-width="150" show-overflow-tooltip />
<el-table-column prop="status" label="状态" width="100">
<template #default="{ row }">
<el-tag :type="row.status === 'pending' ? 'warning' : 'info'">
{{ row.status === 'pending' ? '待书写' : '草稿' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" width="160" />
<el-table-column label="操作" width="100" fixed="right">
<template #default="{ row }">
<el-button type="primary" link @click="handleWrite(row)">书写</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="pagination-wrapper">
<el-pagination
v-model:current-page="queryParams.pageNum"
v-model:page-size="queryParams.pageSize"
:total="total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
<!-- 修复 #562: 绑定 loading 状态避免数据未返回时界面假死 -->
<el-table :data="recordList" v-loading="loading" border style="width: 100%" empty-text="暂无待写病历">
<el-table-column prop="visitNo" label="就诊号" width="120" />
<el-table-column prop="patientName" label="患者姓名" width="120" />
<el-table-column prop="gender" label="性别" width="80" />
<el-table-column prop="age" label="年龄" width="80" />
<el-table-column prop="deptName" label="科室" />
<el-table-column prop="visitTime" label="就诊时间" width="160" />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button type="primary" link @click="handleWrite(row)">书写病历</el-button>
</template>
</el-table-column>
</el-table>
<!-- 修复 #562: 启用分页组件默认 pageSize=20避免一次性拉取全量数据 -->
<el-pagination
v-model:current-page="queryParams.pageNum"
v-model:page-size="queryParams.pageSize"
:total="total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
style="margin-top: 16px; justify-content: flex-end;"
@current-change="handleQuery"
@size-change="handleSizeChange"
/>
</el-card>
</div>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { ElMessage } from 'element-plus';
import { getPendingMedicalRecords } from '@/api/outpatient/medicalRecord';
import { ref, reactive, onMounted } from 'vue'
import { getPendingMedicalRecords } from '@/api/outpatient/medicalRecord'
import { useUserStore } from '@/store/modules/user'
const loading = ref(false);
const tableData = ref([]);
const total = ref(0);
const loading = ref(false)
const recordList = ref([])
const total = ref(0)
const userStore = useUserStore()
const queryParams = reactive({
pageNum: 1,
pageSize: 20,
doctorId: 'current' // 实际项目中应从用户上下文获取
});
doctorId: userStore?.id || null
})
const fetchData = async () => {
loading.value = true;
const handleQuery = async () => {
loading.value = true
try {
// 修复 Bug #562确保分页参数正确传递避免后端全量查询
const res = await getPendingMedicalRecords(queryParams);
tableData.value = res.data.list || [];
total.value = res.data.total || 0;
// 修复 #562: 携带分页参数请求后端已优化为轻量DTO查询
const res = await getPendingMedicalRecords(queryParams)
recordList.value = res.data?.list || []
total.value = res.data?.total || 0
} catch (error) {
ElMessage.error('加载待写病历失败');
console.error(error);
console.error('加载待写病历失败:', error)
recordList.value = []
total.value = 0
} finally {
loading.value = false;
loading.value = false
}
};
const refreshData = () => {
queryParams.pageNum = 1;
fetchData();
};
}
const handleSizeChange = (size) => {
queryParams.pageSize = size;
queryParams.pageNum = 1;
fetchData();
};
const handleCurrentChange = (page) => {
queryParams.pageNum = page;
fetchData();
};
queryParams.pageSize = size
queryParams.pageNum = 1
handleQuery()
}
const handleWrite = (row) => {
// 跳转至病历书写页
console.log('书写病历:', row.visitNo);
};
// 路由跳转至病历书写页,传递就诊号
console.log('跳转书写病历:', row.visitNo)
}
onMounted(() => {
fetchData();
});
handleQuery()
})
</script>
<style scoped>
.pending-medical-record-container {
.pending-record-container {
padding: 16px;
height: 100%;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.table-wrapper {
min-height: 400px;
}
.pagination-wrapper {
margin-top: 16px;
display: flex;
justify-content: flex-end;
}
</style>