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); }); }