diff --git a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/testApplication.vue b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/testApplication.vue index b5f294642..c6e36d3bd 100755 --- a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/testApplication.vue +++ b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/applicationShow/testApplication.vue @@ -415,26 +415,16 @@ const getLocationInfo = async () => { const recursionFun = (targetDepartment) => { if (!targetDepartment) return ''; - let name = ''; - for (let index = 0; index < orgOptions.value.length; index++) { - const obj = orgOptions.value[index]; - if (obj.id == targetDepartment) { - name = obj.name; - break; + const findNode = (list, id) => { + if (!list || list.length === 0) return ''; + for (const item of list) { + if (item.id == id) return item.name; + const found = findNode(item.children, id); + if (found) return found; } - const subObjArray = obj['children']; - if (subObjArray && subObjArray.length > 0) { - for (let i = 0; i < subObjArray.length; i++) { - const item = subObjArray[i]; - if (item.id == targetDepartment) { - name = item.name; - break; - } - } - } - if (name) break; - } - return name; + return ''; + }; + return findNode(orgOptions.value, targetDepartment); }; const handleViewDetail = async (row) => {