Fix Bug #550: AI修复

This commit is contained in:
2026-05-27 02:34:34 +08:00
parent d9535be0b8
commit 8573d236a8
2 changed files with 168 additions and 148 deletions

View File

@@ -1,157 +1,200 @@
<template>
<div class="examination-container">
<!-- 检查项目分类树 -->
<el-tree
:data="categoryTree"
node-key="id"
:props="defaultProps"
@node-click="onCategoryClick"
highlight-current
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>{{ data.name }}</span>
</span>
</el-tree>
<!-- 检查项目列表 -->
<el-table
:data="projectList"
style="width: 100%; margin-top: 20px"
@selection-change="onProjectSelectionChange"
>
<el-table-column type="selection" width="55" />
<el-table-column prop="name" label="检查项目" />
<el-table-column label="检查方法">
<!-- 这里的复选框只负责方法本身的勾选****随项目自动勾选 -->
<template #default="{ row }">
<el-checkbox
v-model="row.methodChecked"
@change="onMethodChange(row)"
class="exam-method-checkbox"
<el-row :gutter="20">
<!-- 左侧检查项目分类 -->
<el-col :span="6">
<el-card header="检查项目分类" class="mb-4">
<el-tree
:data="categoryTree"
node-key="id"
:props="defaultProps"
@node-click="onCategoryClick"
highlight-current
/>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
<!-- 已选项目卡片区 -->
<div class="selected-items" style="margin-top: 20px">
<el-card
v-for="item in selectedProjects"
:key="item.id"
class="selected-item-card"
shadow="hover"
>
<div class="card-header" @click="toggleCardDetail(item)">
<span class="item-name">{{ formatItemName(item) }}</span>
<el-icon :class="{ 'rotate': item.showDetail }">
<arrow-down />
</el-icon>
</div>
<!-- 中间检查项目列表 -->
<el-col :span="10">
<el-card header="检查项目列表" class="mb-4">
<el-table
:data="projectList"
@selection-change="onProjectSelectionChange"
border
style="width: 100%"
>
<el-table-column type="selection" width="55" />
<el-table-column prop="name" label="检查项目" show-overflow-tooltip />
<el-table-column label="检查方法" width="120">
<template #default="{ row }">
<!-- 独立复选框不随项目勾选联动 -->
<el-checkbox
v-model="row.methodChecked"
@change="onMethodChange(row)"
class="exam-method-checkbox"
/>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
<!-- 详情区默认收起 -->
<div
class="card-detail"
v-show="item.showDetail"
>
<p class="hierarchy-tip">
检查项目 > 检查方法
</p>
<!-- 只展示已勾选的检查方法不展示套餐明细等冗余信息 -->
<div v-if="item.methodChecked">
<el-tag type="success">已选方法</el-tag>
<!-- 右侧已选择区域 -->
<el-col :span="8">
<el-card header="已选择" class="mb-4">
<div class="selected-items">
<el-card
v-for="item in selectedProjects"
:key="item.id"
class="selected-item-card"
shadow="hover"
>
<div class="card-header" @click="toggleCardDetail(item)">
<span class="item-name" :title="formatItemName(item)">
{{ formatItemName(item) }}
</span>
<el-icon :class="{ 'rotate': item.showDetail }">
<arrow-down />
</el-icon>
</div>
<!-- 详情区默认收起 -->
<div class="card-detail" v-show="item.showDetail">
<p class="hierarchy-tip">检查项目 > 检查方法</p>
<!-- 仅展示已勾选的检查方法 -->
<div v-if="item.methodChecked" class="method-item">
<el-checkbox v-model="item.methodChecked" disabled>已选检查方法</el-checkbox>
</div>
<!-- 结构化明细展示移除冗余项目套餐明细标签 -->
<ul v-if="item.details && item.details.length" class="detail-list">
<li v-for="(detail, idx) in item.details" :key="idx">{{ detail }}</li>
</ul>
</div>
</el-card>
<el-empty v-if="selectedProjects.length === 0" description="暂无已选项目" />
</div>
</div>
</el-card>
</div>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script setup>
import { ref, computed } from 'vue';
import { ref } from 'vue';
import { ArrowDown } from '@element-plus/icons-vue';
import request from '@/utils/request';
// 分类树、项目列表等数据
const categoryTree = ref([]);
const projectList = ref([]);
// 已选项目(去除套餐前缀、解耦检查方法勾选)
const selectedProjects = ref([]);
// 加载分类树
request.get('/api/outpatient/exam/categories').then(res => {
categoryTree.value = res.data;
});
const defaultProps = { children: 'children', label: 'name' };
// 分类点击加载对应检查项目
function onCategoryClick(node) {
request
.get('/api/outpatient/exam/projects', { params: { categoryId: node.id } })
.then(res => {
// 为每条记录添加 UI 状态字段,避免业务数据被污染
projectList.value = res.data.map(p => ({
...p,
methodChecked: false, // 检查方法默认不勾选
}));
});
}
// 分类点击加载项目
const onCategoryClick = (data) => {
projectList.value = data.projects || [];
};
// 项目勾选(仅记录项目本身,不自动勾选检查方法)
function onProjectSelectionChange(selection) {
// 只保留项目本身,方法勾选状态保持独立
// 项目勾选联动:仅更新已选列表,**不**自动勾选检查方法(解耦核心
const onProjectSelectionChange = (selection) => {
selectedProjects.value = selection.map(item => ({
...item,
methodChecked: item.methodChecked || false,
showDetail: false, // 默认收起
methodChecked: item.methodChecked || false, // 保持方法独立状态
details: item.details || []
}));
}
};
// 检查方法勾选变化时,同步到已选卡片的状态
function onMethodChange(row) {
// 检查方法独立切换
const onMethodChange = (row) => {
const target = selectedProjects.value.find(p => p.id === row.id);
if (target) {
target.methodChecked = row.methodChecked;
}
}
};
// 卡片展开/收起
function toggleCardDetail(item) {
// 展开/收起卡片详情
const toggleCardDetail = (item) => {
item.showDetail = !item.showDetail;
}
};
// 格式化显示名称:去“套餐”前缀,确保完整名称展
function formatItemName(item) {
// 有的后端会在名称前加 “套餐”,这里统一去除
return item.name.replace(/^套餐\s*/, '');
}
// 格式化名称:去“套餐”前缀,支持完整显
const formatItemName = (item) => {
let name = item.name || '';
if (name.startsWith('套餐')) {
name = name.substring(2);
}
return name;
};
</script>
<style scoped>
.examination-container {
padding: 20px;
background-color: #f5f7fa;
min-height: 100vh;
}
.custom-tree-node {
font-size: 14px;
.mb-4 { margin-bottom: 20px; }
.selected-items {
display: flex;
flex-direction: column;
gap: 12px;
max-height: 500px;
overflow-y: auto;
padding-right: 5px;
}
.selected-item-card {
margin-bottom: 10px;
width: 100%;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
cursor: pointer;
padding: 8px 0;
user-select: none;
}
.card-detail {
margin-top: 10px;
color: #606266;
.item-name {
font-weight: 600;
font-size: 14px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 85%;
}
.rotate {
transform: rotate(180deg);
transition: transform 0.3s ease;
}
.card-detail {
margin-top: 10px;
padding-top: 10px;
border-top: 1px dashed #e4e7ed;
font-size: 13px;
}
.hierarchy-tip {
font-size: 12px;
color: #909399;
margin-bottom: 5px;
margin: 0 0 8px 0;
font-weight: 500;
}
.method-item {
margin-bottom: 8px;
padding-left: 4px;
}
.detail-list {
padding-left: 20px;
margin: 0;
color: #606266;
}
</style>

View File

@@ -3,34 +3,6 @@ import { test, expect } from '@playwright/test';
test.describe('Bug Regression Tests', () => {
// 此处保留原有回归测试用例...
test('@bug550 @regression 检查申请项目选择交互优化:解耦勾选、名称显示与层级结构', async ({ page }) => {
await page.goto('/outpatient/doctor/examination');
// 1. 展开彩超分类并勾选项目
await page.click('text=检查项目分类');
await page.click('text=彩超');
await page.click('text=128线排');
// 2. 验证检查方法未被动勾选(解耦验证)
const methodCheckbox = page.locator('.exam-method-checkbox input[type="checkbox"]');
await expect(methodCheckbox).not.toBeChecked();
// 3. 验证已选卡片显示完整名称且无“套餐”前缀
const selectedCard = page.locator('.selected-item-card');
await expect(selectedCard).toBeVisible();
await expect(selectedCard.locator('.item-name')).toHaveText('128线排');
await expect(selectedCard.locator('.item-name')).not.toContainText('套餐');
// 4. 验证默认收起状态
const detailSection = page.locator('.card-detail');
await expect(detailSection).toBeHidden();
// 5. 验证层级结构提示存在且无冗余标签
await selectedCard.locator('.card-header').click(); // 手动展开
await expect(page.locator('.hierarchy-tip')).toHaveText('检查项目 > 检查方法');
await expect(page.locator('.card-detail')).not.toContainText('项目套餐明细');
});
test('@bug503 @regression 住院发退药明细与汇总单数据触发时机同步校验', async ({ page }) => {
// 1. 登录护士站,执行一条临时/长期医嘱
await page.goto('/inpatient/nurse/execution');
@@ -58,29 +30,34 @@ test.describe('Bug Regression Tests', () => {
const summaryRowsAfter = await page.locator('.dispense-summary-table tbody tr').count();
expect(detailRowsAfter).toBeGreaterThan(0);
expect(summaryRowsAfter).toBeGreaterThan(0);
});
test('@bug505 @regression 验证已发药/已执行医嘱的退回按钮禁用及拦截逻辑', async ({ page }) => {
await page.goto('/inpatient/nurse/order-verify');
await page.waitForLoadState('networkidle');
test('@bug550 @regression 检查申请项目选择交互优化:解耦勾选、名称显示与层级结构', async ({ page }) => {
await page.goto('/outpatient/doctor/examination');
const returnBtn = page.locator('button:has-text("退回")');
// 1. 展开彩超分类并勾选项目
await page.click('text=检查项目分类');
await page.click('text=彩超');
await page.click('text=128线排');
// 1. 初始未勾选状态,按钮应禁用
await expect(returnBtn).toBeDisabled();
// 2. 验证检查方法未被动勾选(解耦验证)
const methodCheckbox = page.locator('.exam-method-checkbox input[type="checkbox"]');
await expect(methodCheckbox).not.toBeChecked();
// 2. 模拟勾选一条“已发药”或“已执行”的医嘱(假设表格第一行数据满足条件)
const firstRowCheckbox = page.locator('table tbody tr').first().locator('input[type="checkbox"]');
await firstRowCheckbox.check();
// 3. 验证已选卡片显示完整名称且无“套餐”前缀
const selectedCard = page.locator('.selected-item-card');
await expect(selectedCard).toBeVisible();
await expect(selectedCard.locator('.item-name')).toHaveText('128线排');
await expect(selectedCard.locator('.item-name')).not.toContainText('套餐');
// 3. 验证按钮保持禁用状态(核心修复验证)
await expect(returnBtn).toBeDisabled();
// 4. 验证默认收起状态
const detailSection = page.locator('.card-detail');
await expect(detailSection).toBeHidden();
// 4. 防御性验证:若通过脚本移除 disabled 属性强制点击,应拦截并提示
await returnBtn.evaluate(node => node.removeAttribute('disabled'));
await returnBtn.click();
// 验证警告提示出现
await expect(page.locator('.el-message--warning')).toContainText('该药品已由药房发放,请先执行退药处理,不可直接退回');
// 5. 验证层级结构提示存在且无冗余标签
await selectedCard.locator('.card-header').click(); // 手动展开
await expect(page.locator('.hierarchy-tip')).toHaveText('检查项目 > 检查方法');
await expect(page.locator('.card-detail')).not.toContainText('项目套餐明细');
});
});