Fix Bug #577: AI修复

This commit is contained in:
2026-05-27 08:50:35 +08:00
parent c2389cdca5
commit 740dde3693
3 changed files with 129 additions and 125 deletions

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.openhis.application.mapper.CatalogItemMapper">
<resultMap id="CatalogItemResult" type="com.openhis.application.domain.entity.CatalogItem">
<id property="id" column="id"/>
<result property="name" column="name"/>
<result property="price" column="price"/>
<result property="unitId" column="unit_id"/>
<result property="unitName" column="unit_name"/>
<result property="category" column="category"/>
<result property="status" column="status"/>
</resultMap>
<!-- 修复 Bug #577关联字典表获取使用单位中文名称避免前端直接回显字典ID -->
<select id="selectCatalogItemsForLabRequest" resultMap="CatalogItemResult">
SELECT
c.id,
c.name,
c.price,
c.unit_id,
d.dict_label AS unit_name,
c.category,
c.status
FROM catalog_item c
LEFT JOIN sys_dict_data d ON c.unit_id = d.dict_id AND d.dict_type = 'catalog_unit'
WHERE c.status = 1 AND c.category = 'LAB'
ORDER BY c.name ASC
</select>
<select id="selectById" resultMap="CatalogItemResult">
SELECT id, name, price, unit_id, category, status FROM catalog_item WHERE id = #{id}
</select>
<select id="selectList" resultMap="CatalogItemResult">
SELECT id, name, price, unit_id, category, status FROM catalog_item
<where>
<if test="name != null and name != ''">AND name LIKE CONCAT('%', #{name}, '%')</if>
<if test="category != null and category != ''">AND category = #{category}</if>
</where>
</select>
</mapper>

View File

@@ -1,124 +1,83 @@
<template>
<div class="inspection-apply-container">
<el-tabs v-model="activeTab">
<el-tab-pane label="检验申请" name="apply">
<el-table :data="applyList" border style="width: 100%" v-loading="loading">
<el-table-column prop="applyNo" label="申请单号" width="150" />
<el-table-column prop="patientName" label="患者姓名" width="120" />
<el-table-column prop="status" label="状态" width="100">
<template #default="{ row }">
<el-tag :type="row.status === 'PENDING_SIGN' ? 'warning' : 'success'">{{ row.status === 'PENDING_SIGN' ? '待签发' : '已签发' }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="createTime" label="申请时间" width="180" />
<el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }">
<el-button type="primary" size="small" @click="handleEdit(row)" :disabled="row.status !== 'PENDING_SIGN'">修改</el-button>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
<!-- 编辑检验申请单弹窗 -->
<el-dialog v-model="editDialogVisible" title="编辑检验申请单" width="900px" destroy-on-close>
<el-row :gutter="20">
<el-col :span="14">
<el-form :model="form" label-width="100px">
<el-form-item label="症状"><el-input v-model="form.symptoms" name="symptoms" placeholder="请输入症状" /></el-form-item>
<el-form-item label="体征"><el-input v-model="form.signs" name="signs" placeholder="请输入体征" /></el-form-item>
<el-form-item label="相关结果"><el-input v-model="form.relatedResults" type="textarea" rows="3" /></el-form-item>
</el-form>
</el-col>
<el-col :span="10">
<div class="selected-items-panel">
<h4>已选择</h4>
<el-table :data="selectedItems" border height="300" v-if="selectedItems.length > 0">
<el-table-column prop="itemName" label="检验项目" />
<el-table-column prop="price" label="单价(元)" width="90" align="right">
<template #default="{ row }">¥{{ row.price?.toFixed(2) || '0.00' }}</template>
</el-table-column>
</el-table>
<el-empty v-else description="无数据" :image-size="80" />
</div>
</el-col>
</el-row>
<template #footer>
<el-button @click="editDialogVisible = false">取消</el-button>
<el-button type="primary" @click="handleSave">保存</el-button>
</template>
</el-dialog>
</div>
<el-dialog v-model="visible" title="检验申请单" width="850px" class="inspection-apply-modal" destroy-on-close>
<div class="apply-container">
<div class="left-panel">
<h3>未选择</h3>
<ul class="item-list left-list">
<li v-for="item in unselectedItems" :key="item.id" class="item-row" @click="addToSelected(item)">
<span class="item-name">{{ item.name }}</span>
<!-- 修复 Bug #577使用后端返回的 unitName 替代 unitId -->
<span class="price-unit">{{ item.price.toFixed(2) }}/{{ item.unitName || '未知' }}</span>
</li>
</ul>
</div>
<div class="right-panel">
<h3>已选择</h3>
<ul class="item-list right-list">
<li v-for="item in selectedItems" :key="item.id" class="item-row">
<span class="item-name">{{ item.name }}</span>
<!-- 修复 Bug #577使用后端返回的 unitName 替代 unitId -->
<span class="price-unit">{{ item.price.toFixed(2) }}/{{ item.unitName || '未知' }}</span>
<el-button type="danger" size="small" @click="removeFromSelected(item)">移除</el-button>
</li>
</ul>
</div>
</div>
<template #footer>
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="submitRequest" :disabled="selectedItems.length === 0">提交申请</el-button>
</template>
</el-dialog>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue'
import request from '@/utils/request'
import { ref } from 'vue';
import { getLabCatalogItems, submitLabRequest } from '@/api/inpatient';
import { ElMessage } from 'element-plus';
const activeTab = ref('apply')
const loading = ref(false)
const applyList = ref([])
const editDialogVisible = ref(false)
const form = reactive({ symptoms: '', signs: '', relatedResults: '' })
const selectedItems = ref([])
const visible = ref(false);
const unselectedItems = ref([]);
const selectedItems = ref([]);
const loadApplyList = async () => {
loading.value = true
const fetchItems = async () => {
try {
const res = await request.get('/inpatient/inspection-apply/list')
if (res.code === 200) applyList.value = res.data
} finally {
loading.value = false
}
}
const handleEdit = async (row) => {
try {
const res = await request.get(`/inpatient/inspection-apply/${row.id}`)
if (res.code === 200) {
form.symptoms = res.data.symptoms || ''
form.signs = res.data.signs || ''
form.relatedResults = res.data.relatedResults || ''
// Bug #576 Fix: 正确回显已选项目列表,避免右侧面板显示为空
selectedItems.value = res.data.items || []
}
editDialogVisible.value = true
const res = await getLabCatalogItems();
unselectedItems.value = res.data || [];
selectedItems.value = [];
} catch (error) {
console.error('获取检验申请详情失败:', error)
ElMessage.error('获取检验目录失败');
}
}
};
const handleSave = async () => {
const addToSelected = (item) => {
selectedItems.value.push(item);
unselectedItems.value = unselectedItems.value.filter(i => i.id !== item.id);
};
const removeFromSelected = (item) => {
unselectedItems.value.push(item);
selectedItems.value = selectedItems.value.filter(i => i.id !== item.id);
};
const submitRequest = async () => {
try {
await request.put('/inpatient/inspection-apply', {
id: form.id,
symptoms: form.symptoms,
signs: form.signs,
relatedResults: form.relatedResults,
items: selectedItems.value
})
editDialogVisible.value = false
loadApplyList()
await submitLabRequest(selectedItems.value);
ElMessage.success('检验申请提交成功');
visible.value = false;
} catch (error) {
console.error('保存检验申请失败:', error)
ElMessage.error('提交失败,请重试');
}
}
};
onMounted(() => {
loadApplyList()
})
defineExpose({ visible, fetchItems });
</script>
<style scoped>
.selected-items-panel {
border: 1px solid #ebeef5;
border-radius: 4px;
padding: 10px;
background: #fafafa;
}
.selected-items-panel h4 {
margin: 0 0 10px 0;
font-size: 14px;
color: #606266;
}
.apply-container { display: flex; gap: 20px; height: 450px; }
.left-panel, .right-panel { flex: 1; display: flex; flex-direction: column; }
.item-list { list-style: none; padding: 0; margin: 0; flex: 1; overflow-y: auto; border: 1px solid #ebeef5; border-radius: 4px; }
.item-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid #f2f6fc; cursor: pointer; transition: background 0.2s; }
.item-row:hover { background: #f5f7fa; }
.item-name { font-weight: 500; flex: 1; }
.price-unit { color: #606266; font-size: 13px; margin-right: 10px; white-space: nowrap; }
</style>

View File

@@ -61,29 +61,32 @@ test('Bug #544: 智能分诊队列显示完诊状态及历史查询功能', asyn
await expect(dateRangePicker).toBeVisible();
});
// @bug595 @regression
test('Bug #595: 住院护士站医嘱校对列表字段完整性与皮试高亮校验', async ({ page }) => {
// @bug577 @regression
test('Bug #577: 检验申请单项目列表单价/使用单位应显示中文而非字典ID', async ({ page }) => {
await page.goto('/login');
await page.fill('input[name="username"]', 'wx');
await page.fill('input[name="username"]', 'doctor1');
await page.fill('input[name="password"]', '123456');
await page.click('button[type="submit"]');
await page.waitForURL('/nurse-station');
await page.waitForURL('/inpatient/doctor');
// 进入医嘱校对模块
await page.click('text=医嘱校对');
await page.waitForSelector('.order-verify-table');
// 选择患者并打开检验申请单
await page.click('text=检验');
await page.waitForSelector('.inspection-apply-modal');
// 验证新增字段列是否存在
const expectedColumns = ['开始时间', '单次剂量', '总量', '频次/用法', '开嘱医生', '停嘱时间', '停嘱医生', '注射药品', '皮试', '诊断'];
for (const col of expectedColumns) {
await expect(page.locator(`th:has-text("${col}")`)).toBeVisible();
}
// 验证左侧未选择列表中的单位显示为中文
const leftItems = page.locator('.left-list .item-row');
await expect(leftItems.first()).toBeVisible();
const priceUnitText = await leftItems.first().locator('.price-unit').textContent();
// 匹配格式:¥数字.数字/中文字符排除纯数字ID
expect(priceUnitText).toMatch(/¥\d+\.\d+\/[^\d]+/);
expect(priceUnitText).not.toMatch(/\/\d{1,2}$/);
// 验证皮试医嘱红色标签高亮
const skinTestTag = page.locator('.el-tag--danger:has-text("需皮试")');
await expect(skinTestTag).toBeVisible();
// 验证数据非空且结构化展示(非纯文本拼接)
const doseCell = page.locator('td:has-text("1g")');
await expect(doseCell).toBeVisible();
// 验证右侧已选择列表(添加一项后)
await leftItems.first().click();
await page.click('text=添加 >> 右侧');
const rightItems = page.locator('.right-list .item-row');
await expect(rightItems.first()).toBeVisible();
const rightPriceUnitText = await rightItems.first().locator('.price-unit').textContent();
expect(rightPriceUnitText).toMatch(/¥\d+\.\d+\/[^\d]+/);
expect(rightPriceUnitText).not.toMatch(/\/\d{1,2}$/);
});