Fix Bug #550: AI修复

This commit is contained in:
2026-05-27 04:41:29 +08:00
parent b25614ff48
commit 454b7a91db
2 changed files with 207 additions and 202 deletions

View File

@@ -4,6 +4,7 @@
<div class="panel category-panel">
<h3 class="panel-title">检查项目分类</h3>
<el-tree
ref="categoryTreeRef"
:data="categoryTree"
:props="{ label: 'name', children: 'children' }"
node-key="id"
@@ -15,129 +16,121 @@
<!-- 中间检查项目列表 -->
<div class="panel item-panel">
<h3 class="panel-title">检查项目</h3>
<el-checkbox-group v-model="selectedItemIds" @change="handleItemSelect">
<el-checkbox
<div class="item-list">
<div
v-for="item in currentItems"
:key="item.id"
:label="item.id"
class="item-checkbox"
class="item-card"
:class="{ active: item.checked }"
@click="handleItemSelect(item)"
>
{{ item.name }}
</el-checkbox>
</el-checkbox-group>
<el-checkbox v-model="item.checked" @click.stop="handleItemSelect(item)" />
<span class="item-name">{{ item.name }}</span>
</div>
</div>
</div>
<!-- 右侧已选择区域 -->
<!-- 右侧已选择 & 检查方法/明细 -->
<div class="panel selected-panel">
<h3 class="panel-title">已选择</h3>
<div v-if="selectedGroups.length === 0" class="empty-tip">暂无选择项目</div>
<div
v-for="group in selectedGroups"
:key="group.itemId"
class="selected-item-card"
>
<!-- 卡片头部名称自适应/提示 + 展开收起控制 -->
<div class="card-header" @click="toggleDetail(group.itemId)">
<el-tooltip :content="group.itemName" placement="top" :show-after="300">
<span class="item-name">{{ truncateName(group.itemName) }}</span>
</el-tooltip>
<el-icon class="toggle-icon">
<ArrowDown v-if="group.expanded" />
<ArrowRight v-else />
</el-icon>
</div>
<div class="selected-list" v-if="selectedItems.length">
<div v-for="item in selectedItems" :key="item.id" class="selected-group">
<!-- 修复2卡片宽度自适应悬停提示完整名称去除冗余套餐前缀 -->
<div
class="selected-card"
:title="item.name"
@click="toggleExpand(item)"
>
<span class="card-name">{{ cleanName(item.name) }}</span>
<el-icon class="expand-icon">
<ArrowDown v-if="!item.expanded" />
<ArrowUp v-else />
</el-icon>
</div>
<!-- 明细区域默认收起严格遵循 项目 > 检查方法 层级 -->
<div v-show="group.expanded" class="detail-panel">
<div v-for="method in group.methods" :key="method.id" class="method-row">
<el-checkbox
v-model="method.checked"
@change="handleMethodChange(group.itemId, method)"
>
{{ method.name }}
</el-checkbox>
<!-- 修复3结构化展示明细默认收起严格遵循项目 > 检查方法层级 -->
<div v-show="item.expanded" class="method-detail-list">
<div v-for="method in item.methods" :key="method.id" class="method-item">
<!-- 修复1检查方法独立勾选不随父级联动 -->
<el-checkbox
v-model="method.checked"
@change="handleMethodCheck(method)"
>
{{ method.name }}
</el-checkbox>
</div>
</div>
</div>
</div>
<el-empty v-else description="暂无已选项目" />
</div>
</div>
</template>
<script setup>
import { ref, computed } from 'vue';
import { ElTree, ElCheckbox, ElCheckboxGroup, ElTooltip, ElIcon } from 'element-plus';
import { ArrowDown, ArrowRight } from '@element-plus/icons-vue';
<script setup lang="ts">
import { ref, computed } from 'vue'
import { ArrowDown, ArrowUp } from '@element-plus/icons-vue'
import type { ElTree } from 'element-plus'
// 模拟分类数据
const categoryTree = ref([
{ id: 'c1', name: '彩超', children: [
{ id: 'i1', name: '128线排', methods: [{ id: 'm1', name: '常规检查', checked: false }, { id: 'm2', name: '血管多普勒', checked: false }] },
{ id: 'i2', name: '套餐-腹部彩超', methods: [{ id: 'm3', name: '肝胆脾胰', checked: false }] }
]}
]);
// 模拟数据结构
interface ExamMethod {
id: string
name: string
checked: boolean
}
const currentItems = ref([]);
const selectedItemIds = ref([]);
const selectedGroups = ref([]);
interface ExamItem {
id: string
name: string
checked: boolean
methods: ExamMethod[]
expanded?: boolean
}
// 点击分类加载对应项目
const handleCategoryClick = (data) => {
if (data.children) {
currentItems.value = data.children;
}
};
const categoryTreeRef = ref<InstanceType<typeof ElTree>>()
const categoryTree = ref<any[]>([])
const currentItems = ref<ExamItem[]>([])
const selectedItems = ref<ExamItem[]>([])
// 修复1项目勾选与检查方法解耦。仅更新已选列表不联动修改方法状态
const handleItemSelect = (ids) => {
// 过滤掉已取消的项目
const validGroups = selectedGroups.value.filter(g => ids.includes(g.itemId));
// 修复2清理名称去除冗余“套餐”字样
const cleanName = (name: string): string => {
return name.replace(/套餐/g, '').trim()
}
// 切换分类加载项目
const handleCategoryClick = (data: any) => {
// 实际项目中此处调用API获取项目列表
currentItems.value = data.items || []
}
// 修复1独立解耦 - 勾选项目时不再自动勾选检查方法
const handleItemSelect = (item: ExamItem) => {
item.checked = !item.checked
// 新增勾选的项目
const newIds = ids.filter(id => !validGroups.some(g => g.itemId === id));
newIds.forEach(id => {
const item = findItemById(id);
if (item) {
validGroups.push({
itemId: item.id,
// 修复2去除“套餐”前缀避免冗余显示
itemName: item.name.replace(/^套餐[-]?/, ''),
expanded: false, // 修复3默认收起状态
methods: item.methods.map(m => ({ ...m, checked: false })) // 修复1方法默认不勾选保持独立
});
}
});
selectedGroups.value = validGroups;
};
// 修复3点击展开/收起明细
const toggleDetail = (itemId) => {
const group = selectedGroups.value.find(g => g.itemId === itemId);
if (group) group.expanded = !group.expanded;
};
// 检查方法独立勾选逻辑
const handleMethodChange = (itemId, method) => {
// 仅更新当前方法状态,不影响项目或其他方法
console.log(`方法 ${method.name} 状态变更为: ${method.checked}`);
};
// 辅助:查找项目
const findItemById = (id) => {
for (const cat of categoryTree.value) {
if (cat.children) {
const found = cat.children.find(i => i.id === id);
if (found) return found;
if (item.checked) {
// 仅将项目加入已选列表,默认展开状态为 false
if (!selectedItems.value.find(i => i.id === item.id)) {
selectedItems.value.push({
...item,
expanded: false,
methods: item.methods?.map(m => ({ ...m, checked: false })) || []
})
}
} else {
selectedItems.value = selectedItems.value.filter(i => i.id !== item.id)
}
return null;
};
}
// 修复2名称截断与提示
const truncateName = (name) => {
return name.length > 12 ? name.slice(0, 12) + '...' : name;
};
// 修复1检查方法独立勾选逻辑
const handleMethodCheck = (method: ExamMethod) => {
// 仅更新方法自身状态,不向上冒泡影响父级项目
console.log(`[Bug550 Fix] 方法独立勾选: ${method.name} -> ${method.checked}`)
}
// 修复3展开/收起明细交互
const toggleExpand = (item: ExamItem) => {
item.expanded = !item.expanded
}
</script>
<style scoped>
@@ -146,78 +139,114 @@ const truncateName = (name) => {
gap: 16px;
padding: 16px;
height: 100%;
background: #f5f7fa;
}
.panel {
background: #fff;
border: 1px solid #ebeef5;
border-radius: 4px;
border-radius: 8px;
padding: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
display: flex;
flex-direction: column;
}
.category-panel { width: 20%; }
.item-panel { width: 35%; }
.selected-panel { width: 45%; }
.category-panel { flex: 1; }
.item-panel { flex: 2; }
.selected-panel { flex: 2; }
.panel-title {
margin: 0 0 12px;
font-size: 14px;
font-weight: 600;
color: #303133;
border-bottom: 1px solid #ebeef5;
padding-bottom: 8px;
}
.item-checkbox {
display: block;
margin-bottom: 8px;
.item-list {
display: flex;
flex-direction: column;
gap: 8px;
overflow-y: auto;
max-height: 600px;
}
.selected-item-card {
.item-card {
display: flex;
align-items: center;
padding: 8px 12px;
border: 1px solid #dcdfe6;
border-radius: 4px;
margin-bottom: 10px;
overflow: hidden;
cursor: pointer;
transition: all 0.2s;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 12px;
background: #f5f7fa;
cursor: pointer;
user-select: none;
.item-card.active {
border-color: #409eff;
background: #ecf5ff;
}
.item-name {
margin-left: 8px;
flex: 1;
}
/* 修复2已选卡片样式优化 */
.selected-list {
display: flex;
flex-direction: column;
gap: 10px;
overflow-y: auto;
max-height: 600px;
}
.selected-card {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 12px;
background: #fafafa;
border: 1px solid #e4e7ed;
border-radius: 6px;
cursor: pointer;
/* 宽度自适应与文本截断 */
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.card-name {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 13px;
font-weight: 500;
color: #303133;
}
.toggle-icon {
.expand-icon {
margin-left: 8px;
color: #909399;
transition: transform 0.2s;
}
.detail-panel {
padding: 8px 12px;
/* 修复3明细层级样式 */
.method-detail-list {
margin-top: 6px;
padding-left: 16px;
border-left: 2px solid #409eff;
background: #fff;
border-top: 1px solid #ebeef5;
border-radius: 0 0 4px 4px;
}
.method-row {
.method-item {
padding: 6px 0;
font-size: 13px;
color: #606266;
border-bottom: 1px dashed #ebeef5;
}
.empty-tip {
text-align: center;
color: #909399;
padding: 20px 0;
font-size: 13px;
.method-item:last-child {
border-bottom: none;
}
</style>