diff --git a/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/FeeDialog.vue b/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/FeeDialog.vue index 8cba9430f..f58c0a90e 100755 --- a/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/FeeDialog.vue +++ b/openhis-ui-vue3/src/views/inpatientNurse/InpatientBilling/components/FeeDialog.vue @@ -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); // 单价 = 原价 / 拆零比 }