Fix Bug #411: 智能分诊排队:底部操作控制区"过滤栏"功能实现与PRD需求不符(误设为科室过滤)

将底部过滤栏从"就诊科室快速过滤栏"改为"诊室快速过滤栏":
- UI文案:过滤栏标题、下拉框placeholder均改为诊室相关
- 数据源:移除 getLocationTree() 科室树API调用,改为从队列/候选池数据中动态提取诊室列表
- 过滤逻辑:改为按诊室名称(room字段)过滤,支持本科室下不同诊室快速切换
- 后端API调用不再依赖过滤栏选择,改用队列数据自身的organizationId

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
赵云
2026-05-10 23:59:53 +08:00
committed by 关羽
parent c0cdfcc688
commit 04ac6b0ec2

View File

@@ -220,15 +220,15 @@
<!-- 底部控制面板 --> <!-- 底部控制面板 -->
<div class="footer-section"> <div class="footer-section">
<!-- 就诊科室快速过滤栏 --> <!-- 室快速过滤栏 -->
<div class="filter-section"> <div class="filter-section">
<div class="filter-label"> <div class="filter-label">
就诊科室快速过滤栏 室快速过滤栏
</div> </div>
<div class="filter-select-wrapper"> <div class="filter-select-wrapper">
<el-select <el-select
v-model="selectedDept" v-model="selectedClinicRoom"
placeholder="请选择就诊科室" placeholder="请选择室"
clearable clearable
filterable filterable
style="width: 100%" style="width: 100%"
@@ -239,10 +239,10 @@
value="all" value="all"
/> />
<el-option <el-option
v-for="dept in departmentList" v-for="room in clinicRoomList"
:key="dept.id" :key="room"
:label="dept.name" :label="room"
:value="dept.id" :value="room"
/> />
</el-select> </el-select>
</div> </div>
@@ -648,7 +648,6 @@ import { Refresh } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { import {
getCandidatePool, getCandidatePool,
getLocationTree,
getTriageQueueList, getTriageQueueList,
addToQueue, addToQueue,
removeFromQueue, removeFromQueue,
@@ -681,10 +680,10 @@ const selectedCandidates = ref([])
// 显示选项 // 显示选项
const showOnlyWaiting = ref(false) const showOnlyWaiting = ref(false)
// 室过滤(改为使用就诊科室 // 室过滤(按诊室维度筛选
const selectedDept = ref('all') const selectedClinicRoom = ref('all')
// 就诊科室列表 // 诊室列表(从数据中动态提取)
const departmentList = ref([]) const clinicRoomList = ref([])
// 修复【#397】动态获取当前科室名称 // 修复【#397】动态获取当前科室名称
const currentDeptName = computed(() => { const currentDeptName = computed(() => {
@@ -907,13 +906,11 @@ const mapFrontendStatusToBackend = (status) => {
// 从数据库加载队列 // 从数据库加载队列
const loadQueueFromDb = async () => { const loadQueueFromDb = async () => {
try { try {
// 如果选择了具体科室,就按科室加载;否则加载当前登录人科室(后端默认) // 使用当前登录人科室
const organizationId = selectedDept.value !== 'all' ? selectedDept.value : undefined
// 只查询今天的患者
const today = new Date() const today = new Date()
const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}` const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`
console.log('【心内科】loadQueueFromDb 开始:organizationId=', organizationId, 'date=', todayStr, 'selectedDept=', selectedDept.value) console.log('【心内科】loadQueueFromDb 开始:date=', todayStr)
const res = await getTriageQueueList({ organizationId, date: todayStr }).catch((err) => { const res = await getTriageQueueList({ date: todayStr }).catch((err) => {
console.error('【心内科】loadQueueFromDb 请求异常:', err) console.error('【心内科】loadQueueFromDb 请求异常:', err)
return { code: 500, msg: err?.message || '请求失败', data: null } return { code: 500, msg: err?.message || '请求失败', data: null }
}) })
@@ -1141,6 +1138,8 @@ const loadDataFromApi = async () => {
// 同步当前呼叫(队列从 DB 加载后已同步;这里再兜底一次) // 同步当前呼叫(队列从 DB 加载后已同步;这里再兜底一次)
syncCurrentCallFromQueue() syncCurrentCallFromQueue()
// 提取诊室列表供过滤栏使用
extractClinicRooms()
console.log('【心内科】数据加载完成:候选池', originalCandidatePoolList.value.length, '条,队列', originalQueueList.value.length, '条') console.log('【心内科】数据加载完成:候选池', originalCandidatePoolList.value.length, '条,队列', originalQueueList.value.length, '条')
ElMessage.success('【心内科】已从门诊挂号接口加载数据') ElMessage.success('【心内科】已从门诊挂号接口加载数据')
} catch (e) { } catch (e) {
@@ -1152,56 +1151,37 @@ const loadDataFromApi = async () => {
totalSignedIn.value = originalCandidatePoolList.value.length totalSignedIn.value = originalCandidatePoolList.value.length
totalInQueue.value = originalQueueList.value.length totalInQueue.value = originalQueueList.value.length
syncCurrentCallFromQueue() syncCurrentCallFromQueue()
extractClinicRooms()
} }
} }
// 原始数据存储(用于过滤) // 原始数据存储(用于过滤)
const originalCandidatePoolList = ref(getInitialCandidatePoolList()) const originalCandidatePoolList = ref(getInitialCandidatePoolList())
// 辅助函数:扁平化科室树形结构 // 提取诊室列表(从队列和候选池数据中动态获取)
const flattenDepartmentTree = (tree, result = []) => { const extractClinicRooms = () => {
if (!Array.isArray(tree)) return result const roomSet = new Set()
tree.forEach(node => { // 从队列中提取
if (node.id && node.name) { originalQueueList.value.forEach(item => {
result.push({ id: node.id, name: node.name }) if (item.room && item.room !== '-') {
} roomSet.add(item.room)
if (node.children && Array.isArray(node.children)) {
flattenDepartmentTree(node.children, result)
} }
}) })
return result // 从候选池中提取
originalCandidatePoolList.value.forEach(item => {
if (item.room && item.room !== '-') {
roomSet.add(item.room)
} }
})
// 加载就诊科室列表 clinicRoomList.value = Array.from(roomSet).sort()
const loadDepartmentList = async () => {
try {
const response = await getLocationTree()
if (response && response.data) {
// 扁平化树形结构
departmentList.value = flattenDepartmentTree(response.data)
console.log('【心内科】已加载就诊科室列表:', departmentList.value.length, '个科室')
}
} catch (error) {
console.error('【心内科】加载就诊科室列表失败:', error)
ElMessage.warning('加载就诊科室列表失败,使用默认数据')
}
}
// 获取选中科室的名称
const getSelectedDeptName = () => {
if (selectedDept.value === 'all') return null
const dept = departmentList.value.find(d => d.id === selectedDept.value)
return dept ? dept.name : null
} }
// 过滤后的智能候选池数据 // 过滤后的智能候选池数据
const filteredCandidatePoolList = computed(() => { const filteredCandidatePoolList = computed(() => {
if (selectedDept.value === 'all') { if (selectedClinicRoom.value === 'all') {
return originalCandidatePoolList.value return originalCandidatePoolList.value
} }
const deptName = getSelectedDeptName() return originalCandidatePoolList.value.filter(item => item.room === selectedClinicRoom.value)
if (!deptName) return originalCandidatePoolList.value
return originalCandidatePoolList.value.filter(item => item.room === deptName)
}) })
// 原始队列数据存储(用于过滤) // 原始队列数据存储(用于过滤)
@@ -1223,19 +1203,16 @@ const formatSecondsToMmSs = (totalSeconds) => {
return `${mm}:${ss}` return `${mm}:${ss}`
} }
// 过滤后的智能队列数据(同时考虑室过滤和状态过滤) // 过滤后的智能队列数据(同时考虑室过滤和状态过滤)
const filteredQueueList = computed(() => { const filteredQueueList = computed(() => {
let filtered = originalQueueList.value let filtered = originalQueueList.value
// 先过滤掉"已完成"状态的患者(无论什么情况都不显示) // 先过滤掉"已完成"状态的患者(无论什么情况都不显示)
filtered = filtered.filter(item => item.status !== '已完成') filtered = filtered.filter(item => item.status !== '已完成')
// 再按室过滤 // 再按室过滤
if (selectedDept.value !== 'all') { if (selectedClinicRoom.value !== 'all') {
const deptName = getSelectedDeptName() filtered = filtered.filter(item => item.room === selectedClinicRoom.value)
if (deptName) {
filtered = filtered.filter(item => item.room === deptName)
}
} }
// 再按状态过滤(只显示等待) // 再按状态过滤(只显示等待)
@@ -1747,9 +1724,9 @@ const handleNextPatient = async () => {
reqData.organizationId = selectedQueueRow.value.organizationId reqData.organizationId = selectedQueueRow.value.organizationId
} else { } else {
// 如果没有选中患者,使用查询条件(兼容旧逻辑) // 如果没有选中患者,使用查询条件(兼容旧逻辑)
let orgId = selectedDept.value !== 'all' ? selectedDept.value : undefined // 全科模式:优先用"当前叫号中/第一个等待"所在科室
// "全科"模式:优先用"当前叫号中/第一个等待"所在科室 let orgId = null
if (orgId == null) { {
const calling = originalQueueList.value.find((i) => i.status === '叫号中') const calling = originalQueueList.value.find((i) => i.status === '叫号中')
const waiting = originalQueueList.value.find((i) => i.status === '等待') const waiting = originalQueueList.value.find((i) => i.status === '等待')
console.log('【心内科】handleNextPatient 查找:叫号中=', calling?.patientName, '等待=', waiting?.patientName) console.log('【心内科】handleNextPatient 查找:叫号中=', calling?.patientName, '等待=', waiting?.patientName)
@@ -1785,9 +1762,9 @@ const handleSkip = async () => {
reqData.organizationId = selectedQueueRow.value.organizationId reqData.organizationId = selectedQueueRow.value.organizationId
} else { } else {
// 如果没有选中患者,使用查询条件(兼容旧逻辑) // 如果没有选中患者,使用查询条件(兼容旧逻辑)
let orgId = selectedDept.value !== 'all' ? selectedDept.value : undefined // 全科模式:优先用”当前叫号中”所在科室
// “全科”模式:优先用“当前叫号中”所在科室 let orgId = null
if (orgId == null) { {
const calling = originalQueueList.value.find((i) => i.status === '叫号中') const calling = originalQueueList.value.find((i) => i.status === '叫号中')
orgId = calling?.organizationId orgId = calling?.organizationId
} }
@@ -1819,9 +1796,9 @@ const handleComplete = async () => {
reqData.organizationId = selectedQueueRow.value.organizationId reqData.organizationId = selectedQueueRow.value.organizationId
} else { } else {
// 如果没有选中患者,使用查询条件(兼容旧逻辑) // 如果没有选中患者,使用查询条件(兼容旧逻辑)
let orgId = selectedDept.value !== 'all' ? selectedDept.value : undefined // 全科模式:优先用”当前叫号中”所在科室
// “全科”模式:优先用“当前叫号中”所在科室 let orgId = null
if (orgId == null) { {
const calling = originalQueueList.value.find((i) => i.status === '叫号中') const calling = originalQueueList.value.find((i) => i.status === '叫号中')
orgId = calling?.organizationId orgId = calling?.organizationId
} }
@@ -1853,9 +1830,9 @@ const handleRequeue = async () => {
reqData.organizationId = selectedQueueRow.value.organizationId reqData.organizationId = selectedQueueRow.value.organizationId
} else { } else {
// 如果没有选中患者,使用查询条件(兼容旧逻辑) // 如果没有选中患者,使用查询条件(兼容旧逻辑)
let orgId = selectedDept.value !== 'all' ? selectedDept.value : undefined // 全科模式:优先用”当前叫号中”所在科室
// “全科”模式:优先用“当前叫号中”所在科室 let orgId = null
if (orgId == null) { {
const calling = originalQueueList.value.find((i) => i.status === '叫号中') const calling = originalQueueList.value.find((i) => i.status === '叫号中')
orgId = calling?.organizationId orgId = calling?.organizationId
} }
@@ -2121,8 +2098,6 @@ const handleTestRule = () => {
// 组件挂载 // 组件挂载
onMounted(() => { onMounted(() => {
// 加载就诊科室列表
loadDepartmentList()
// 初始化:优先从后端加载,失败则回退本地假数据 // 初始化:优先从后端加载,失败则回退本地假数据
loadDataFromApi() loadDataFromApi()
startWaitingTimer() startWaitingTimer()