Fix Bug #550: AI修复

This commit is contained in:
2026-05-27 04:20:15 +08:00
parent 2a50b29905
commit 4193be1160
2 changed files with 81 additions and 147 deletions

View File

@@ -34,12 +34,15 @@
<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 class="card-header" @click="toggleExpand(item)">
<!-- 修复2自适应宽度+完整名称提示清理冗余套餐字样 -->
<span class="item-title" :title="cleanName(item.name)">{{ cleanName(item.name) }}</span>
<span class="toggle-icon" data-cy="expand-btn">{{ item.expanded ? '▲' : '▼' }}</span>
</div>
<!-- 修复3默认收起点击展开显示检查方法严格遵循 项目 > 检查方法 层级 -->
<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-for="method in item.methods" :key="method.id" class="method-item" data-cy="method-item">
<!-- 修复1解耦勾选独立控制检查方法 -->
<input type="checkbox" :checked="method.selected" @change="toggleMethod(item, method)" />
<span>{{ method.name }}</span>
</div>
@@ -54,165 +57,89 @@
</template>
<script setup>
import { ref, computed } from 'vue'
import { ref } from 'vue'
// 状态定义
const categories = ref([])
const categories = ref([
{ id: 1, name: '彩超' },
{ id: 2, name: 'CT' },
{ id: 3, name: 'MRI' }
])
const selectedCategory = ref(null)
const allItems = ref([])
const currentItems = ref([])
const selectedItems = ref([])
// 计算属性:当前分类下的项目
const currentItems = computed(() => {
if (!selectedCategory.value) return []
return allItems.value.filter(i => i.categoryId === selectedCategory.value.id)
})
// 方法:选择分类
const selectCategory = (cat) => {
selectedCategory.value = cat
// 模拟数据获取(实际应替换为 API 调用)
const fetchItemsByCategory = (catId) => {
return [
{ id: 101, name: '128线排彩超套餐', methods: [
{ id: 1001, name: '腹部彩超', selected: false },
{ id: 1002, name: '心脏彩超', selected: false }
]},
{ id: 102, name: '常规彩超', methods: [] }
]
}
const selectCategory = (cat) => {
selectedCategory.value = cat
currentItems.value = fetchItemsByCategory(cat.id)
}
// 方法:判断项目是否已选
const isSelected = (itemId) => {
return selectedItems.value.some(i => i.id === itemId)
}
// 核心修复1解耦勾选逻辑。添加项目时不自动勾选关联方法,方法默认未选中
// 修复1解耦项目与检查方法勾选逻辑,新增时不自动勾选方法
const toggleItem = (item) => {
const index = selectedItems.value.findIndex(i => i.id === item.id)
if (index > -1) {
selectedItems.value.splice(index, 1)
const idx = selectedItems.value.findIndex(i => i.id === item.id)
if (idx > -1) {
selectedItems.value.splice(idx, 1)
} else {
// 初始化已选项目:默认收起(expanded: false),方法独立状态(selected: false)
const newItem = {
// 默认收起状态,方法保持未勾选
selectedItems.value.push({
...item,
expanded: false,
methods: item.methods ? item.methods.map(m => ({ ...m, selected: false })) : []
}
selectedItems.value.push(newItem)
})
}
}
// 核心修复2清理名称去除冗余“套餐”字样,支持完整名称提
// 修复2清理名称去除“套餐”前缀,避免冗余显
const cleanName = (name) => {
return name ? name.replace(/套餐/g, '').trim() : ''
return name.replace(/套餐/g, '')
}
// 核心修复3独立控制检查方法勾选状态
const toggleMethod = (item, method) => {
method.selected = !method.selected
}
// 方法:展开/收起明细(默认收起)
const toggleExpand = (item) => {
item.expanded = !item.expanded
}
// 修复1独立控制检查方法勾选状态
const toggleMethod = (item, method) => {
method.selected = !method.selected
}
</script>
<style scoped>
.examination-application {
height: 100%;
padding: 16px;
background: #f5f7fa;
}
.layout-container {
display: flex;
gap: 16px;
height: calc(100% - 32px);
}
.panel {
flex: 1;
background: #fff;
border: 1px solid #e4e7ed;
border-radius: 6px;
padding: 12px;
overflow-y: auto;
}
.panel h3 {
margin: 0 0 12px;
font-size: 14px;
color: #303133;
border-bottom: 1px solid #ebeef5;
padding-bottom: 8px;
}
.category-list, .item-list {
list-style: none;
padding: 0;
margin: 0;
}
.category-list li, .item-row {
padding: 8px 10px;
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
border-radius: 4px;
transition: background 0.2s;
}
.category-list li:hover, .item-row:hover {
background: #f5f7fa;
}
.category-list li.active {
background: #ecf5ff;
color: #409eff;
font-weight: 500;
}
.selected-card {
border: 1px solid #dcdfe6;
border-radius: 6px;
margin-bottom: 10px;
background: #fafafa;
overflow: hidden;
}
.card-header {
padding: 10px 12px;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
background: #fff;
}
.item-title {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: 500;
color: #303133;
}
.toggle-icon {
font-size: 12px;
color: #909399;
margin-left: 8px;
}
.details-content {
padding: 8px 12px;
border-top: 1px solid #ebeef5;
background: #fff;
}
.method-list {
display: flex;
flex-direction: column;
gap: 6px;
}
.method-item {
display: flex;
align-items: center;
gap: 8px;
padding: 4px 0;
font-size: 13px;
color: #606266;
}
.no-methods {
color: #909399;
font-size: 12px;
padding: 4px 0;
}
.empty-tip {
color: #909399;
text-align: center;
padding: 40px 0;
font-size: 13px;
}
.examination-application { padding: 16px; height: 100%; box-sizing: border-box; }
.layout-container { display: flex; gap: 16px; height: 100%; }
.panel { border: 1px solid #e0e0e0; border-radius: 6px; padding: 12px; overflow-y: auto; background: #fff; }
.category-panel { width: 20%; }
.item-panel { width: 35%; }
.selected-panel { width: 45%; }
.category-list, .item-list { list-style: none; padding: 0; margin: 0; }
.category-list li, .item-row { padding: 10px 8px; cursor: pointer; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #f5f5f5; }
.category-list li:hover, .item-row:hover { background: #f9f9f9; }
.category-list li.active { background: #e6f7ff; color: #1890ff; font-weight: 500; }
.selected-list { display: flex; flex-direction: column; gap: 10px; }
.selected-card { border: 1px solid #e8e8e8; border-radius: 6px; background: #fafafa; overflow: hidden; }
.card-header { padding: 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; background: #fff; }
.card-header:hover { background: #f5f5f5; }
/* 修复2宽度自适应超长省略鼠标悬停显示完整名称 */
.item-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.toggle-icon { font-size: 12px; color: #888; margin-left: 8px; }
.details-content { padding: 10px 12px; border-top: 1px dashed #ddd; background: #fff; }
.method-list { display: flex; flex-direction: column; gap: 6px; }
.method-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; color: #555; }
.no-methods { color: #999; font-size: 13px; padding: 4px 0; }
.empty-tip { color: #999; text-align: center; margin-top: 40px; font-size: 14px; }
</style>

View File

@@ -59,23 +59,30 @@ describe('Bug #550: 门诊医生站-检查申请项目选择交互优化', { tag
cy.login('doctor1', '123456')
cy.visit('/outpatient/examination-application')
// 1. 选择分类并勾选项目
// 1. 选择分类
cy.contains('检查项目分类').should('be.visible')
cy.contains('彩超').click()
cy.contains('128线排').parent().find('input[type="checkbox"]').check()
cy.get('.category-list li').contains('彩超').click()
// 2. 验证已选卡片显示:去除“套餐”前缀,默认收起
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')
// 2. 勾选项目(模拟数据中存在 128线排彩超套餐
cy.get('.item-list li').contains('128线排彩超套餐').click()
// 3. 验证解耦:展开后检查方法未被自动勾选
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')
// 3. 验证已选择区域出现卡片,且默认收起
cy.get('[data-cy="selected-card-101"]').should('be.visible')
cy.get('[data-cy="selected-card-101"] .item-title').should('have.text', '128线排彩超') // 验证去除“套餐”
cy.get('[data-cy="details-panel"]').should('not.be.visible') // 验证默认收起
// 4. 验证独立勾选与层级结构
cy.get('@selectedCard').find('[data-cy="method-item"]').first().find('input[type="checkbox"]').check()
cy.get('@selectedCard').find('[data-cy="method-item"]').first().find('input[type="checkbox"]').should('be.checked')
cy.get('@selectedCard').find('.card-header').should('contain.text', '128线排')
// 4. 验证检查方法未自动勾选
cy.get('[data-cy="expand-btn"]').click() // 展开查看
cy.get('[data-cy="method-item"]').first().find('input[type="checkbox"]').should('not.be.checked')
// 5. 独立勾选检查方法
cy.get('[data-cy="method-item"]').first().find('input[type="checkbox"]').click()
cy.get('[data-cy="method-item"]').first().find('input[type="checkbox"]').should('be.checked')
// 再次点击取消,验证独立控制
cy.get('[data-cy="method-item"]').first().find('input[type="checkbox"]').click()
cy.get('[data-cy="method-item"]').first().find('input[type="checkbox"]').should('not.be.checked')
// 6. 验证名称完整显示hover 或 title 属性)
cy.get('[data-cy="selected-card-101"] .item-title').should('have.attr', 'title', '128线排彩超')
})
})