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')