From ba37bff5582473300fbcf0f89ce39a938d54a2ed Mon Sep 17 00:00:00 2001 From: XiuHe <1109326957@qq.com> Date: Tue, 10 Mar 2026 10:53:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E2=80=9C=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E2=80=9D=E4=B8=AD=E7=9A=84=E9=83=A8=E5=88=86?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/views/assets/location/edit.vue | 32 ++++++++++++++++------- admin/src/views/assets/location/index.vue | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/admin/src/views/assets/location/edit.vue b/admin/src/views/assets/location/edit.vue index 18c6fc81..686f9485 100644 --- a/admin/src/views/assets/location/edit.vue +++ b/admin/src/views/assets/location/edit.vue @@ -9,7 +9,7 @@ @close="handleClose" > - + - + @@ -116,7 +117,7 @@ const formData = reactive({ //楼层号 floorNumber: 0, //状态 - status: 0 + status: '', }) const formRules = { @@ -146,11 +147,22 @@ const menuOptions = ref([]) const getMenu = async () => { const data: any = await getLocationList() - const menu: any = { id: 0, name: '顶级', children: [] } - menu.children = arrayToTree( - treeToArray(data.childLocation).filter((item) => item.type != "ER") - ) - menuOptions.value.push(menu) + const filteredTree = filterTree(data.childLocation, (item) => item.type !== 'ER') + // 构建顶级节点 + const menu: any = { + id: 0, + name: '顶级', + childLocation: filteredTree + } + menuOptions.value = [menu] +} + +// 递归过滤树形数据的辅助函数 +const filterTree = (tree: any[], predicate: (item: any) => boolean): any[] => { + return tree.filter(predicate).map(node => ({ + ...node, + childLocation: node.childLocation ? filterTree(node.childLocation, predicate) : [] + })) } const handleSubmit = async () => { diff --git a/admin/src/views/assets/location/index.vue b/admin/src/views/assets/location/index.vue index 92498a58..cb1272bb 100644 --- a/admin/src/views/assets/location/index.vue +++ b/admin/src/views/assets/location/index.vue @@ -167,7 +167,7 @@ const handleAdd = async (id?: number) => { await nextTick() if (id) { editRef.value?.setFormData({ - pid: id + parentId: id }) } editRef.value?.open('add')