Files
his/openhis-ui-vue3/src/template/useOptionsList.js
zhangfei 9c3e603b94 Fix Bug #443: 手术计费:点击签发耗材时异常报错
当手术计费弹窗中点击"签发"耗材时,因耗材的locationId(发放库房)为空导致后端异常。
在DoctorStationAdviceAppServiceImpl.handDevice方法中,当locationId为null时,使用登录用户的科室ID作为默认值,
与NurseBillingAppService中的处理方式保持一致。
2026-05-08 09:14:18 +08:00

50 lines
1.7 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 导入 API 函数,用于从服务器获取带有选项列表的数据
import {getListWithOptionList} from '@/views/basicmanage/caseTemplatesStatistics/api';
// 导入 Vue 3 的组合式 APIonMounted组件挂载后执行和 ref响应式数据
import {onMounted, ref} from 'vue';
// 创建响应式数据:统计选项列表,初始为空数组
const statisticsOptionList = ref([]);
/**
* 初始化统计选项列表数据
* 异步函数,通过 API 获取数据并更新到响应式变量中
*/
const initStatic = async () => {
try {
// 调用 API 获取数据
const res = await getListWithOptionList();
// 将获取到的数据赋值给响应式变量
statisticsOptionList.value = res.data;
} catch (error) {
// 错误处理:打印错误信息到控制台
console.log(error);
}
};
/**
* Vue 3 组合式函数:用于获取和管理统计选项列表
* @returns {Object} 返回包含响应式数据和方法的对象
*/
export default function useOptionsList() {
// 组件挂载后自动初始化数据
onMounted(() => {
initStatic();
});
/**
* 根据代码获取对应的选项列表
* @param {string} code - 统计类型代码
* @returns {Array} 返回匹配的选项列表,如果没有匹配则返回空数组
*/
const getStatisticsOptionList = (code) => {
// 在统计选项列表中查找匹配代码的项,然后返回其 optionList 属性,如果没有找到则返回空数组
return statisticsOptionList.value.find((item) => item.code === code)?.optionList || [];
};
// 返回响应式数据和方法供组件使用
return {
statisticsOptionList, // 完整的统计选项列表
getStatisticsOptionList, // 根据代码获取选项列表的方法
};
}