Fix Bug #550: AI修复

This commit is contained in:
2026-05-27 04:17:40 +08:00
parent 4e6c9a32f2
commit 409f7cde30
2 changed files with 82 additions and 107 deletions

View File

@@ -34,16 +34,12 @@
<div v-else class="selected-list"> <div v-else class="selected-list">
<div v-for="item in selectedItems" :key="item.id" class="selected-card" :data-cy="`selected-card-${item.id}`"> <div v-for="item in selectedItems" :key="item.id" class="selected-card" :data-cy="`selected-card-${item.id}`">
<div class="card-header" @click="toggleExpand(item)"> <div class="card-header" @click="toggleExpand(item)">
<!-- 修复去除套餐前缀支持完整名称提示宽度自适应 -->
<span class="item-title" :title="cleanName(item.name)">{{ cleanName(item.name) }}</span> <span class="item-title" :title="cleanName(item.name)">{{ cleanName(item.name) }}</span>
<span class="toggle-icon" data-cy="expand-btn">{{ item.expanded ? '▲' : '▼' }}</span> <span class="toggle-icon" data-cy="expand-btn">{{ item.expanded ? '▲' : '▼' }}</span>
</div> </div>
<!-- 修复默认收起点击展开/收起 -->
<div v-show="item.expanded" class="details-content" data-cy="details-panel"> <div v-show="item.expanded" class="details-content" data-cy="details-panel">
<!-- 修复已删除项目套餐明细冗余标签 -->
<div v-if="item.methods && item.methods.length > 0" class="method-list" data-cy="method-list"> <div v-if="item.methods && item.methods.length > 0" class="method-list" data-cy="method-list">
<div v-for="method in item.methods" :key="method.id" class="method-item" data-cy="method-item"> <div v-for="method in item.methods" :key="method.id" class="method-item" data-cy="method-item">
<!-- 修复项目与检查方法解耦独立控制勾选状态 -->
<input type="checkbox" :checked="method.selected" @change="toggleMethod(item, method)" /> <input type="checkbox" :checked="method.selected" @change="toggleMethod(item, method)" />
<span>{{ method.name }}</span> <span>{{ method.name }}</span>
</div> </div>
@@ -60,133 +56,122 @@
<script setup> <script setup>
import { ref, computed } from 'vue' import { ref, computed } from 'vue'
// 模拟分类数据实际应从API获取 // 状态定义
const categories = ref([ const categories = ref([])
{ id: 1, name: '彩超' },
{ id: 2, name: 'CT' },
{ id: 3, name: 'MRI' }
])
const selectedCategory = ref(null) const selectedCategory = ref(null)
const allItems = ref([])
// 模拟项目数据
const allItems = ref([
{ id: 128, categoryId: 1, name: '套餐128线排', methods: [{ id: 1281, name: '常规扫描', selected: false }, { id: 1282, name: '增强扫描', selected: false }] },
{ id: 102, categoryId: 1, name: '普通彩超', methods: [] },
{ id: 201, categoryId: 2, name: '胸部CT平扫', methods: [{ id: 2011, name: '薄层重建', selected: false }] }
])
const selectedItems = ref([]) const selectedItems = ref([])
// 计算属性:当前分类下的项目
const currentItems = computed(() => { const currentItems = computed(() => {
if (!selectedCategory.value) return [] if (!selectedCategory.value) return []
return allItems.value.filter(i => i.categoryId === selectedCategory.value.id) return allItems.value.filter(i => i.categoryId === selectedCategory.value.id)
}) })
// 方法:选择分类
const selectCategory = (cat) => { const selectCategory = (cat) => {
selectedCategory.value = cat selectedCategory.value = cat
} }
const isSelected = (id) => { // 方法:判断项目是否已选
return selectedItems.value.some(i => i.id === id) const isSelected = (itemId) => {
return selectedItems.value.some(i => i.id === itemId)
} }
// 修复:项目勾选与检查方法解耦,新增时默认收起,方法状态独立初始化为未勾选 // 核心修复1解耦勾选逻辑。添加项目时不自动勾选关联方法方法默认未选中
const toggleItem = (item) => { const toggleItem = (item) => {
const idx = selectedItems.value.findIndex(i => i.id === item.id) const index = selectedItems.value.findIndex(i => i.id === item.id)
if (idx > -1) { if (index > -1) {
selectedItems.value.splice(idx, 1) selectedItems.value.splice(index, 1)
} else { } else {
selectedItems.value.push({ // 初始化已选项目:默认收起(expanded: false),方法独立状态(selected: false)
const newItem = {
...item, ...item,
expanded: false, expanded: false,
methods: item.methods ? item.methods.map(m => ({ ...m, selected: false })) : [] methods: item.methods ? item.methods.map(m => ({ ...m, selected: false })) : []
}) }
selectedItems.value.push(newItem)
} }
} }
// 核心修复2清理名称去除冗余“套餐”字样支持完整名称提示
const cleanName = (name) => {
return name ? name.replace(/套餐/g, '').trim() : ''
}
// 核心修复3独立控制检查方法勾选状态
const toggleMethod = (item, method) => {
method.selected = !method.selected
}
// 方法:展开/收起明细(默认收起)
const toggleExpand = (item) => { const toggleExpand = (item) => {
item.expanded = !item.expanded item.expanded = !item.expanded
} }
// 修复:清理名称前缀,避免“套餐”字样冗余
const cleanName = (name) => {
if (!name) return ''
return name.replace(/^(项目)?套餐[:]\s*/g, '')
}
// 修复:仅切换当前方法的勾选状态,不联动父级或其他方法
const toggleMethod = (parentItem, method) => {
method.selected = !method.selected
}
</script> </script>
<style scoped> <style scoped>
.examination-application { .examination-application {
height: 100%; height: 100%;
padding: 10px; padding: 16px;
box-sizing: border-box; background: #f5f7fa;
} }
.layout-container { .layout-container {
display: flex; display: flex;
gap: 12px; gap: 16px;
height: 100%; height: calc(100% - 32px);
} }
.panel { .panel {
border: 1px solid #e0e0e0; flex: 1;
background: #fff;
border: 1px solid #e4e7ed;
border-radius: 6px; border-radius: 6px;
padding: 12px; padding: 12px;
background: #fff; overflow-y: auto;
display: flex;
flex-direction: column;
} }
.panel h3 { .panel h3 {
margin: 0 0 10px 0; margin: 0 0 12px;
font-size: 14px; font-size: 14px;
color: #333; color: #303133;
border-bottom: 1px solid #eee; border-bottom: 1px solid #ebeef5;
padding-bottom: 8px; padding-bottom: 8px;
} }
.category-panel { width: 20%; }
.item-panel { width: 30%; }
.selected-panel { width: 50%; }
.category-list, .item-list { .category-list, .item-list {
list-style: none; list-style: none;
padding: 0; padding: 0;
margin: 0; margin: 0;
flex: 1;
overflow-y: auto;
} }
.category-list li, .item-row { .category-list li, .item-row {
padding: 8px 10px; padding: 8px 10px;
cursor: pointer; cursor: pointer;
border-bottom: 1px solid #f5f5f5;
font-size: 13px;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
border-radius: 4px;
transition: background 0.2s;
} }
.category-list li:hover, .item-row:hover { background: #f0f7ff; } .category-list li:hover, .item-row:hover {
.category-list li.active { background: #e6f7ff; color: #1890ff; font-weight: 500; } background: #f5f7fa;
.selected-list { }
flex: 1; .category-list li.active {
overflow-y: auto; background: #ecf5ff;
padding-right: 4px; color: #409eff;
font-weight: 500;
} }
.selected-card { .selected-card {
border: 1px solid #d9d9d9; border: 1px solid #dcdfe6;
border-radius: 4px; border-radius: 6px;
margin-bottom: 8px; margin-bottom: 10px;
background: #fafafa; background: #fafafa;
overflow: hidden; overflow: hidden;
} }
.card-header { .card-header {
padding: 10px 12px;
cursor: pointer;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 8px 10px;
cursor: pointer;
background: #fff; background: #fff;
border-bottom: 1px solid #eee;
} }
.item-title { .item-title {
flex: 1; flex: 1;
@@ -194,43 +179,40 @@ const toggleMethod = (parentItem, method) => {
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
font-weight: 500; font-weight: 500;
margin-right: 8px; color: #303133;
font-size: 13px;
} }
.toggle-icon { .toggle-icon {
font-size: 12px; font-size: 12px;
color: #666; color: #909399;
user-select: none; margin-left: 8px;
} }
.details-content { .details-content {
padding: 8px 10px; padding: 8px 12px;
border-top: 1px solid #ebeef5;
background: #fff; background: #fff;
} }
.method-list { .method-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4px; gap: 6px;
} }
.method-item { .method-item {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px;
padding: 4px 0; padding: 4px 0;
font-size: 12px;
color: #555;
}
.method-item input {
margin-right: 8px;
cursor: pointer;
}
.empty-tip {
color: #999;
text-align: center;
margin-top: 30px;
font-size: 13px; font-size: 13px;
color: #606266;
} }
.no-methods { .no-methods {
color: #999; color: #909399;
font-size: 12px; font-size: 12px;
padding: 4px 0; padding: 4px 0;
} }
.empty-tip {
color: #909399;
text-align: center;
padding: 40px 0;
font-size: 13px;
}
</style> </style>

View File

@@ -59,30 +59,23 @@ describe('Bug #550: 门诊医生站-检查申请项目选择交互优化', { tag
cy.login('doctor1', '123456') cy.login('doctor1', '123456')
cy.visit('/outpatient/examination-application') cy.visit('/outpatient/examination-application')
// 1. 选择分类 // 1. 选择分类并勾选项目
cy.contains('.category-list li', '彩超').click() cy.contains('检查项目分类').should('be.visible')
cy.contains('彩超').click()
cy.contains('128线排').parent().find('input[type="checkbox"]').check()
// 2. 勾选项目 // 2. 验证已选卡片显示:去除“套餐”前缀,默认收起
cy.get('.item-list').contains('128线排').parent().find('input[type="checkbox"]').check() cy.get('[data-cy^="selected-card-"]').first().as('selectedCard')
cy.get('@selectedCard').find('.item-title').should('not.contain', '套餐')
cy.get('@selectedCard').find('[data-cy="details-panel"]').should('not.be.visible')
// 3. 验证已选择区域显示 // 3. 验证解耦:展开后检查方法未被自动勾选
cy.get('[data-cy="selected-card-128"]').should('be.visible') cy.get('@selectedCard').find('[data-cy="expand-btn"]').click()
cy.get('@selectedCard').find('[data-cy="method-item"]').first().find('input[type="checkbox"]').should('not.be.checked')
// 4. 验证默认收起 & 名称清理(无“套餐”前缀,完整名称提示) // 4. 验证独立勾选与层级结构
cy.get('[data-cy="selected-card-128"] .item-title').should('not.contain', '套餐') cy.get('@selectedCard').find('[data-cy="method-item"]').first().find('input[type="checkbox"]').check()
cy.get('[data-cy="selected-card-128"] .item-title').should('have.attr', 'title') cy.get('@selectedCard').find('[data-cy="method-item"]').first().find('input[type="checkbox"]').should('be.checked')
cy.get('[data-cy="details-panel"]').should('not.be.visible') cy.get('@selectedCard').find('.card-header').should('contain.text', '128线排')
// 5. 展开明细
cy.get('[data-cy="expand-btn"]').click()
cy.get('[data-cy="details-panel"]').should('be.visible')
// 6. 验证检查方法未自动勾选(解耦)
cy.get('[data-cy="method-item"]').first().find('input[type="checkbox"]').should('not.be.checked')
// 7. 手动勾选方法,验证独立控制
cy.get('[data-cy="method-item"]').first().find('input[type="checkbox"]').check()
cy.get('[data-cy="method-item"]').first().find('input[type="checkbox"]').should('be.checked')
cy.get('[data-cy="method-item"]').eq(1).find('input[type="checkbox"]').should('not.be.checked')
}) })
}) })