From 09b7f8b63278ddd64f5b47058ee27a1984fce093 Mon Sep 17 00:00:00 2001 From: zhaoyun Date: Fri, 29 May 2026 02:20:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(#578):=20=E8=AF=B7=E4=BF=AE=E5=A4=8D=20Bug?= =?UTF-8?q?=20#578=EF=BC=9A[=E4=B8=80=E8=88=AC]=20[=E6=82=A3=E8=80=85?= =?UTF-8?q?=E7=AE=A1=E7=90=86]=20=E4=BF=AE=E6=94=B9=E6=82=A3=E8=80=85?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=97=B6=EF=BC=8C=E7=BA=A7=E8=81=94=E7=9C=81?= =?UTF-8?q?=E5=B8=82=E5=8C=BA=E5=9B=9E=E6=98=BE=E4=B8=BA=E7=A9=BA=EF=BC=8C?= =?UTF-8?q?=E4=B8=94=E8=AF=A6=E7=BB=86=E5=9C=B0=E5=9D=80=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=8F=91=E7=94=9F=E9=87=8D=E5=A4=8D=E3=80=81=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E6=8B=BC=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: - Bug 1 — 级联省市区回显为空:** `patientAddDialog.vue` 的 `convertAddressToCodes` 函数是存根(stub),始终返回 `null`,导致回显时级联选择器无法选中任何值。 - ### 修改文件 - `src/views/charge/outpatientregistration/components/patientAddDialog.vue` - | 位置 | 改动 | - |---|---| - | `convertAddressToCodes` 函数 | 从存根替换为递归名称→代码查找(`findCodeByName`),使用 `options.value`(pcas 数据树)按名称匹配返回 code | - | `setFormData`(级联回显块后) | 新增地址前缀剥离逻辑:用 `addressProvince`+`addressCity`+`addressDistrict`+`addressStreet` 拼接前缀,从全地址 `address` 中去除前缀,使 `form.value.address` 只保留用户输入的详细地址部分(如"村道120号") | - ### 验证 - `npx eslint` — 0 errors, 仅 pre-existing warnings 修复: - 修改相关代码文件 --- .../components/patientAddDialog.vue | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue b/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue index e4f3fad10..203199351 100755 --- a/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue +++ b/openhis-ui-vue3/src/views/charge/outpatientregistration/components/patientAddDialog.vue @@ -1685,6 +1685,17 @@ function setFormData(rowData) { selectedOptions.value = codes.filter((code) => code !== null); } } + + // 从全地址中提取详细的用户输入部分(去除省市区前缀),避免保存时重复拼接 + const addressPrefix = [ + rowData.addressProvince, + rowData.addressCity, + rowData.addressDistrict, + rowData.addressStreet, + ].filter(Boolean).join(''); + if (rowData.address && addressPrefix && rowData.address.startsWith(addressPrefix)) { + form.value.address = rowData.address.substring(addressPrefix.length); + } // 设置患者 ID 信息 - 如果没有 patientIdInfoList 则创建一个 if (!form.value.patientIdInfoList || form.value.patientIdInfoList.length === 0) { @@ -1727,11 +1738,19 @@ function setFormData(rowData) { // 将地址转换为级联选择器所需的代码 function convertAddressToCodes(addressParts) { + const findCodeByName = (data, name) => { + for (const item of data) { + if (item.name === name) return item.code; + if (item.children) { + const result = findCodeByName(item.children, name); + if (result) return result; + } + } + return null; + }; return addressParts.map((part) => { if (!part) return null; - // 这里需要根据实际的地址名称找到对应的代码 - // 由于数据结构的复杂性,这里先返回空值 - return null; + return findCodeByName(options.value, part); }); }