Fix Bug #507: [住院护士站-住院记账-补费] 项目单位未获取、执行科室显示内码且缺乏默认/模糊搜索逻辑
**后端开发重点**:优先搜索 Java/Spring 后端代码。 关键词:Controller, Service, Mapper, API, 接口, 数据查询 搜索目录:openhis-server-new/src/, his-repo/src/ 修复三个问题: 1. 单位字段显示为空:getUnitCodeOptions 中 unitCode/minUnitCode 未做 String() 转换,与 selectUnitCode(String类型)比较时类型不匹配导致 el-select 无法正确选中;unitCodeChange 中同样存在类型比较问题 2. 执行科室/位置默认值未生效:departmentOptions 在 onMounted 异步加载,用户快速点击项目时数据尚未加载完成导致默认 positionId 为空;增加 watch 监听科室/位置选项加载完成,自动补填默认值;弹窗打开时重新加载确保数据最新 3. 下拉模糊搜索不生效:优化 filterOptions/getFilteredOptions 过滤逻辑,增加拼音首字母(pyStr)搜索支持
This commit is contained in:
@@ -481,12 +481,43 @@ watch(
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
executeTime.value = formatDateStr(new Date(), 'YYYY-MM-DD HH:mm:ss');
|
||||
// 弹窗打开时重新加载科室和位置选项,确保数据最新
|
||||
loadDepartmentOptions();
|
||||
getDiseaseInitLoc(16);
|
||||
} else {
|
||||
resetData();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// 监听科室选项加载完成,为已添加的诊疗项目设置默认执行科室
|
||||
watch(
|
||||
() => departmentOptions.value,
|
||||
(depts) => {
|
||||
if (!depts || depts.length === 0) return;
|
||||
feeItemsList.value.forEach(item => {
|
||||
if (item.adviceType === 3 && !item.positionId) {
|
||||
const patientOrgId = props.patientInfo.organizationId;
|
||||
const matched = depts.find(d => String(d.id) === String(patientOrgId));
|
||||
item.positionId = matched ? String(matched.id) : String(depts[0].id);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// 监听位置选项加载完成,为已添加的耗材项目设置默认位置
|
||||
watch(
|
||||
() => locationOptions.value,
|
||||
(locs) => {
|
||||
if (!locs || locs.length === 0) return;
|
||||
feeItemsList.value.forEach(item => {
|
||||
if (item.adviceType === 2 && !item.positionId) {
|
||||
item.positionId = String(locs[0].value);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// 加载科室选项
|
||||
function loadDepartmentOptions() {
|
||||
getOrgList()
|
||||
@@ -527,23 +558,27 @@ function getDiseaseInitLoc() {
|
||||
locationOptions.value = [];
|
||||
});
|
||||
}
|
||||
// 下拉框模糊搜索过滤
|
||||
// 下拉框模糊搜索过滤(自定义filter-method,配合element-plus filterable使用)
|
||||
function filterOptions(val, row, optionsKey) {
|
||||
const key = row.adviceDefinitionId + '_' + optionsKey;
|
||||
filterKeywords.value[key] = val;
|
||||
if (!val || val.trim() === '') {
|
||||
delete filterKeywords.value[key];
|
||||
} else {
|
||||
filterKeywords.value[key] = val.toLowerCase();
|
||||
}
|
||||
}
|
||||
function getFilteredOptions(row, optionsKey) {
|
||||
const key = row.adviceDefinitionId + '_' + optionsKey;
|
||||
const keyword = filterKeywords.value[key];
|
||||
const options = optionsKey === 'departmentOptions' ? departmentOptions.value : locationOptions.value;
|
||||
if (!keyword || keyword.trim() === '') {
|
||||
if (!keyword) {
|
||||
return options;
|
||||
}
|
||||
const lower = keyword.toLowerCase();
|
||||
return options.filter(item => {
|
||||
const name = (item.name || item.label || '').toLowerCase();
|
||||
const id = String(item.id || item.value || '').toLowerCase();
|
||||
return name.includes(lower) || id.includes(lower);
|
||||
const py = (item.pyStr || '').toLowerCase();
|
||||
return name.includes(keyword) || id.includes(keyword) || py.includes(keyword);
|
||||
});
|
||||
}
|
||||
// 获取组套类型文本
|
||||
@@ -553,9 +588,9 @@ function getItemType_Text(type) {
|
||||
}
|
||||
function getUnitCodeOptions(row) {
|
||||
const unitCodes = [
|
||||
{ code: row.unitCode, codeText: row.unitCode_dictText },
|
||||
{ code: row.minUnitCode, codeText: row.minUnitCode_dictText },
|
||||
];
|
||||
{ code: String(row.unitCode), codeText: row.unitCode_dictText },
|
||||
{ code: String(row.minUnitCode), codeText: row.minUnitCode_dictText },
|
||||
].filter(item => item.code);
|
||||
// 使用 Set 来跟踪已经存在的 code
|
||||
const seenCodes = new Set();
|
||||
const uniqueUnitCodes = unitCodes.filter((item) => {
|
||||
@@ -575,11 +610,11 @@ function unitCodeChange(row) {
|
||||
// 获取价格
|
||||
const price = row.priceList?.[0]?.price || 0;
|
||||
|
||||
// 根据选择的单位调整单价
|
||||
if (row.selectUnitCode === row.unitCode) {
|
||||
// 根据选择的单位调整单价(统一用字符串比较)
|
||||
if (String(row.selectUnitCode) === String(row.unitCode)) {
|
||||
// 如果选择的是大单位 (如 "盒")
|
||||
row.unitPrice = price.toFixed(6); // 单价就是原价
|
||||
} else if (row.selectUnitCode === row.minUnitCode) {
|
||||
} else if (String(row.selectUnitCode) === String(row.minUnitCode)) {
|
||||
// 如果选择的是小单位 (如 "个")
|
||||
row.unitPrice = (price / (row.partPercent || 1)).toFixed(6); // 单价 = 原价 / 拆零比
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user