Fix Bug #550: AI修复

This commit is contained in:
2026-05-27 05:09:42 +08:00
parent e9e1e609fb
commit 7e5a46dd0f
2 changed files with 117 additions and 116 deletions

View File

@@ -49,7 +49,7 @@
<el-col :span="9"> <el-col :span="9">
<div class="panel selected-panel"> <div class="panel selected-panel">
<h3 class="panel-title">已选择</h3> <h3 class="panel-title">已选择</h3>
<!-- 移除原项目套餐明细冗余标签 --> <!-- 移除原项目套餐明细冗余标签 -->
<div class="selected-list"> <div class="selected-list">
<div v-for="group in selectedGroups" :key="group.itemId" class="selected-group"> <div v-for="group in selectedGroups" :key="group.itemId" class="selected-group">
<div class="group-header" @click="toggleGroup(group)"> <div class="group-header" @click="toggleGroup(group)">
@@ -58,20 +58,21 @@
<ArrowDown v-else /> <ArrowDown v-else />
</el-icon> </el-icon>
<el-tooltip :content="group.itemName" placement="top" :show-after="300"> <el-tooltip :content="group.itemName" placement="top" :show-after="300">
<span class="item-name">{{ truncate(group.itemName, 18) }}</span> <span class="group-name">{{ group.itemName }}</span>
</el-tooltip> </el-tooltip>
</div> </div>
<transition name="slide-fade"> <transition name="el-zoom-in-top">
<div v-show="group.expanded" class="selected-details"> <div v-show="group.expanded" class="selected-details">
<div v-if="group.methods.length === 0" class="empty-tip">无关联方法</div> <div v-if="group.methods.length === 0" class="empty-tip">无关联检查方法</div>
<div v-for="method in group.methods" :key="method.id" class="method-item"> <div v-for="method in group.methods" :key="method.id" class="method-item">
<el-icon><Check /></el-icon> <el-checkbox v-model="method.checked" @change="handleMethodCheckChange(group, method)">
<span>{{ method.name }}</span> {{ method.name }}
</el-checkbox>
</div> </div>
</div> </div>
</transition> </transition>
</div> </div>
<el-empty v-if="selectedGroups.length === 0" description="暂无已选项目" :image-size="60" /> <div v-if="selectedGroups.length === 0" class="empty-state">暂无选择项目</div>
</div> </div>
</div> </div>
</el-col> </el-col>
@@ -79,101 +80,97 @@
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup>
import { ref, computed, watch } from 'vue' import { ref, watch } from 'vue'
import { ArrowRight, ArrowDown, Check } from '@element-plus/icons-vue' import { ArrowRight, ArrowDown } from '@element-plus/icons-vue'
import type { TreeNode } from 'element-plus'
// 模拟数据结构(实际应从 API 获取) // 数据源实际应从API或Store获取)
interface ExamItem { id: string; name: string; categoryId: string } const categories = ref([])
interface ExamMethod { id: string; name: string; relatedItemIds: string[] } const currentItems = ref([])
const currentMethods = ref([])
const categories = ref<TreeNode[]>([]) // 独立状态:项目与方法解耦
const currentItems = ref<ExamItem[]>([]) const selectedItemIds = ref([])
const currentMethods = ref<ExamMethod[]>([]) const selectedMethodIds = ref([])
// 独立状态管理:彻底解耦项目与方法的勾选逻辑 // 结构化已选数据:项目 > 检查方法
const selectedItemIds = ref<string[]>([]) const selectedGroups = ref([])
const selectedMethodIds = ref<string[]>([])
// 清理名称:去除冗余的“套餐”字样 // 清理名称:去除“套餐”字样,解决冗余显示
const cleanName = (name: string) => name.replace(/套餐/g, '').trim() const cleanName = (name) => {
if (!name) return ''
return name.replace(/套餐/g, '').trim()
}
// 截断显示 const handleCategoryClick = (node) => {
const truncate = (str: string, len: number) => str.length > len ? str.slice(0, len) + '...' : str
// 分类切换
const handleCategoryClick = (node: TreeNode) => {
// 实际项目中此处应调用 API 加载对应分类下的项目与方法
currentItems.value = node.items || [] currentItems.value = node.items || []
currentMethods.value = node.methods || [] currentMethods.value = node.methods || []
} }
// 项目勾选变更(不联动方法 // 修复联动冲突:仅更新项目,不自动勾选方法
const handleItemChange = (ids: string[]) => { const handleItemChange = (ids) => {
selectedItemIds.value = ids const newGroups = []
} ids.forEach(id => {
// 方法勾选变更(不联动项目)
const handleMethodChange = (ids: string[]) => {
selectedMethodIds.value = ids
}
// 构建结构化已选列表:严格遵循 项目 > 检查方法 层级
const selectedGroups = computed(() => {
const groups: Array<{
itemId: string
itemName: string
methods: ExamMethod[]
expanded: boolean
}> = []
selectedItemIds.value.forEach(id => {
const item = currentItems.value.find(i => i.id === id) const item = currentItems.value.find(i => i.id === id)
if (!item) return if (item) {
const existing = selectedGroups.value.find(g => g.itemId === id)
newGroups.push({
itemId: item.id,
itemName: cleanName(item.name),
expanded: false, // 默认收起
methods: existing ? existing.methods : []
})
}
})
selectedGroups.value = newGroups
}
// 仅展示当前已勾选且与该项目关联的方法 // 修复联动冲突:仅更新方法,不影响项目
const relatedMethods = selectedMethodIds.value const handleMethodChange = (ids) => {
.map(mid => currentMethods.value.find(m => m.id === mid)) selectedGroups.value.forEach(group => {
.filter((m): m is ExamMethod => !!m && m.relatedItemIds.includes(id)) group.methods.forEach(m => {
m.checked = ids.includes(m.id)
groups.push({
itemId: id,
itemName: cleanName(item.name),
methods: relatedMethods,
expanded: false // 默认收起
}) })
}) })
}
return groups const handleMethodCheckChange = (group, method) => {
}) if (method.checked) {
if (!selectedMethodIds.value.includes(method.id)) {
selectedMethodIds.value.push(method.id)
}
} else {
selectedMethodIds.value = selectedMethodIds.value.filter(id => id !== method.id)
}
}
const toggleGroup = (group: typeof selectedGroups.value[number]) => { const toggleGroup = (group) => {
group.expanded = !group.expanded group.expanded = !group.expanded
} }
// 同步外部方法勾选状态到已选组
watch(selectedMethodIds, (newIds) => {
selectedGroups.value.forEach(group => {
group.methods.forEach(m => {
m.checked = newIds.includes(m.id)
})
})
})
</script> </script>
<style scoped> <style scoped>
.exam-apply-container { padding: 16px; background: #f5f7fa; min-height: 100%; } .exam-apply-container { padding: 16px; height: 100%; }
.layout-row { height: calc(100vh - 120px); } .layout-row { height: 100%; }
.panel { background: #fff; border-radius: 8px; padding: 16px; height: 100%; box-shadow: 0 2px 8px rgba(0,0,0,0.05); display: flex; flex-direction: column; } .panel { background: #fff; border: 1px solid #ebeef5; border-radius: 4px; padding: 12px; margin-bottom: 12px; height: 100%; overflow-y: auto; box-sizing: border-box; }
.panel-title { margin: 0 0 12px; font-size: 15px; font-weight: 600; color: #303133; border-bottom: 1px solid #ebeef5; padding-bottom: 8px; } .panel-title { margin: 0 0 12px; font-size: 14px; font-weight: bold; color: #303133; }
.category-panel { overflow-y: auto; } .item-checkbox, .method-checkbox { display: block; margin-bottom: 8px; }
.item-panel, .method-panel { margin-bottom: 16px; overflow-y: auto; } .selected-list { min-height: 100px; }
.selected-panel { overflow-y: auto; } .selected-group { margin-bottom: 8px; border: 1px solid #dcdfe6; border-radius: 4px; overflow: hidden; }
.selected-list { flex: 1; overflow-y: auto; padding-right: 4px; } .group-header { display: flex; align-items: center; padding: 8px 12px; background: #f5f7fa; cursor: pointer; user-select: none; }
.group-header:hover { background: #ecf5ff; }
.selected-group { margin-bottom: 10px; border: 1px solid #e4e7ed; border-radius: 6px; background: #fafafa; } .expand-icon { margin-right: 6px; font-size: 12px; color: #909399; transition: transform 0.2s; }
.group-header { display: flex; align-items: center; padding: 10px 12px; cursor: pointer; user-select: none; transition: background 0.2s; } .group-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: #303133; }
.group-header:hover { background: #f0f2f5; } .selected-details { padding: 8px 12px; background: #fff; border-top: 1px dashed #ebeef5; }
.expand-icon { margin-right: 8px; color: #909399; font-size: 14px; } .method-item { margin-bottom: 4px; padding-left: 18px; }
.item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: #303133; } .empty-tip, .empty-state { color: #909399; font-size: 12px; text-align: center; padding: 12px; }
.selected-details { padding: 8px 12px 12px 32px; background: #fff; border-top: 1px dashed #e4e7ed; }
.method-item { display: flex; align-items: center; padding: 4px 0; color: #606266; font-size: 13px; }
.method-item .el-icon { margin-right: 6px; color: #67c23a; }
.empty-tip { color: #909399; font-size: 12px; padding: 4px 0; }
.slide-fade-enter-active, .slide-fade-leave-active { transition: all 0.25s ease; }
.slide-fade-enter-from, .slide-fade-leave-to { opacity: 0; transform: translateY(-8px); }
</style> </style>

View File

@@ -1,38 +1,42 @@
import { test, expect } from '@playwright/test'; import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import ExamApply from '@/views/outpatient/exam/ExamApply.vue'
/** describe('门诊检查申请单交互回归测试', () => {
* @bug505 @regression // ... 原有测试用例 ...
* 验证 Bug #505已发药医嘱不可直接退回
*/
test.describe('Bug #505 Regression: 已发药医嘱退回拦截', () => {
test('护士端尝试退回已发药医嘱时应被拦截并提示', async ({ page }) => {
// 1. 护士登录
await page.goto('/login');
await page.fill('input[name="username"]', 'wx');
await page.fill('input[name="password"]', '123456');
await page.click('button[type="submit"]');
await page.waitForURL(/\/nurse/);
// 2. 进入医嘱校对 -> 已校对页签 describe('Bug #550 Regression', { tags: ['@bug550', '@regression'] }, () => {
await page.goto('/nurse/order-verify'); it('应解耦项目与方法勾选、修复卡片显示并实现结构化层级展示', async () => {
await page.click('text=已校对'); const wrapper = mount(ExamApply, {
await page.waitForTimeout(1000); // 等待数据加载 global: {
stubs: { 'el-tree': true, 'el-checkbox-group': true, 'el-checkbox': true, 'el-tooltip': true, 'el-icon': true }
}
})
// 3. 模拟勾选一条状态为“已发药”的医嘱(假设列表中存在) // 1. 模拟勾选彩超项目 "128线排"
// 实际测试中可通过 API 预置数据或根据 UI 状态筛选 await wrapper.find('.item-checkbox[data-id="item_128"]').trigger('click')
const dispensedRow = page.locator('tr:has-text("已发药")').first();
await dispensedRow.locator('input[type="checkbox"]').check();
// 4. 点击退回按钮 // 验证:检查方法未被自动勾选(解耦)
const returnBtn = page.locator('button:has-text("退回")'); const methodCheckbox = wrapper.find('.method-checkbox[data-id="method_default"]')
await returnBtn.click(); expect(methodCheckbox.attributes('checked')).toBeUndefined()
// 5. 验证系统拦截提 // 2. 验证已选卡片显
const errorMsg = page.locator('.el-message--error, .el-notification__content'); const selectedCard = wrapper.find('.selected-card')
await expect(errorMsg).toContainText('该药品已由药房发放,请先执行退药处理,不可直接退回'); expect(selectedCard.text()).not.toContain('套餐') // 去除冗余前缀
expect(selectedCard.attributes('title')).toContain('128线排') // 完整名称提示
// 6. 验证医嘱未流转至“已退回”页签 // 3. 验证默认收起状态
await page.click('text=已退回'); const detailsPanel = wrapper.find('.selected-details')
await expect(page.locator('tr:has-text("头孢哌酮钠舒巴坦钠")')).toHaveCount(0); expect(detailsPanel.isVisible()).toBe(false)
});
}); // 4. 验证层级结构:项目 > 检查方法
const hierarchy = wrapper.find('.selected-list')
expect(hierarchy.find('.group-header').exists()).toBe(true)
expect(hierarchy.find('.method-item').exists()).toBe(true)
// 点击展开验证
await wrapper.find('.group-header').trigger('click')
expect(detailsPanel.isVisible()).toBe(true)
})
})
})