diff --git a/openhis-server-new/core-admin/src/main/java/com/core/web/controller/system/SysConfigController.java b/openhis-server-new/core-admin/src/main/java/com/core/web/controller/system/SysConfigController.java index 1f35a99d..378d4e1c 100644 --- a/openhis-server-new/core-admin/src/main/java/com/core/web/controller/system/SysConfigController.java +++ b/openhis-server-new/core-admin/src/main/java/com/core/web/controller/system/SysConfigController.java @@ -61,7 +61,25 @@ public class SysConfigController extends BaseController { */ @GetMapping(value = "/configKey/{configKey}") public AjaxResult getConfigKey(@PathVariable String configKey) { - return success(configService.selectConfigByKey(configKey)); + String configValue = configService.selectConfigByKey(configKey); + // 确保即使返回 null 或空字符串,也明确设置 data 字段 + // 如果 configValue 是 null,转换为空字符串 + if (configValue == null) { + configValue = ""; + } + // 直接创建 AjaxResult 并明确设置 data 字段,确保 data 字段始终存在 + AjaxResult result = new AjaxResult(); + result.put("code", 200); + result.put("msg", "操作成功"); + result.put("data", configValue); // 明确设置 data 字段,即使值为空字符串 + System.out.println("=== getConfigKey 调试信息 ==="); + System.out.println("configKey: " + configKey); + System.out.println("configValue: [" + configValue + "]"); + System.out.println("result.data: " + result.get("data")); + System.out.println("result.msg: " + result.get("msg")); + System.out.println("result.code: " + result.get("code")); + System.out.println("============================"); + return result; } /** diff --git a/openhis-server-new/core-system/src/main/java/com/core/system/service/impl/SysConfigServiceImpl.java b/openhis-server-new/core-system/src/main/java/com/core/system/service/impl/SysConfigServiceImpl.java index 024a0ecc..354a2d30 100644 --- a/openhis-server-new/core-system/src/main/java/com/core/system/service/impl/SysConfigServiceImpl.java +++ b/openhis-server-new/core-system/src/main/java/com/core/system/service/impl/SysConfigServiceImpl.java @@ -69,8 +69,25 @@ public class SysConfigServiceImpl implements ISysConfigService { config.setConfigKey(configKey); SysConfig retConfig = configMapper.selectConfig(config); if (StringUtils.isNotNull(retConfig)) { - redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue()); - return retConfig.getConfigValue(); + String dbValue = retConfig.getConfigValue(); + System.out.println("=== selectConfigByKey 调试信息 ==="); + System.out.println("configKey: " + configKey); + System.out.println("retConfig: " + retConfig); + System.out.println("configId: " + retConfig.getConfigId()); + System.out.println("configName: " + retConfig.getConfigName()); + System.out.println("configValue from DB: [" + dbValue + "]"); + System.out.println("configValue is null: " + (dbValue == null)); + System.out.println("configValue is empty: " + StringUtils.isEmpty(dbValue)); + System.out.println("================================"); + if (StringUtils.isNotEmpty(dbValue)) { + redisCache.setCacheObject(getCacheKey(configKey), dbValue); + return dbValue; + } else { + System.out.println("警告: configValue 为空,返回空字符串"); + return StringUtils.EMPTY; + } + } else { + System.out.println("警告: 数据库中未找到 configKey=" + configKey + " 的记录"); } return StringUtils.EMPTY; } diff --git a/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue b/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue index 5f669ca9..c1d5180b 100644 --- a/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue +++ b/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue @@ -701,6 +701,7 @@ const paymentId = ref(''); const loadingText = ref(''); const registerInfo = ref({}); // 原挂号记录信息 const queryType = ref('all'); // 查询类型:all-全部, normal-正常挂号, returned-退号记录 +const guardianAgeConfig = ref(''); // 监护人规定年龄配置 // 使用 ref 定义查询所得用户信息数据 const patientInfoList = ref(undefined); @@ -1524,11 +1525,49 @@ getLocationInfo(); async function loadGuardianAgeConfig() { try { const response = await getConfigKey('guardianAge'); - if (response.code === 200) { - guardianAgeConfig.value = response.data; + console.log('获取监护人年龄配置完整响应:', JSON.stringify(response, null, 2)); + console.log('响应 code:', response.code); + console.log('响应 data:', response.data); + console.log('响应 data 类型:', typeof response.data); + console.log('响应 data === null:', response.data === null); + console.log('响应 data === undefined:', response.data === undefined); + console.log('响应 data === "":', response.data === ''); + + if (response && response.code === 200) { + // response.data 可能是字符串、数字或对象 + let configValue = response.data; + + // 如果是对象,尝试获取 configValue 字段 + if (typeof configValue === 'object' && configValue !== null) { + configValue = configValue.configValue || configValue.value || ''; + console.log('从对象中提取的 configValue:', configValue); + } + + // 处理数字类型(可能是数字 18) + if (typeof configValue === 'number') { + configValue = String(configValue); + console.log('将数字转换为字符串:', configValue); + } + + // 转换为字符串并去除空白 + const trimmedValue = configValue !== null && configValue !== undefined ? String(configValue).trim() : ''; + console.log('trimmedValue:', trimmedValue, '长度:', trimmedValue.length); + + if (trimmedValue) { + guardianAgeConfig.value = trimmedValue; + console.log('✅ 监护人年龄配置值已设置为:', guardianAgeConfig.value, '类型:', typeof guardianAgeConfig.value); + } else { + console.warn('⚠️ 配置值为空,trimmedValue:', trimmedValue); + guardianAgeConfig.value = ''; + } + } else { + console.warn('⚠️ 获取监护人年龄配置失败,响应码:', response?.code, '响应:', response); + guardianAgeConfig.value = ''; } } catch (error) { - console.error('获取监护人规定年龄配置失败:', error); + console.error('❌ 获取监护人规定年龄配置失败:', error); + console.error('错误详情:', error.response || error); + guardianAgeConfig.value = ''; } } // 组件加载时获取配置