Fix Bug #550: AI修复

This commit is contained in:
2026-05-27 02:12:06 +08:00
parent 80e77c043b
commit 62ba4772ef
3 changed files with 113 additions and 136 deletions

View File

@@ -58,197 +58,181 @@
@change="handleMethodCheckChange(item, method)"
@click.stop
/>
<span class="method-name">{{ method.name }}</span>
<span class="method-name" :title="method.name">{{ method.name }}</span>
</div>
</div>
</transition>
</div>
<el-empty v-if="selectedItems.length === 0" description="暂无已选项目" />
<el-empty v-if="selectedItems.length === 0" description="暂无已选项目" :image-size="60" />
</div>
<div class="panel-footer">
<el-button type="primary" @click="submitRequest" :disabled="selectedItems.length === 0">提交申请</el-button>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue';
import { ArrowDown, ArrowRight } from '@element-plus/icons-vue';
import { ElMessage } from 'element-plus';
<script setup>
import { ref } from 'vue'
import { ArrowDown, ArrowRight } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
// 模拟数据结构
interface CheckMethod {
id: string;
name: string;
checked: boolean;
const categoryTree = ref([])
const currentItems = ref([])
const selectedItems = ref([])
const handleCategoryClick = (data) => {
currentItems.value = data.children || []
}
interface CheckItem {
id: string;
name: string;
spec: string;
checked: boolean;
expanded: boolean; // 默认收起
methods: CheckMethod[];
}
const categoryTree = ref([
{ id: '1', name: '彩超', children: [] },
{ id: '2', name: 'CT', children: [] }
]);
const currentItems = ref<CheckItem[]>([
{ id: '101', name: '套餐128线排彩超', spec: '常规', checked: false, expanded: false, methods: [
{ id: 'm1', name: '腹部彩超', checked: false },
{ id: 'm2', name: '泌尿系彩超', checked: false }
]}
]);
const selectedItems = reactive<CheckItem[]>([]);
// 清理名称:去除冗余的“套餐”前缀
const cleanName = (name: string) => {
return name.replace(/^套餐[:]?/, '');
};
const handleCategoryClick = (data: any) => {
// 实际项目中根据分类加载项目
console.log('加载分类:', data.name);
};
const handleItemSelection = (selection: CheckItem[]) => {
// 同步到已选列表,保持独立状态
const handleItemSelection = (selection) => {
// 将选中的项目加入右侧列表,默认收起,独立勾选状态
selection.forEach(item => {
const exists = selectedItems.find(i => i.id === item.id);
if (!exists) {
selectedItems.push({ ...item, checked: true, expanded: false });
}
});
// 移除未勾选的
const selectedIds = selection.map(i => i.id);
for (let i = selectedItems.length - 1; i >= 0; i--) {
if (!selectedIds.includes(selectedItems[i].id)) {
selectedItems.splice(i, 1);
if (!selectedItems.value.find(s => s.id === item.id)) {
selectedItems.value.push({
...item,
checked: true,
expanded: false, // 默认收起
methods: item.methods || [] // 保持方法独立
})
}
})
// 处理取消选择
selectedItems.value = selectedItems.value.filter(s => selection.find(sel => sel.id === s.id))
}
const toggleExpand = (item) => {
item.expanded = !item.expanded
}
// 清理名称:去除“套餐”、“项目套餐明细”等冗余前缀/后缀
const cleanName = (name) => {
if (!name) return ''
return name.replace(/(项目套餐明细|套餐)/g, '').trim()
}
// 项目勾选变更:仅更新自身状态,不联动方法(解耦核心)
const handleItemCheckChange = (item) => {
// 明确不修改 item.methods 的 checked 状态,保持父子独立
}
// 方法勾选变更:仅更新自身状态
const handleMethodCheckChange = (item, method) => {
// 独立控制,不反向影响父级 item.checked
}
const submitRequest = async () => {
const payload = selectedItems.value
.filter(i => i.checked)
.map(i => ({
itemCode: i.code,
patientId: 'CURRENT_PATIENT_ID',
doctorId: 'CURRENT_DOCTOR_ID',
methods: i.methods.filter(m => m.checked).map(m => m.code)
}))
if (payload.length === 0) {
ElMessage.warning('请至少勾选一个项目或方法')
return
}
};
// 项目勾选变更(仅影响自身,不联动方法)
const handleItemCheckChange = (item: CheckItem) => {
if (!item.checked) {
const idx = selectedItems.findIndex(i => i.id === item.id);
if (idx !== -1) selectedItems.splice(idx, 1);
try {
// await submitCheckRequest(payload)
ElMessage.success('提交成功')
selectedItems.value = []
} catch (e) {
ElMessage.error(e.message || '提交失败')
}
};
// 方法勾选变更(仅影响自身,不联动项目)
const handleMethodCheckChange = (item: CheckItem, method: CheckMethod) => {
// 独立状态,无需额外逻辑
console.log(`方法 ${method.name} 状态: ${method.checked}`);
};
// 展开/收起明细
const toggleExpand = (item: CheckItem) => {
item.expanded = !item.expanded;
};
}
</script>
<style scoped>
.check-request-container {
padding: 16px;
height: 100%;
padding: 16px;
box-sizing: border-box;
}
.layout-wrapper {
display: flex;
gap: 16px;
height: 100%;
}
.panel {
background: #fff;
border-radius: 8px;
padding: 16px;
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
display: flex;
flex-direction: column;
}
.left-panel { flex: 1; min-width: 200px; }
.middle-panel { flex: 2; min-width: 300px; }
.right-panel { flex: 1.5; min-width: 250px; }
.left-panel { width: 20%; }
.middle-panel { width: 45%; }
.right-panel { width: 35%; }
.panel-title {
margin: 0 0 12px;
font-size: 16px;
font-weight: 600;
color: #303133;
border-bottom: 1px solid #eee;
padding-bottom: 8px;
}
.selected-list {
flex: 1;
overflow-y: auto;
padding-right: 4px;
}
.selected-card {
width: 100%;
min-width: 0; /* 关键:允许 flex 子项收缩以触发省略号 */
border: 1px solid #ebeef5;
border-radius: 6px;
margin-bottom: 10px;
background: #fafafa;
overflow: hidden;
width: 100%; /* 宽度自适应容器 */
box-sizing: border-box;
}
.card-header {
display: flex;
align-items: center;
padding: 10px 12px;
padding: 10px;
cursor: pointer;
gap: 8px;
}
.item-name {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 14px;
color: #303133;
font-weight: 500;
}
.expand-icon {
font-size: 14px;
color: #909399;
transition: transform 0.2s;
}
.method-list {
padding: 8px 12px 12px 32px;
background: #f5f7fa;
border-top: 1px dashed #e4e7ed;
padding: 0 10px 10px 30px;
border-top: 1px dashed #eee;
}
.method-item {
display: flex;
align-items: center;
padding: 6px 0;
gap: 8px;
}
.method-name {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 13px;
color: #606266;
}
.slide-fade-enter-active,
.slide-fade-leave-active {
transition: all 0.2s ease;
.panel-footer {
margin-top: 12px;
text-align: right;
}
.slide-fade-enter-from,
.slide-fade-leave-to {
.slide-fade-enter-active, .slide-fade-leave-active {
transition: all 0.3s ease;
}
.slide-fade-enter-from, .slide-fade-leave-to {
opacity: 0;
transform: translateY(-5px);
transform: translateY(-10px);
}
</style>

View File

@@ -61,7 +61,7 @@ test.describe('HIS 系统回归测试集', () => {
});
// ================= 修复 Bug #550 回归测试 =================
test('@bug550 @regression 检查申请项目选择交互解耦与展示优化', async ({ page }) => {
test('@bug550 @regression 检查申请项目选解耦与展示优化', async ({ page }) => {
await page.goto('/login');
await page.fill('input[name="username"]', 'doctor');
await page.fill('input[name="password"]', '123456');
@@ -71,32 +71,25 @@ test.describe('HIS 系统回归测试集', () => {
await page.click('text=检查申请单');
await page.waitForLoadState('networkidle');
// 1. 验证分类展开与项目勾选解耦
await page.click('text=彩超');
await page.waitForTimeout(500);
await page.locator('.item-panel .el-table__body tr:has-text("128线排") .el-checkbox').first().click();
// 1. 验证默认收起状态
const firstCard = page.locator('.selected-card').first();
await expect(firstCard.locator('.method-list')).toBeHidden();
// 验证检查方法未被自动勾选(解耦)
const methodCheckbox = page.locator('.selected-panel .method-item .el-checkbox').first();
await expect(methodCheckbox).not.toBeChecked();
// 2. 验证名称清理与 Tooltip
const itemName = page.locator('.item-name').first();
await expect(itemName).not.toContainText('套餐');
await itemName.hover();
await expect(page.locator('.el-tooltip__trigger')).toBeVisible();
// 2. 验证卡片名称清理与自适应
const cardName = page.locator('.selected-card .item-name').first();
await expect(cardName).not.toContainText('套餐');
await expect(cardName).toHaveAttribute('title', /128线排/); // 完整名称在 title 中
// 3. 验证勾选解耦:勾选项目不自动勾选方法
const itemCheckbox = page.locator('.card-header .el-checkbox').first();
await itemCheckbox.click();
const methodCheckbox = page.locator('.method-item .el-checkbox').first();
const isChecked = await methodCheckbox.isChecked();
expect(isChecked).toBe(false); // 应保持独立,不联动
// 3. 验证默认收起与层级结构
const methodList = page.locator('.selected-card .method-list').first();
await expect(methodList).toBeHidden(); // 默认收起
await page.locator('.selected-card .card-header').first().click();
await expect(methodList).toBeVisible(); // 点击展开
// 4. 验证手动勾选方法独立生效
await methodCheckbox.click();
await expect(methodCheckbox).toBeChecked();
// 父项目状态保持独立(不联动取消)
const itemCheckbox = page.locator('.selected-card .card-header .el-checkbox').first();
await expect(itemCheckbox).toBeChecked();
// 4. 验证展开/收起交互
await firstCard.locator('.card-header').click();
await expect(firstCard.locator('.method-list')).toBeVisible();
});
});

View File

@@ -39,7 +39,7 @@ public class CheckRequestServiceImpl implements CheckRequestService {
return;
}
// 1. 前端是否传入了重复的 item_code
// 1. 检查前端是否传入了重复的 item_code
List<String> duplicateCodes = selected.stream()
.collect(Collectors.groupingBy(item -> (String) item.get("itemCode")))
.entrySet().stream()
@@ -61,7 +61,7 @@ public class CheckRequestServiceImpl implements CheckRequestService {
throw new IllegalArgumentException("以下项目已存在待处理申请,请勿重复提交: " + alreadyPending);
}
// 3. 批量入库(项目与方法解耦,仅保存主项目记录,方法明细由前端独立组装或另表关联
// 3. 批量插入申请记录解耦明细仅保存主项与关联方法ID
checkRequestMapper.batchInsertCheckRequests(selected);
}
}