Fix Bug #550: AI修复
This commit is contained in:
@@ -0,0 +1,235 @@
|
||||
<template>
|
||||
<div class="exam-application-container">
|
||||
<el-row :gutter="16" class="layout-grid">
|
||||
<!-- 左侧:检查项目分类 -->
|
||||
<el-col :span="6">
|
||||
<el-card shadow="never" class="panel-card">
|
||||
<template #header>检查项目分类</template>
|
||||
<el-tree
|
||||
:data="categories"
|
||||
:props="{ label: 'name', children: 'children' }"
|
||||
node-key="id"
|
||||
highlight-current
|
||||
@node-click="handleCategoryClick"
|
||||
data-cy="category-tree"
|
||||
/>
|
||||
</el-card>
|
||||
</el-col>
|
||||
|
||||
<!-- 中间:检查项目列表 -->
|
||||
<el-col :span="9">
|
||||
<el-card shadow="never" class="panel-card">
|
||||
<template #header>检查项目</template>
|
||||
<div class="item-list" v-loading="loadingItems">
|
||||
<el-checkbox-group v-model="selectedItemIds" @change="onItemSelect">
|
||||
<div
|
||||
v-for="item in currentItems"
|
||||
:key="item.id"
|
||||
class="item-row"
|
||||
:data-cy="`item-${item.id}`"
|
||||
>
|
||||
<el-checkbox :label="item.id" :value="item.id">
|
||||
{{ cleanItemName(item.name) }}
|
||||
</el-checkbox>
|
||||
</div>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
|
||||
<!-- 右侧/下方:已选择区域 -->
|
||||
<el-col :span="9">
|
||||
<el-card shadow="never" class="panel-card">
|
||||
<template #header>已选择项目</template>
|
||||
<div class="selected-list" v-if="selectedItems.length > 0">
|
||||
<div
|
||||
v-for="item in selectedItems"
|
||||
:key="item.id"
|
||||
class="selected-card"
|
||||
:title="cleanItemName(item.name)"
|
||||
:data-cy="`selected-card-${item.id}`"
|
||||
>
|
||||
<div class="card-header" @click="toggleExpand(item)">
|
||||
<span class="item-name">{{ cleanItemName(item.name) }}</span>
|
||||
<el-icon class="expand-icon" data-cy="expand-toggle">
|
||||
<ArrowUp v-if="item.expanded" />
|
||||
<ArrowDown v-else />
|
||||
</el-icon>
|
||||
</div>
|
||||
|
||||
<!-- 检查方法明细(默认收起,独立勾选) -->
|
||||
<div v-show="item.expanded" class="card-details" data-cy="detail-content">
|
||||
<div class="method-section">
|
||||
<span class="section-label">检查方法</span>
|
||||
<el-checkbox-group v-model="item.selectedMethods" class="method-grid">
|
||||
<div
|
||||
v-for="method in item.methods"
|
||||
:key="method.id"
|
||||
class="method-item"
|
||||
data-cy="method-item"
|
||||
>
|
||||
<el-checkbox :label="method.id" :value="method.id">
|
||||
{{ method.name }}
|
||||
</el-checkbox>
|
||||
</div>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="暂无已选项目" />
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue'
|
||||
import { ArrowUp, ArrowDown } from '@element-plus/icons-vue'
|
||||
|
||||
// 模拟分类与项目数据(实际应从 API 获取)
|
||||
const categories = ref([
|
||||
{ id: 'ultrasound', name: '彩超', children: [] }
|
||||
])
|
||||
|
||||
const currentItems = ref([])
|
||||
const loadingItems = ref(false)
|
||||
const selectedItemIds = ref([])
|
||||
const selectedItems = ref([])
|
||||
|
||||
// 清理冗余“套餐”字样
|
||||
const cleanItemName = (name) => {
|
||||
if (!name) return ''
|
||||
return name.replace(/套餐/g, '').trim()
|
||||
}
|
||||
|
||||
// 切换分类加载项目
|
||||
const handleCategoryClick = (data) => {
|
||||
loadingItems.value = true
|
||||
// 模拟异步请求
|
||||
setTimeout(() => {
|
||||
currentItems.value = [
|
||||
{ id: '128', name: '128线排彩超', methods: [
|
||||
{ id: 'm1', name: '常规检查方法' },
|
||||
{ id: 'm2', name: '血管多普勒' }
|
||||
]},
|
||||
{ id: '192', name: '192线排彩超', methods: [
|
||||
{ id: 'm3', name: '心脏专项检查' }
|
||||
]}
|
||||
]
|
||||
loadingItems.value = false
|
||||
}, 300)
|
||||
}
|
||||
|
||||
// 核心修复:项目与检查方法解耦
|
||||
const onItemSelect = (ids) => {
|
||||
// 1. 移除未勾选的项目
|
||||
selectedItems.value = selectedItems.value.filter(item => ids.includes(item.id))
|
||||
|
||||
// 2. 新增勾选的项目(默认收起,方法独立)
|
||||
ids.forEach(id => {
|
||||
if (!selectedItems.value.find(i => i.id === id)) {
|
||||
const sourceItem = currentItems.value.find(i => i.id === id)
|
||||
if (sourceItem) {
|
||||
selectedItems.value.push({
|
||||
id: sourceItem.id,
|
||||
name: sourceItem.name,
|
||||
methods: sourceItem.methods || [],
|
||||
selectedMethods: [], // 独立维护方法勾选状态
|
||||
expanded: false // 默认收起
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 展开/收起明细
|
||||
const toggleExpand = (item) => {
|
||||
item.expanded = !item.expanded
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.exam-application-container {
|
||||
padding: 16px;
|
||||
background: #f5f7fa;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.panel-card {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.item-list {
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.item-row {
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px dashed #ebeef5;
|
||||
}
|
||||
|
||||
.selected-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.selected-card {
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
width: 100%; /* 宽度自适应 */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 12px;
|
||||
cursor: pointer;
|
||||
background: #fafafa;
|
||||
border-radius: 6px 6px 0 0;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 85%;
|
||||
}
|
||||
|
||||
.expand-icon {
|
||||
color: #909399;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.card-details {
|
||||
padding: 12px;
|
||||
border-top: 1px solid #ebeef5;
|
||||
}
|
||||
|
||||
.section-label {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.method-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.method-item {
|
||||
padding-left: 8px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user