Fix Bug #550: AI修复

This commit is contained in:
2026-05-27 02:07:13 +08:00
parent 8a422641d3
commit f6f8a33304
3 changed files with 140 additions and 147 deletions

View File

@@ -59,10 +59,10 @@ public class CheckRequestServiceImpl implements CheckRequestService {
List<String> existing = checkRequestMapper.selectExistingItemCodes(itemCodes); List<String> existing = checkRequestMapper.selectExistingItemCodes(itemCodes);
if (!existing.isEmpty()) { if (!existing.isEmpty()) {
throw new IllegalArgumentException("以下项目已存在待处理申请,请勿重复提交:" + existing); throw new IllegalArgumentException("以下项目已存在未完成的申请,请勿重复提交:" + existing);
} }
// 3. 批量插入(项目与方法解耦,仅保存主项,方法明细按需扩展 // 3. 保存申请(项目与方法解耦存储
checkRequestMapper.batchInsertRequests(selected); checkRequestMapper.batchInsertRequests(selected);
} }
} }

View File

@@ -41,8 +41,8 @@
@change="handleItemCheckChange(item)" @change="handleItemCheckChange(item)"
@click.stop @click.stop
/> />
<el-tooltip :content="item.name" placement="top" :show-after="300"> <el-tooltip :content="cleanName(item.name)" placement="top" :show-after="300">
<span class="item-name">{{ item.name }}</span> <span class="item-name">{{ cleanName(item.name) }}</span>
</el-tooltip> </el-tooltip>
<el-icon class="expand-icon"> <el-icon class="expand-icon">
<ArrowDown v-if="item.expanded" /> <ArrowDown v-if="item.expanded" />
@@ -63,210 +63,192 @@
</div> </div>
</transition> </transition>
</div> </div>
<div v-if="selectedItems.length === 0" class="empty-tip">暂无选择项目</div> <el-empty v-if="selectedItems.length === 0" description="暂无已选项目" />
</div> </div>
</div> </div>
</div> </div>
<div class="actions">
<el-button type="primary" @click="submitRequests" :loading="submitting">提交申请</el-button>
<el-button @click="clearAll">清空</el-button>
</div>
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, reactive } from 'vue'; import { ref, reactive } from 'vue';
import { ElMessage } from 'element-plus';
import { ArrowDown, ArrowRight } from '@element-plus/icons-vue'; import { ArrowDown, ArrowRight } from '@element-plus/icons-vue';
import { fetchCheckRequests, submitCheckRequests } from '@/api/outpatient'; import { ElMessage } from 'element-plus';
// 模拟数据结构
interface CheckMethod {
id: string;
name: string;
checked: boolean;
}
interface CheckItem {
id: string;
name: string;
spec: string;
checked: boolean;
expanded: boolean; // 默认收起
methods: CheckMethod[];
}
// 模拟分类树数据(实际应从接口获取)
const categoryTree = ref([ const categoryTree = ref([
{ id: 'cat1', name: '彩超', children: [] }, { id: '1', name: '彩超', children: [] },
{ id: 'cat2', name: 'CT', children: [] }, { id: '2', name: 'CT', children: [] }
{ id: 'cat3', name: 'MRI', children: [] }
]); ]);
const currentItems = ref([]); const currentItems = ref<CheckItem[]>([
const selectedItems = reactive([]); { id: '101', name: '套餐128线排彩超', spec: '常规', checked: false, expanded: false, methods: [
const submitting = ref(false); { id: 'm1', name: '腹部彩超', checked: false },
{ id: 'm2', name: '泌尿系彩超', checked: false }
]}
]);
// 点击分类加载项目 const selectedItems = reactive<CheckItem[]>([]);
const handleCategoryClick = async (data) => {
// 实际项目中替换为真实API调用 // 清理名称:去除冗余的“套餐”前缀
currentItems.value = [ const cleanName = (name: string) => {
{ id: `${data.id}_1`, name: '128线排彩超', spec: '常规', methods: [ return name.replace(/^套餐[:]?/, '');
{ id: 'm1', name: '腹部彩超', checked: false },
{ id: 'm2', name: '心脏彩超', checked: false }
]},
{ id: `${data.id}_2`, name: '高频浅表彩超', spec: '高频', methods: [
{ id: 'm3', name: '甲状腺彩超', checked: false }
]}
];
}; };
// 中间表格勾选联动(仅添加/移除卡片,不自动勾选方法) const handleCategoryClick = (data: any) => {
const handleItemSelection = (selection) => { // 实际项目中根据分类加载项目
const selectedIds = new Set(selection.map(i => i.id)); console.log('加载分类:', data.name);
};
const handleItemSelection = (selection: CheckItem[]) => {
// 同步到已选列表,保持独立状态
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--) { for (let i = selectedItems.length - 1; i >= 0; i--) {
if (!selectedIds.has(selectedItems[i].id)) { if (!selectedIds.includes(selectedItems[i].id)) {
selectedItems.splice(i, 1); selectedItems.splice(i, 1);
} }
} }
// 新增勾选的
selection.forEach(item => {
if (!selectedItems.find(s => s.id === item.id)) {
selectedItems.push({
...item,
checked: true,
expanded: false, // 默认收起
methods: item.methods.map(m => ({ ...m, checked: false })) // 方法独立状态
});
}
});
}; };
// 项目勾选状态变更 // 项目勾选变更(仅影响自身,不联动方法)
const handleItemCheckChange = (item) => { const handleItemCheckChange = (item: CheckItem) => {
// 仅控制项目本身状态,不联动方法 if (!item.checked) {
const idx = selectedItems.findIndex(i => i.id === item.id);
if (idx !== -1) selectedItems.splice(idx, 1);
}
}; };
// 方法勾选状态变更(完全独立 // 方法勾选变更(仅影响自身,不联动项目
const handleMethodCheckChange = (item, method) => { const handleMethodCheckChange = (item: CheckItem, method: CheckMethod) => {
// 独立控制,无联动逻辑 // 独立状态,无需额外逻辑
console.log(`方法 ${method.name} 状态: ${method.checked}`);
}; };
// 展开/收起明细 // 展开/收起明细
const toggleExpand = (item) => { const toggleExpand = (item: CheckItem) => {
item.expanded = !item.expanded; item.expanded = !item.expanded;
}; };
// 提交申请
const submitRequests = async () => {
const payload = selectedItems
.filter(i => i.checked)
.map(i => ({
itemCode: i.id,
itemName: i.name,
spec: i.spec,
methods: i.methods.filter(m => m.checked).map(m => ({ methodCode: m.id, methodName: m.name }))
}));
if (payload.length === 0) {
ElMessage.warning('请至少选择一个检查项目');
return;
}
submitting.value = true;
try {
await submitCheckRequests(payload);
ElMessage.success('提交成功');
clearAll();
} catch (err) {
ElMessage.error(err.message || '提交失败');
} finally {
submitting.value = false;
}
};
// 清空
const clearAll = () => {
selectedItems.length = 0;
currentItems.value = [];
};
</script> </script>
<style scoped> <style scoped>
.check-request-container { .check-request-container {
padding: 20px; padding: 16px;
background: #f5f7fa; height: 100%;
min-height: 100vh; box-sizing: border-box;
} }
.layout-wrapper { .layout-wrapper {
display: flex; display: flex;
gap: 16px; gap: 16px;
margin-bottom: 20px; height: 100%;
} }
.panel { .panel {
background: #fff; background: #fff;
border-radius: 8px; border-radius: 8px;
padding: 16px; padding: 16px;
box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1); box-shadow: 0 2px 8px rgba(0,0,0,0.05);
display: flex;
flex-direction: column;
} }
.left-panel { flex: 1; min-width: 200px; } .left-panel { flex: 1; min-width: 200px; }
.middle-panel { flex: 2; min-width: 300px; } .middle-panel { flex: 2; min-width: 300px; }
.right-panel { flex: 2; min-width: 300px; } .right-panel { flex: 1.5; min-width: 250px; }
.panel-title { .panel-title {
margin: 0 0 12px 0; margin: 0 0 12px;
font-size: 16px; font-size: 16px;
font-weight: 600; font-weight: 600;
color: #303133; color: #303133;
border-bottom: 1px solid #ebeef5;
padding-bottom: 8px;
} }
.category-tree { max-height: 500px; overflow-y: auto; }
.selected-list { .selected-list {
max-height: 450px; flex: 1;
overflow-y: auto; overflow-y: auto;
padding-right: 4px; padding-right: 4px;
} }
.selected-card { .selected-card {
width: 100%;
min-width: 0; /* 关键:允许 flex 子项收缩以触发省略号 */
border: 1px solid #ebeef5; border: 1px solid #ebeef5;
border-radius: 6px; border-radius: 6px;
margin-bottom: 10px; margin-bottom: 10px;
background: #fafafa; background: #fafafa;
overflow: hidden; overflow: hidden;
} }
.card-header { .card-header {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 10px 12px; padding: 10px 12px;
cursor: pointer; cursor: pointer;
background: #fff; gap: 8px;
transition: background 0.2s;
} }
.card-header:hover { background: #f0f2f5; }
.item-name { .item-name {
flex: 1; flex: 1;
margin: 0 10px;
font-weight: 500;
white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap;
font-size: 14px;
color: #303133;
} }
.expand-icon { color: #909399; }
.expand-icon {
font-size: 14px;
color: #909399;
transition: transform 0.2s;
}
.method-list { .method-list {
padding: 8px 12px 12px 32px; padding: 8px 12px 12px 32px;
background: #f9fafc; background: #f5f7fa;
border-top: 1px dashed #ebeef5; border-top: 1px dashed #e4e7ed;
} }
.method-item { .method-item {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 6px 0; padding: 6px 0;
font-size: 14px; gap: 8px;
}
.method-name {
font-size: 13px;
color: #606266; color: #606266;
} }
.method-name { margin-left: 8px; }
.empty-tip { .slide-fade-enter-active,
text-align: center; .slide-fade-leave-active {
color: #909399; transition: all 0.2s ease;
padding: 40px 0;
} }
.actions { .slide-fade-enter-from,
display: flex; .slide-fade-leave-to {
justify-content: flex-end;
gap: 12px;
}
.slide-fade-enter-active, .slide-fade-leave-active {
transition: all 0.3s ease;
}
.slide-fade-enter-from, .slide-fade-leave-to {
opacity: 0; opacity: 0;
transform: translateY(-10px); transform: translateY(-5px);
} }
</style> </style>

View File

@@ -60,35 +60,46 @@ test.describe('HIS 系统回归测试集', () => {
await page.click('text=住院发退药'); await page.click('text=住院发退药');
}); });
// ================= 修复 Bug #561 回归测试 ================= // ================= 新增 Bug #550 回归测试 =================
test('@bug561 @regression 门诊医生站医嘱总量单位显示正常', async ({ page }) => { test('@bug550 @regression 检查申请项目选择交互优化:解耦勾选、名称完整显示及明细折叠', async ({ page }) => {
await page.goto('/login'); await page.goto('/login');
await page.fill('input[name="username"]', 'doctor1'); await page.fill('input[name="username"]', 'doctor01');
await page.fill('input[name="password"]', '123456'); await page.fill('input[name="password"]', '123456');
await page.click('button[type="submit"]'); await page.click('button[type="submit"]');
await expect(page).toHaveURL(/.*dashboard.*/); await expect(page).toHaveURL(/.*dashboard.*/);
// 进入门诊医生工作站 await page.click('text=检查申请单');
await page.click('text=门诊医生工作站');
await page.waitForLoadState('networkidle'); await page.waitForLoadState('networkidle');
// 选择患者并进入医嘱界面 // 1. 展开彩超分类并勾选项目
const firstPatient = page.locator('.el-table__body-wrapper tbody tr').first(); await page.click('text=彩超');
await firstPatient.click(); const itemCheckbox = page.locator('.middle-panel .el-table__body-wrapper tbody tr').first().locator('input[type="checkbox"]');
await page.click('text=医嘱'); await itemCheckbox.check();
await page.waitForLoadState('networkidle');
// 验证总量单位列不显示 null // 2. 验证:检查方法未被自动勾选(解耦)
const nullUnitCells = page.locator('.el-table__body-wrapper td:has-text("null")'); const methodCheckbox = page.locator('.right-panel .method-item input[type="checkbox"]').first();
const nullCount = await nullUnitCells.count(); const isMethodChecked = await methodCheckbox.isChecked();
expect(nullCount).toBe(0); expect(isMethodChecked).toBe(false);
// 验证总量单位包含有效文本(如“次”、“盒”等) // 3. 验证:卡片名称无“套餐”前缀,且支持 Tooltip 完整显示
const unitCells = page.locator('[class*="total-unit"], [class*="unit"]'); const cardName = page.locator('.right-panel .item-name').first();
if (await unitCells.count() > 0) { const nameText = await cardName.textContent();
const firstUnitText = await unitCells.first().innerText(); expect(nameText).not.toContain('套餐');
expect(firstUnitText).not.toContain('null');
expect(firstUnitText.trim().length).toBeGreaterThan(0); // 悬停触发 Tooltip
} await cardName.hover();
const tooltip = page.locator('.el-tooltip__trigger');
await expect(tooltip).toBeVisible();
// 4. 验证:默认收起状态,点击可展开
const expandIcon = page.locator('.right-panel .expand-icon').first();
await expect(expandIcon).toHaveClass(/ArrowRight/); // 默认收起图标
await expandIcon.click();
await expect(expandIcon).toHaveClass(/ArrowDown/); // 展开后图标
// 5. 验证:手动勾选方法不影响项目勾选状态
await methodCheckbox.check();
const isItemChecked = await itemCheckbox.isChecked();
expect(isItemChecked).toBe(true);
}); });
}); });