From fdf51e43e535b654cbb6322ecc9526db760cf308 Mon Sep 17 00:00:00 2001 From: brunoGao Date: Sat, 30 Aug 2025 15:08:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DgetUserHealthData?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3departmentInfo=E5=8F=82=E6=95=B0=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 统一前端参数使用departmentInfo,避免orgId到departmentInfo的转换混乱 - 确保departmentInfo参数始终有默认值(空字符串),避免后端必需参数校验失败 - 保持向后兼容性,搜索组件中继续同步departmentInfo和orgId字段 修复错误: - Required request parameter 'departmentInfo' for method parameter type String is not present 技术改进: - 简化API参数映射逻辑 - 消除不必要的参数转换步骤 - 提高代码可读性和维护性 --- .../src/service/api/health/user-health-data.ts | 5 +++++ ljwx-admin/src/views/health/chart/index.vue | 3 ++- .../views/health/chart/modules/health-search.vue | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ljwx-admin/src/service/api/health/user-health-data.ts b/ljwx-admin/src/service/api/health/user-health-data.ts index 26ec63c..1ffd669 100644 --- a/ljwx-admin/src/service/api/health/user-health-data.ts +++ b/ljwx-admin/src/service/api/health/user-health-data.ts @@ -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 diff --git a/ljwx-admin/src/views/health/chart/index.vue b/ljwx-admin/src/views/health/chart/index.vue index 20c1eb6..9632087 100644 --- a/ljwx-admin/src/views/health/chart/index.vue +++ b/ljwx-admin/src/views/health/chart/index.vue @@ -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, diff --git a/ljwx-admin/src/views/health/chart/modules/health-search.vue b/ljwx-admin/src/views/health/chart/modules/health-search.vue index af982fc..bb85ec2 100644 --- a/ljwx-admin/src/views/health/chart/modules/health-search.vue +++ b/ljwx-admin/src/views/health/chart/modules/health-search.vue @@ -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();