Fix Bug #550: AI修复

This commit is contained in:
2026-05-27 08:13:40 +08:00
parent 840793c61d
commit c91b9b07b3
2 changed files with 236 additions and 34 deletions

View File

@@ -0,0 +1,191 @@
<template>
<div class="exam-apply-container">
<el-row :gutter="16">
<!-- 左侧检查项目分类 -->
<el-col :span="5">
<el-card shadow="never" class="panel-card">
<template #header><span class="panel-title">检查项目分类</span></template>
<el-tree
:data="categoryTree"
:props="{ label: 'name', children: 'children' }"
highlight-current
@node-click="handleCategoryClick"
/>
</el-card>
</el-col>
<!-- 中间检查项目列表 -->
<el-col :span="10">
<el-card shadow="never" class="panel-card">
<template #header><span class="panel-title">检查项目</span></template>
<el-table
:data="currentItems"
row-key="id"
@selection-change="handleItemSelection"
style="width: 100%"
>
<el-table-column type="selection" width="50" />
<el-table-column prop="name" label="项目名称" show-overflow-tooltip />
</el-table>
</el-card>
</el-col>
<!-- 右侧已选择区域核心修复区 -->
<el-col :span="9">
<el-card shadow="never" class="panel-card selected-panel">
<template #header><span class="panel-title">已选择</span></template>
<div class="selected-list">
<div v-for="item in selectedItems" :key="item.id" class="selected-card">
<!-- 卡片头部项目勾选 + 名称 + 展开/收起 -->
<div class="card-header" @click="toggleExpand(item)">
<el-checkbox
v-model="item.checked"
@change="handleItemCheck(item)"
@click.stop
/>
<span class="item-name" :title="cleanName(item.name)">{{ cleanName(item.name) }}</span>
<el-icon class="expand-icon">
<ArrowDown v-if="item.isExpanded" />
<ArrowRight v-else />
</el-icon>
</div>
<!-- 检查方法/明细区域严格遵循 项目 > 检查方法 层级默认收起 -->
<transition name="el-fade-in">
<div v-if="item.isExpanded && item.methods?.length" class="method-list">
<div v-for="method in item.methods" :key="method.id" class="method-item">
<el-checkbox
v-model="method.checked"
@change="handleMethodCheck(item, method)"
@click.stop
/>
<span class="method-name" :title="method.name">{{ method.name }}</span>
</div>
</div>
</transition>
</div>
<el-empty v-if="selectedItems.length === 0" description="暂无已选项目" :image-size="60" />
</div>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { ArrowDown, ArrowRight } from '@element-plus/icons-vue'
// 数据结构定义
interface ExamMethod { id: string; name: string; checked: boolean }
interface ExamItem { id: string; name: string; checked: boolean; isExpanded: boolean; methods: ExamMethod[] }
const categoryTree = ref<any[]>([])
const currentItems = ref<ExamItem[]>([])
const selectedItems = ref<ExamItem[]>([])
// 修复点2清理冗余“套餐”前缀支持完整名称提示
const cleanName = (name: string) => name.replace(/套餐/g, '').trim()
// 修复点3默认收起状态点击切换展开/收起
const toggleExpand = (item: ExamItem) => {
item.isExpanded = !item.isExpanded
}
// 修复点1项目勾选独立解耦不联动检查方法
const handleItemCheck = (item: ExamItem) => {
if (item.checked) {
if (!selectedItems.value.find(i => i.id === item.id)) {
selectedItems.value.push({ ...item, isExpanded: false })
}
} else {
selectedItems.value = selectedItems.value.filter(i => i.id !== item.id)
}
}
// 修复点1检查方法勾选独立解耦仅更新自身状态
const handleMethodCheck = (item: ExamItem, method: ExamMethod) => {
const target = selectedItems.value.find(i => i.id === item.id)
if (target) {
const m = target.methods.find(m => m.id === method.id)
if (m) m.checked = method.checked
}
}
// 中间列表选择同步至已选区域
const handleItemSelection = (selection: ExamItem[]) => {
selection.forEach(item => {
if (!selectedItems.value.find(i => i.id === item.id)) {
selectedItems.value.push({ ...item, isExpanded: false })
}
})
selectedItems.value = selectedItems.value.filter(i => selection.some(s => s.id === i.id))
}
// 分类点击加载项目(含关联检查方法)
const handleCategoryClick = (data: any) => {
currentItems.value = data.items || []
}
</script>
<style scoped>
.exam-apply-container { padding: 16px; background: #f5f7fa; min-height: 100vh; }
.panel-card { height: 100%; }
.panel-title { font-weight: 600; font-size: 15px; }
.selected-panel { height: 600px; overflow: hidden; display: flex; flex-direction: column; }
.selected-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 10px; }
/* 修复点2卡片宽度自适应去除固定宽度限制 */
.selected-card {
border: 1px solid #dcdfe6;
border-radius: 6px;
background: #ffffff;
padding: 10px 12px;
width: 100%;
box-sizing: border-box;
transition: all 0.2s;
}
.selected-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.card-header {
display: flex;
align-items: center;
cursor: pointer;
gap: 8px;
user-select: none;
}
/* 修复点2名称溢出省略悬停提示完整内容 */
.item-name {
flex: 1;
font-weight: 500;
color: #303133;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* 修复点3层级缩进与视觉分隔 */
.method-list {
margin-top: 8px;
padding-left: 24px;
border-left: 2px solid #409eff;
background: #f9fafc;
border-radius: 0 0 4px 4px;
}
.method-item {
display: flex;
align-items: center;
gap: 8px;
padding: 4px 0;
}
.method-name {
flex: 1;
color: #606266;
font-size: 13px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.expand-icon { color: #909399; font-size: 14px; }
</style>