fix: 修复getUserHealthData接口departmentInfo参数问题

- 统一前端参数使用departmentInfo,避免orgId到departmentInfo的转换混乱
- 确保departmentInfo参数始终有默认值(空字符串),避免后端必需参数校验失败
- 保持向后兼容性,搜索组件中继续同步departmentInfo和orgId字段

修复错误:
- Required request parameter 'departmentInfo' for method parameter type String is not present

技术改进:
- 简化API参数映射逻辑
- 消除不必要的参数转换步骤
- 提高代码可读性和维护性
This commit is contained in:
2025-08-30 15:08:11 +08:00
parent 949d740019
commit fdf51e43e5
3 changed files with 23 additions and 1 deletions
@@ -52,6 +52,11 @@ export function fetchUserHealthData(params?: Api.Health.HealthChartSearchParams)
delete filteredParams.userId;
}
// 确保 departmentInfo 有默认值
if (!filteredParams.departmentInfo) {
filteredParams.departmentInfo = '';
}
return request({
url: '/t_user_health_data/getUserHealthData',
params: filteredParams
+2 -1
View File
@@ -29,6 +29,7 @@ const searchParams = ref({
page: 1,
pageSize: 10,
departmentInfo: null,
orgId: null,
userId: null,
startDate,
endDate,
@@ -117,7 +118,7 @@ async function fetchHealthData() {
try {
const response = await fetchUserHealthData({
customerId: searchParams.value.customerId,
orgId: searchParams.value.orgId,
departmentInfo: searchParams.value.orgId || '',
userId: searchParams.value.userId,
startDate: searchParams.value.startDate,
endDate: searchParams.value.endDate,
@@ -76,6 +76,22 @@ watch(
}
);
// 监听departmentInfo变化,同步到orgId字段(保持向后兼容)
watch(
() => model.value.departmentInfo,
departmentInfo_val => {
// 如果departmentInfo是数组(多选),取第一个值;如果是单选,直接使用
if (Array.isArray(departmentInfo_val) && departmentInfo_val.length > 0) {
model.value.orgId = departmentInfo_val[0];
} else if (departmentInfo_val && !Array.isArray(departmentInfo_val)) {
model.value.orgId = departmentInfo_val;
} else {
model.value.orgId = null;
}
},
{ immediate: true }
);
// 组件挂载时加载特征选项
onMounted(() => {
loadFeatureOptions();